Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPU Power consumption #28

Closed
velaar opened this issue Jan 10, 2020 · 124 comments
Closed

CPU Power consumption #28

velaar opened this issue Jan 10, 2020 · 124 comments
Labels
enhancement New feature or request

Comments

@velaar
Copy link

velaar commented Jan 10, 2020

@tylernguyen
Can you please confirm the CPU power of about 2W on PKG when idle? If possible also post an Intel power gadget screenshot.

I've got a feeling that the CPU power vectors are not exactly correct. I have a way lower PKG on Linux/Windows (<1W) and trying to pinpoint the issue.

Thanks!

Screen Shot 2020-01-10 at 8 22 24 AM

@tylernguyen
Copy link
Owner

I just quickly checked, mine is also pulling 2W on idle. Though I'm not exactly sure how to approach this issue. @velaar I saw your pull request, did power consumption improve after installing NVMEFix?

@velaar
Copy link
Author

velaar commented Jan 10, 2020

@tylernguyen Yes, but not on the CPU package. The system can now go down from around 9W to around 7W and I have a very low power SSD.

For the CPU package consumption, so far every app I run reports the original 1.3GHz CPU frequency vector. One way would be to determine if that is the case. Also for i7-8650U the minimum frequency is 400MHz but I was unable to patch the vector to push it this low.

CPU Ratio Info:
------------------------------------------
Base Clock Frequency (BLCK)............. : 100 MHz
Maximum Efficiency Ratio/Frequency.......:  4 ( 400 MHz)
Maximum non-Turbo Ratio/Frequency........: 21 (2100 MHz)
Maximum Turbo Ratio/Frequency............: 42 (4200 MHz)

IGPU Info:
------------------------------------------
IGPU Current Frequency...................:    0 MHz
IGPU Minimum Frequency...................:  300 MHz
IGPU Maximum Non-Turbo Frequency.........:  300 MHz
IGPU Maximum Turbo Frequency.............: 1150 MHz
IGPU Maximum limit.......................: No Limit

@Colton-Ko
Copy link

Screen Shot 2020-01-11 at 09 25 11
2W on idle as well

@velaar
Copy link
Author

velaar commented Jan 11, 2020

@Colton-Ko @tylernguyen
There is a chance that this is just a different type of measurement (comparing to Linux), but I was able to get <3W of total consumption on low brightness. (here: https://www.reddit.com/r/thinkpad/comments/8aqy5g/x1c6_on_linux_idle_29w_real_battery_life_on_light/). I guess 5W should be achievable in MacOS (that should give us about 10h of battery).

NVMeFix definitely helps. Now the question is if we can really push the CPU to C10 at 400MHz.
Another question is why CpuFriendFriend (and other similar apps) all show that the vector is 1.3GHz:

Current Frequency Vector:

1 of 2: 0D (1300 MHz)

Enter the new min hex freq (800Mhz would be 08, 1300Mhz would be 0D):

@Colton-Ko
Copy link

Colton-Ko commented Jan 12, 2020

@velaar I have only reached the minimum of 800MHz on i7-8550U in macOS. I used https://github.com/stevezhengshiqi/one-key-cpufriend to create a customized DataProvider for CPUFriend.kext

The below is the configuration screen when customizing CPUFriend using one-key-cpufriend
image

I am now trying to lower the frequency to 400MHz using one-key-cpufriend.

Test configuration:
Low Frequency Mode: 400MHz
Mode: Prefer max battery life

Result
Screen Shot 2020-01-12 at 12 21 25

CPU Ratio Info in AppleIntelInfo.kext

CPU Ratio Info:
------------------------------------------
Base Clock Frequency (BLCK)............. : 100 MHz
Maximum Efficiency Ratio/Frequency...... :  4 ( 400 MHz)
Maximum non-Turbo Ratio/Frequency....... : 20 (2000 MHz)
Maximum Turbo Ratio/Frequency........... : 40 (4000 MHz)

@velaar
Copy link
Author

velaar commented Jan 15, 2020

I think I did it :)

Screen Shot 2020-01-14 at 8 07 40 PM

@tylernguyen
Copy link
Owner

@velaar That's great! What did you do?

@velaar
Copy link
Author

velaar commented Jan 19, 2020

NVMeFix was the key to this as well as a low power SSD. Plus undervolting (-83mV), using CPU vectors from MacBookPro15,4 adjusted to 400MHz (practically only drops to 600), enabling ASPM through PCIutils on most of the devices, a lot of USB power tweaking.

I've hit a rough patch at work, so can't contribute at a previous rate for some time.

@velaar
Copy link
Author

velaar commented Jan 20, 2020

Sorry for double-posting. Today I woke my laptop and for some reason it was at an unusual power state. I don't know what caused it (ec bug?) but for some reason the CPU power consumption was exactly what it is supposed to be on this cpu. (See screenshots) I'm now wondering what happened and how can we replicate the condition. The good part is that It is possible to achieve 5.5W draw on X1C6 on MacOS X.

Screen Shot 2020-01-20 at 5 20 25 AM

Screen Shot 2020-01-20 at 10 25 47 AM

Update:
I purposely did not reboot the laptop since and using it throughout the day.
I have noticed two things:

  • The thunderbolt USB-C controller is NOT detected the ports have power but devices don't work (So it would seem that we are loosing the power through Thunderbolt)
  • I'm using the laptop the whole day and I'm still at 56% so it seems that the low drain is NOT a measurement error.

Now I'm wondering if we can bring a laptop to this state on demand, as I'd love to have the 8+ hours of battery even if I have to reboot for that

@velaar
Copy link
Author

velaar commented Jan 22, 2020

❗ HELP NEEDED❗

@tylernguyen, @Colton-Ko
Ok. So I found the way to increase the X1C6 battery life to about 9-10h at realistic brightness with low activity (python coding/web kind of tasks)

There are 3 components to it:

1. Undervolting
I use VoltageShift (kext + launchctl) but it doesn't seem to persist after sleep, a better undervaluing solution is needed. It is important that this solution can separately manage the Core, GPU and digital IO voltages and can re-apply it on a 1-3 minute basis (otherwise the EC resets offsets)

2. Thunderbolt / USB-C
Thunderbolt controller causes a C-storn on our laptops ramping the CPU package to 2.2-2.5W
If you disable it (or put into BIOS-assisted mode), the C-storm ends and the CPU properly clocks down to where it is supposed to be allowing us to reach a way better power state. While I'm writing this message on battery my laptop consumes about 5W of power while WiFI and Bluetooth are ON.

I will continue to experiment in this field but here are some findings:

  • USB-C does NOT recognize devices but is powered
  • You can power on the TB3 on demand with IOElectrify (kextload) at any point after boot
  • SSDT-TB3.aml V1 allows to use thunderbolt if the device was plugged in on boot and live unplug without crash

Further research is needed into TB3 v3.1 and TBTonPCH to see if we can activate TB on demand and USB-C

Thunderbolt BIOS assist means (as per Lenovo rep):

I confirmed with the experts:
In BIOS Assist Mode, memory resource arraignment is done by BIOS.
In Native mode, memory resource arrangement is done by OS.

There are two different firmwares - one for each mode - as they aren't compatible between the two modes. LVFS should take care of getting you the right one now as mentioned above.

3. ASPM
The best way to set the ASPM mode is through a EFI driver. But I'm not good enough in programming to write one. It can be done with setpci.efi but I don't know how to wrap the setpci into a script that can be called by OpenCore to automate the process

I think that it is worth looking into it. At the moment I'm enjoying a very long battery life (better than some Macs) with some shortcomings (no USB-C at the moment, TB3 requires reboot, have to run a script for max power savings), I hope that with your help we can overcome all of them, but some time commitment is needed.

@tylernguyen
Copy link
Owner

@velaar Thank you so much for contribution!!! It means so much to me that others are helping my project.

I'm investigating the matter on my own as we speak. Can you point to more references on ASPM and setpci.efi? I want to look deeper into that.

Also, I would suggest repasting the machine with something like Grizzly thermal to improve undervolting capabilities.

Moving forward, I will track the energy usage of my EFI release folders and include it in my repo. I also ask that you attach an EFI folder and relevant settings each time energy usage is reported. This will help coordinate settings and experiments.

I'll be back soon with further updates!

@tylernguyen
Copy link
Owner

@velaar Also, what are you using to track energy usage? A combination of iStats menu and Intel Power Gadget? I just want to be on the same page.

@tylernguyen tylernguyen pinned this issue Jan 25, 2020
@velaar
Copy link
Author

velaar commented Jan 25, 2020

@tylernguyen
I track the energy with iStat + intel power gadget, that is correct.

After running this set of settings for a week I can say that a very low power usage is real.. and it's very easy to get used to.

Unfortunately I'm quite busy this/next week but will try to upload a quick writeup of what needs to be done to achieve this level of power consumption.

@Porco-Rosso
Copy link
Contributor

On a i7-8650U, with Volta set to "power-limit" 1 W and one-key-cpufriend set to "1200/1300mhz balance Power" I get the following:
Screen Shot 2020-01-26 at 5 08 45 PM

Is it safe for me to try 400mhz on cpufriend, or is there a chance I won't be able to boot back into macOS?

@velaar
Copy link
Author

velaar commented Jan 26, 2020

@Porco-Rosso
Yes, it is safe, but no, it is verified to not work (no difference from 800MHz). I don't use Volta as it doesn't work that well on ThinkPads (EC constantly resets the voltage offsets, visible if you read MSR directly), maybe they fixed it by now. Will retest soon.

Also setting PL1 or PL2 (not sure what power-limit actually means) will kill the CPU performance (lock your CPU down to 400MHz)

@AutinMitra
Copy link

AutinMitra commented Feb 23, 2020

When I last checked, my wattage was ~7-9W browsing Chrome and using VSCode for web development, and that's without undervolting (using OC folder).

To highlight ways we can improve PM, we can maybe add a section to README.md?

@tylernguyen tylernguyen added the enhancement New feature or request label Apr 7, 2020
@tylernguyen
Copy link
Owner

@velaar Is there any updates on your instructions to maximize battery life?

@lubixxx96
Copy link

Hello.

Is that only me or VoltageShift does not work on our machine?
I get instant crash on Windows when I am trying to apply offset of -100mV or more, but in OSX I can set -200 or more and nothing. I dont even see any temperature differences.
Powerlimits are working fine.

I am using VoltageShift Undervoltage Tool v 1.21. with deamons for reapply every minute.
Any ideas?

Thanks,
Lubomir

@tylernguyen
Copy link
Owner

@lubixxx96 I haven't really tried VoltageShift myself. It was really only here b/c of reference from @velaar . In the next week, I will do some testing on it and get back to you.

@velaar
Copy link
Author

velaar commented Apr 14, 2020

@lubixxx96
It does work, however you should be aware of the EC behaviour where it resets TDP to 15W/25W as soon as you hit either ~90C or ~40W in power. That's why reapply is there.

I'm not sure what "VoltageShift Undervoltage Tool v 1.21" is. I'm using kexts and software from here: https://github.com/sicreative/VoltageShift

And I crash at about -90mV on the CPU or at about -120mV on the digital/ring side. In Windows I crash at -80mV in linux the best sustained result was -90mV (can be a calculation/rounding error)

@tylernguyen
Sorry for lack of response here. I'm also a student going through my finals at the moment, should be over by Apr. 16.

The main points about power consumption that I hope you can look into:

Powering up/powering down USB-C/Thunderbolt controller causes an interrupt storm. It might be on the CPU side or the USB controller side but the power consumption is higher by about 2W on average. There is some discussion of it here https://forums.lenovo.com/t5/Linux-Discussion/FYI-Linux-May-Not-Support-Thunderbolt-Native-Mode/td-p/4057604?page=1

USB power management - Believe can be tuned further but I don't know how exactly to do that. It seems Mac OS does not completely disable the USB ports when nothing is plugged in

APSM I'm enabling ASPM on most of the devices with a help of a script. I know that is can be done on either UEFI level or with a UEFI/Opencore driver (tested by loading an efi shell and running the UEFI versions of setpci/lspci to set the registers as follows:

./setpci -s 03:00.0 50.b=3:3
./setpci -s 02:00.0 50.b=3:3
./setpci -s 04:00.0 50.b=3:3 

Thunderbolt - I don't really expect power management to work there without Apple firmware on the controller. However if we can make a more reliable thunderbolt implementation with "Thunderbolt BIOS assist" ON we might get hotplug again as BIOS does the d device init. We just need to make it look like an External PCIe device.

Undervolting can be done on BIOS/UEFI/EC side to achieve permanent results - that is pending Skyra1n

aspm2.sh.zip

@lubixxx96
Copy link

@velaar I am using same VoltageShift v1.21 kext and app from same github repo. No matter what I set for cpu, it does not crash. Only the cache offset crash, not sure about other (system agency, analogy i/o) OC mailbox returns failed and looks like I cant change Digital I/O - still 0mv.

Thanks for the aspm2 script, I am using it as lauchdaemon.

BTW, do we have an option to manually control fan rpm?

@tylernguyen
Copy link
Owner

@lubixxx96 I do not think so, not until a BIOS release exploit is out.
@velaar Where you getting setpci and lspci binaries from? I cannot find a source to download them.

@lubixxx96
Copy link

Here you have:
setpci_lspci.zip

@velaar
Copy link
Author

velaar commented Apr 16, 2020

pciutils.zip
pciutils.efi.zip
pciutils.efi.bin.zip

@tylernguyen
I've build pciutils myself. Both for MacOS and efi.

Here is what I used to get the setpci.efi https://github.com/timotheuslin/pciutils.efi

update: I have attached my folders with binaries and toolchain. Sorry for the mess :)

@tylernguyen
Copy link
Owner

@velaar Thanks for your binaries. I do have a question though,

Which pic devices specifically are you enabling ASPM for?
And which ASPM mode are you enabling? I assume L1?

@benbender
Copy link
Contributor

Just as a quick-note: I'm working on this issue on a T480, which is very similar. Three big parts of the puzzle of power consumption are:

a) Power management of the iGPU. All your screenshots showing a max frequency of ~350mhz which means that the GuC-Firmware, and therefore power management, is missing.

b) USB-Power for internal devices (f.e. Card-Readers) which may be powered up constantly

c) MAYBE: dGPU - Whatevergreen just powers down the PCIe-port and I've disabled Optimus via ACPI instead and power consumptions seems to be improved a bit.

@tylernguyen
Copy link
Owner

Just as a quick-note: I'm working on this issue on a T480, which is very similar. Three big parts of the puzzle of power consumption are:

a) Power management of the iGPU. All your screenshots showing a max frequency of ~350mhz which means that the GuC-Firmware, and therefore power management, is missing.

b) USB-Power for internal devices (f.e. Card-Readers) which may be powered up constantly

c) MAYBE: dGPU - Whatevergreen just powers down the PCIe-port and I've disabled Optimus via ACPI instead and power consumptions seems to be improved a bit.

@benbender Thanks for letting me know.

The x1c6 does not have a dGPU so that's not an issue.
On the next repo update, I will force load Apple GuC-Firmware which should improve power consumption somewhat. However, I have been experimenting it on my machine and it really hasn't saved that much power.
I suspect that the biggest power hog is USB and Thunderbolt. But I really don't know how to begin to investigate.

@tylernguyen
Copy link
Owner

tylernguyen commented Jul 20, 2020

I saw the medium article that you posted. Then I found who wrote it, the good n4ru :D I will link you to this post at reddit about unlocking the TDP on a T480: https://www.reddit.com/r/thinkpad/comments/g8fk51/t480_consuming_60w_85w_total_unlimited_tdp/

45W TDP is insane, but it would be interesting to see if we can get sustained 3.9GHz even on high loads with something like 30W TDP or so. T480 benefits of being able to mod with dual heatpipe on the models without dGPU, which I believe gives the oportunity to the T480 to really squeeze out all the performance from the i7-8650u. I happen to have that exact model, so I will certainly give it a try soon. How are the thermals on the X1C6?

I think thermals are fairly limited on the X1C6. The machine is pretty stuck with cooling it's got. There some remedies to be done:

I've done the two things above and honestly, the machine still gets pretty warm on load. But, right now I'm trying to reduce power consumption on battery. Increasing power consumption on connected power for better performance is another issue for another day.

@tylernguyen
Copy link
Owner

tylernguyen commented Jul 20, 2020

With some advanced BIOS tweaking, I was able to get idle power consumption pretty low, pretty much identical to Linux/Windows.

Screenshot_2020-07-20 17 10 07_PNIOGL

All that's left is to experiment and play around with real world usage on battery.

@parndt
Copy link
Contributor

parndt commented Jul 20, 2020

@tylernguyen that's great news; can you please share your current BIOS settings?

@tylernguyen
Copy link
Owner

tylernguyen commented Jul 20, 2020

@parndt Sure, it is a working draft so it's subjected to experimentation and change:

  • SpeedStep mode for Battery Battery optimized

  • Adaptive Thermal Management for Battery Balanced

  • Overclocked Features enabled to allow for undervolting. My personal stable profile are as followed:

    • processor= -95
    • gt slice and unslice = -80
    • uncore = -80
  • CFG Lock disabled

  • FCLK Frequency for Early power on 400MHz

  • Disable External Graphics support all around and especially in the TB3 section if you do not need it.

  • Additionally, if you do not use TB3 hotplug at all on macOS, you should disable Force Power related options in TB3. (My example above had these enabled, so you should see improvements with them disabled). This way, you would need to plug all TB3 devices at boot when needed, but would save power since the TB3 controller does not need to be powered on all the times.

  • TPD Boot Mode Down, this is at the cost of performance. However, there is nothing preventing you from creating a custom power limit profile. In fact, I hope that someone who has more time can experiment with a custom "balanced" power limit profile and share it as I simply do not have the time myself to do so. In addition, I rarely use my x1c6 for sustained heavy computing tasks so I have no need for the Up option.

  • Under PCH-IO/USB:
    You can manually disable any USB pin you do not use. I myself disabled the ones for the SD card reader as I never use it. This feature is also pretty cool since you can hard disable webcam/mic for privacy if you're extra cautious or simply never use the laptop's webcam anyway.

  • Set DeepSX to Enabled in S3-S4-S5/Battery

A lot of these settings may be unnecessary but I am still experiment as this is only my second day with the unlocked BIOS. I will continue to edit this post as I experiment with more and different options.

@tylernguyen
Copy link
Owner

Have you played with DPTF? I've have some good results just turning it off with no other changes. It's the topic of a long thread on the Lenovo forums regarding the "throttling issue" faced by these machines.

@rjocoleman

I have not. Could you link that thread?
I'm more focused on power consumption right now. Experimenting with thermal throttling requires stress testing with Prime95 which takes time so I'm inclined to leave it for later.

@tylernguyen
Copy link
Owner

https://forums.lenovo.com/t5/Other-Linux-Discussions/X1C6-T480s-low-cTDP-and-trip-temperature-in-Linux/m-p/4028489 (around page 20 something they start into the DPTF)
https://www.reddit.com/r/thinkpad/comments/870u0a/t480s_linux_throttling_bug/
https://github.com/erpalma/throttled

I note that many of the MSRs/trip points mentioned in those various threads are configurable in these menus.

Hm... I will try playing around with those variables. @rjocoleman Do you have any experience with tweaking power limit profiles? I myself do not.

@tylernguyen
Copy link
Owner

https://adamgradzki.com/2020/04/03/thinkpad-gpu-undervolt/

According to this article, apparently you can undervolt the gpu on the x1c6 as much as -400 mV before seeing diminishing returns? That seems absurd but I guess I'll test it anyway.

@tylernguyen
Copy link
Owner

tylernguyen commented Jul 20, 2020

Also, Intel Ark https://ark.intel.com/content/www/us/en/ark/products/124968/intel-core-i7-8650u-processor-8m-cache-up-to-4-20-ghz.html says that the T junction for my i7-8650u is 100 C. So I am certain the default throttling/tripping points can be pushed. I'm just not sure what's the safe point for us to configure is at.

In any sense, it is probably not a good idea to remove thermal limits without liquid metal or at least a good after market paste applied.

@benbender
Copy link
Contributor

benbender commented Jul 21, 2020

@tylernguyen wow :)

a) Would you be so kind to provide an AppleIntelInfo.kext-dump from Hackintool (SIP must be disabled) to see in which configuration the processor reached that state? (Hackintool -> Utilities -> Get Appleinfo, the most left icon on the bottom - as noted, SIP must be deactivated to load AppleIntelInfo.kext)

Additional question: do you reach that low power-state reliable?

From my understanding atm its mostly about cpu-cores C-States reaching down to C-10 while the machine is running. It would be very helpful to pin the config needed for this.

(Edit) Reference:

b) I'm experimenting with S0-DeepIdle. With the new options, it can be activated and I'm trying to find the right combination to make it useable. ATM S0-Deepidle works, but screws S3 sleep in terms of usability... More Infos here: https://github.com/daliansky/OC-little/tree/master/01-%E5%85%B3%E4%BA%8EAOAC (You can confirm the principle ability to use S0-DeepIdle in the FACP-Table of ACPI via MacIASL)

@tylernguyen
Copy link
Owner

tylernguyen commented Jul 21, 2020

@benbender
Here's the AppleIntelInfo dump
appleintelinfo.txt

Yup, the power state is very stable. I've been using it the same way I've always been for a day now. The system boosts normally during tasks and otherwise idle below 1. And as far as I can tell, sleep is working normally.

  • I have not been able to get S0-Deepdle working. It seems there's a bug in the BIOS mod that will not allow me to save settings for S0-Deepidle, it would just reset on boot.

@benbender
Copy link
Contributor

benbender commented Jul 22, 2020

The Bios a bit flaky in general when it comes to saving different values. F.e. I'm having I2C2-I2C5-devices activated since yesterday and I'm not able to deactivate them.

From your AppleIntelInfo:

MSR_CONFIG_TDP_NOMINAL...........(0x648) : 0x13
MSR_CONFIG_TDP_LEVEL1............(0x649) : 0x80050
MSR_CONFIG_TDP_LEVEL2............(0x64a) : 0x1500C8
MSR_CONFIG_TDP_CONTROL...........(0x64b) : 0x1
MSR_TURBO_ACTIVATION_RATIO.......(0x64c) : 0x0
MSR_PKGC3_IRTL...................(0x60a) : 0x884E
MSR_PKGC6_IRTL...................(0x60b) : 0x8876
MSR_PKGC7_IRTL...................(0x60c) : 0x8894
MSR_PKG_C2_RESIDENCY.............(0x60d) : 0x28AF432DF
MSR_PKG_C3_RESIDENCY.............(0x3f8) : 0x4265AB643
MSR_PKG_C2_RESIDENCY.............(0x60d) : 0x28AF432DF
MSR_PKG_C3_RESIDENCY.............(0x3f8) : 0x4265AB643
MSR_PKG_C6_RESIDENCY.............(0x3f9) : 0x12223FD85
MSR_PKG_C7_RESIDENCY.............(0x3fa) : 0x13AF739
MSR_PKG_C8_RESIDENCY.............(0x630) : 0xB94B4DEF
MSR_PKG_C9_RESIDENCY.............(0x631) : 0x0
MSR_PKG_C10_RESIDENCY............(0x632) : 0x0
MSR_PKG_C8_LATENCY...............(0x633) : 0xB94B4DEF
MSR_PKG_C9_LATENCY...............(0x634) : 0x0
MSR_PKG_C10_LATENCY..............(0x635) : 0x0

vs. mine:

MSR_CONFIG_TDP_NOMINAL...........(0x648) : 0x13
MSR_CONFIG_TDP_LEVEL1............(0x649) : 0x80050
MSR_CONFIG_TDP_LEVEL2............(0x64a) : 0x1500C8
MSR_CONFIG_TDP_CONTROL...........(0x64b) : 0x80000000
MSR_TURBO_ACTIVATION_RATIO.......(0x64c) : 0x80000012
MSR_PKGC3_IRTL...................(0x60a) : 0x884E
MSR_PKGC6_IRTL...................(0x60b) : 0x8876
MSR_PKGC7_IRTL...................(0x60c) : 0x8894
MSR_PKG_C2_RESIDENCY.............(0x60d) : 0x577C77DA715
MSR_PKG_C3_RESIDENCY.............(0x3f8) : 0x2A45585FA05
MSR_PKG_C2_RESIDENCY.............(0x60d) : 0x577C77DA715
MSR_PKG_C3_RESIDENCY.............(0x3f8) : 0x2A45585FA05
MSR_PKG_C6_RESIDENCY.............(0x3f9) : 0x0
MSR_PKG_C7_RESIDENCY.............(0x3fa) : 0x0
MSR_PKG_C8_RESIDENCY.............(0x630) : 0x0
MSR_PKG_C9_RESIDENCY.............(0x631) : 0x0
MSR_PKG_C10_RESIDENCY............(0x632) : 0x0
MSR_PKG_C8_LATENCY...............(0x633) : 0x0
MSR_PKG_C9_LATENCY...............(0x634) : 0x0
MSR_PKG_C10_LATENCY..............(0x635) : 0x0

I don't know how to achive that config reliably. That's the key to get the CPU to power down in S0 while running. Do you use the CPUFriendProvider-config from this repo atm?

PS: would you be able to dump your bios so that I could flash it and compare the settings? I'm particular interested if it's only the bios or something more.

@tylernguyen
Copy link
Owner

@benbender Yup, I'm using the CPUFriendDataProvider from my repo currently.
I'm not too comfortable with sharing my BIOS dump publicly since it contains my machine's serial information. All the settings I've made are all documented above. But I'll send it to you personally if you contact me via Signal or email. And as far as I can tell, the biggest change in power is disabling CFG Lock and setting TDP config to Down

@benbender
Copy link
Contributor

benbender commented Jul 22, 2020

The problem is that we don't have a good baseline because "Loading defaults" doesn't reset everything in the bios. F.e. my I2C-Devices are there after a reset... ^^ And I'm using your settings afaik. There is surely something more to be done. I'll contact you at contact at tylerspaper dot com.

Edit: msg sent.

@benbender
Copy link
Contributor

benbender commented Jul 25, 2020

I'm now also able to push my pkg-usage below 1W. From my observations

  • CFG Lock disabled

needs to be manually checked with verifyMSR-efi-tool.

  • FCLK Frequency for Early power on 400MHz

Doesn't have an impact for me.

  • Disable External Graphics support all around and especially in the TB3 section if you do not need it.

I can't switch my primary gfx from SG (switchable GFX) to iGPU, but I can manually configure PCIE and disable Port 1, which is my Nvidia-Card. Huge impage, it seems.

  • Additionally, if you do not use TB3 hotplug at all on macOS, you should disable Force Power related options in TB3. (My example above had these enabled, so you should see improvements with them disabled). This way, you would need to plug all TB3 devices at boot when needed, but would save power since the TB3 controller does not need to be powered on all the times.

+1

  • TPD Boot Mode Down, this is at the cost of performance. However, there is nothing preventing you from creating a custom power limit profile. In fact, I hope that someone who has more time can experiment with a custom "balanced" power limit profile and share it as I simply do not have the time myself to do so. In addition, I rarely use my x1c6 for sustained heavy computing tasks so I have no need for the Up option.

Doesn't have an impact for me.

  • Under PCH-IO/USB:
    You can manually disable any USB pin you do not use. I myself disabled the ones for the SD card reader as I never use it. This feature is also pretty cool since you can hard disable webcam/mic for privacy if you're extra cautious or simply never use the laptop's webcam anyway.

+1

  • Set DeepSX to Enabled in S3-S4-S5/Battery

Doesn't have an impact for me.
DeepSX isn't used on OSX afaik.

EDIT: Power-usage atm at typical usage (with enabled usb, usb3.1-ctlr, webcam, ethernet, bt, wifi) with browsing, spotify, vscode, chat, etc:
power-usage

@tylernguyen
Copy link
Owner

I'm now also able to push my pkg-usage below 1W. From my observations

  • CFG Lock disabled

needs to be manually checked with verifyMSR-efi-tool.

Hm.. so I guess there might be a bug where settings are not applied? Have you tried the reset method @velaar posted?

@benbender
Copy link
Contributor

Hm.. so I guess there might be a bug where settings are not applied? Have you tried the reset method @velaar posted?

Yes, and its hard to tell, if it worked. I can't get reliable results from my testing in general. Sometimes settings are not applied and then, out of nowhere, they are. For CFG Lock it was set, but VerifyMSR reported "MSR Locked" until it doesnt after some testing - no clue why... At this point I can only advise to try to double check...

I'm on vacation next week and will try a clean patch afterward to try to sort the stability issues.

@tylernguyen
Copy link
Owner

tylernguyen commented Jul 27, 2020

@benbender

I found that the biggest power difference is enabling Thunderbolt BIOS assist and enabling support in pre boot.

Please test those. When I have disabled, I'm experiencing about 2W while with them enabled, I'm able to get sub 1W.

If you could confirm that, I think I'm ready to post a big final comment about everything we've found and then close this issue as I'm very satisfied with cpu power consumption right now, it's just as good as Linux and Windows for me.

@1Revenger1
Copy link

1Revenger1 commented Jul 28, 2020

If your wanting to look at iGPU power states, interrupts a second from various sources, and CPU usage, then you could try using sudo powermetrics --show-process-energy and see if you can find anything making a lot of interrupts.

I've been looking through here for PM tips for my x1 - what is this thunderbolt bios assist?

@tylernguyen
Copy link
Owner

@1Revenger1
Posted on Lenovo's forum:

  • In BIOS Assist Mode, memory resource arraignment is done by BIOS.
  • In Native mode, memory resource arrangement is done by OS.
    And just as @Veelar said:
    In this generation of machine, Thunderbolt controller causes a C-storn on our laptops ramping the CPU package to 2.2-2.5W
    If you disable it (or put into BIOS-assisted mode), the C-storm ends and the CPU properly clocks down to where it is supposed to be allowing us to reach a way better power state.

https://forums.lenovo.com/t5/Linux-Discussion/FYI-Linux-May-Not-Support-Thunderbolt-Native-Mode/td-p/4057604?page=1

@velaar
Copy link
Author

velaar commented Jul 28, 2020

@tylernguyen my speculation is that in BIOS assist mode the power management is also done by BIOS. (including USB-C/TB link power management). I can not confirm it but with proper Linux/Windows driver it is possible to achieve similar levels of power consumption.

I wonder if the recent BIOS hacks will allow us to use OSX PM for TBT / USB-C

@thalatamsainath
Copy link

@velaar there is a detailed guide on getting macOS PM for TBT. Here : https://osy.gitbook.io/hac-mini-guide/details/thunderbolt-3-fix-part-3

Either ways I will be trying the different BIOS options as suggested by Tyler. I use setup_var to change my bios settings as I don't have a fully modded bios chip. But I have been enable to setup all bios options via setup_var method. FYI I'm using Zenbook S UX391UA very similar specs to the laptop in discussion.

@velaar
Copy link
Author

velaar commented Jul 28, 2020

@FlasHRender
I'm well aware of this fix, however I have a concern about using the updated TBT FW with Windows. As I depend on eGPU for my home office setup where both Windows and MacOS X are needed.

I will say though that at least hot plug with BIOS assist → on; should be a big improvement for my use case.
But we digress, this is a discussion for TBT thread.

@tylernguyen
Copy link
Owner

A year and half after this issue was opened by @velaar, I feel that I am now ready to close this issue as I consider it solved. Here are my closing comments:

  • The biggest culprit of idle power draw is the Thunderbolt 3 controller. With Thunderbolt BIOS Assist disabled, idle CPU power consumption is at ~2W as opposed to ~0.8W with the option enabled, a huge difference in real world usage. This is true for both Windows and macOS.
  • However, this is especially troublesome for macOS/x1c6-hackintosh because:
    • As of right now, my TB3 hotplug patch will not work with Thunderbolt BIOS Assist enabled. This means that those who want TB3 hotplug capabilities will have to sacrifice battery time, and a decent amount of it too.
    • Furthermore, current hackintosh software fixies for Thunderbolt 3 hotplug requires that the the TB3 controller power be forced on at boot. This means that the controller is always powered, even when you do not need it.
    • Hence, you will have to choose between TB3 hotplug and power consumption for the time being on hackintosh. I personally have chosen battery time. I use TB3 quite often but am content with shutting down the machine each to plug in TB3 devices (a fast boot drive helps).

With that said, however, there are other things that can be done to improve CPU power consumption:

  • First things first, you should disable all peripherals you do not need at the BIOS level, things such as: always on USB, fingerprint reader, wwan slot, camera, and microphone.
  • Next, there are a few things that should be done by all to optimize CPU power draw on macOS, all of which requires tampering with the machine physically:
    • Repaste the machine with an aftermarket thermal paste to improve temps.
    • Mod the BIOS to unlock Intel Advance Menu.
    • Disable CFG Lock to allow for native power management.
    • Undervolt the machine using the Overclocking Menu within the modded BIOS.
    • Configure TDP to Down (comes at the cost of sustained performance).

Personally, with all those adjustments made and with Thunderbolt BIOS Assist enabled, my machine idles at ~0.8W, which is identical to Windows and is good enough for a day's worth on medium brightness (by which my 1440p screen is the real power hog).

All of this can be viewed in more details starting the next commit and will be continually updated in my docs/, specifically 1_README-HARDWAREandBIOS.md and 5_README-other.md.

My next hope is that we can tackle the big boss, Thunderbolt 3 hotplug. Right now, it works perfectly but as previously mentioned, comes at a cost of the CPU idle power draw being ~2W. I want to be able to have Thunderbolt 3 hotplug and low idle power draw too, damn it! See Issue #24 for further discussions on this topic.

Finally, thank you to everyone here, your interest is why I keep this project actively maintained.

@Porco-Rosso
Copy link
Contributor

Hi @tylernguyen just a quick question, it might seem obvious. If we enable Thunderbolt BIOS Assist, this would also mean that to use TB3 on windows it would need to be plugged in at boot to work?
I hardly use the GPU on MacOS but would definitely need it on windows for some light gaming.

Lastly it would be great to have some documentation on how to patch the BIOS. I haven't dived into it yet, but would appreciate a starting point, and recommended settings.

@tylernguyen
Copy link
Owner

@Porco-Rosso

Windows works fine with Thunderbolt BIOS assist enabled, only macOS is affected by this. Also, BIOS documentation will be included on the next repo commit. I'm waiting for a few final things before pushing it. Though I think it will be up in a less than one week.

@tylernguyen tylernguyen unpinned this issue Aug 3, 2020
@abbasabidi85
Copy link

If your wanting to look at iGPU power states, interrupts a second from various sources, and CPU usage, then you could try using sudo powermetrics --show-process-energy and see if you can find anything making a lot of interrupts.

I've been looking through here for PM tips for my x1 - what is this thunderbolt bios assist?

I know this is a different Hackintosh forum but I am having the same issues with Comet Lake i7-10610u CPU (Dell Latitude 7410) and these are the interrupts, if anyone can help what is causing them or how to solve them would be helpful. I know HDEF is related to sound I2C is related to Trackpad? and CNVW is wifi, XHC is USB but idk what is TMR. iStat shows 9.5 Watt CPU consumption on idle.

****  Interrupt distribution ****

CPU 0:
	Vector 0x51(I2C1/DSB1/HDEF): 1888.65 interrupts/sec
	Vector 0x70(XHC): 41.90 interrupts/sec
	Vector 0x72(PXSX): 217.28 interrupts/sec
	Vector 0x77(CNVW): 21.95 interrupts/sec
	Vector 0x7a(IGPU): 7.78 interrupts/sec
	Vector 0xdd(TMR): 201.51 interrupts/sec
	Vector 0xde(IPI): 40.10 interrupts/sec
CPU 1:
	Vector 0xde(IPI): 6.58 interrupts/sec
CPU 2:
	Vector 0xdd(TMR): 22.15 interrupts/sec
	Vector 0xde(IPI): 34.92 interrupts/sec
CPU 3:
	Vector 0xde(IPI): 11.57 interrupts/sec
CPU 4:
	Vector 0xdd(TMR): 7.58 interrupts/sec
	Vector 0xde(IPI): 33.32 interrupts/sec
CPU 5:
	Vector 0xde(IPI): 8.98 interrupts/sec
CPU 6:
	Vector 0xdd(TMR): 5.59 interrupts/sec
	Vector 0xde(IPI): 24.14 interrupts/sec
CPU 7:
	Vector 0xdd(TMR): 1.40 interrupts/sec
	Vector 0xde(IPI): 4.59 interrupts/sec

@Mifaxav
Copy link

Mifaxav commented Jan 24, 2025

Hey, im on an X1 yoga gen 3, very close hardware to your machine. How can I decrease the power usage? On idle, power consumption is 8 watts total but the CPU is at 0.2 watts. PKG is at 1.5 - 1.8, dram at 0.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests