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

Native Power Management #44

Closed
mr-prez opened this issue Oct 14, 2020 · 13 comments
Closed

Native Power Management #44

mr-prez opened this issue Oct 14, 2020 · 13 comments

Comments

@mr-prez
Copy link

mr-prez commented Oct 14, 2020

This is more of a recommendation and solution than an actual issue. I (and others from various threads) had the issue where during certain tasks, the CPU would power throttle down to 800Mhz even though temperatures were fine. It seemed to be tied to heavy IO tasks. I believe the solution to be letting MacOS natively manage power by disabling CFG lock.

CFG lock determines if the bios lets the OS directly control power management. Without it we can't boot unless we use AppleCpuPmCfgLock and/or AppleXcpmCfgLock in OpenCore. This is actually a standard procedure mentioned in the OpenCore guide, but I stumbled upon it by searching GitHub for others hacking the 9750. I credit smallssnow for actually doing this with the 9750 and dreamwhite for providing a more general dell specific guide.

Long story short, we use modGRUBShell.efi to disable the 0x5BD offset which controls CFG Lock. Then remove AppleCpuPmCfgLock and AppleXcpmCfgLock since we no longer need them. We can also use it to enable overclocking, disable DPTF (Dynamic Platform and Thermal Framework) etc. The latter was already disabled on mine so I only modified CFG lock.

I only did this yesterday, but I've since noticed better (quieter) fan control and haven't had the power throttling I did before. I also notice the processor scale between many more different clock speeds than before.

In short, even if one doesn't particularly have the 800Mhz issue I did, it's probably a good idea to allow MacOS to natively control power management vs. emulate it.

@Fyobl
Copy link

Fyobl commented Oct 14, 2020

Is there any risk of bios damage when doing this?

@mr-prez
Copy link
Author

mr-prez commented Oct 14, 2020

Aside from the normal stuff like making sure to do it while your laptop is charged and verifying the command you're typing, not really. We aren't adding or removing functionality that hasn't already been coded into the BIOS. All this does is switch the variable set at 0x5BD from "true" (0x01) to "false" (0x00), allowing an OS to directly control the processors C-States (CPU power modes) so we don't have to use OpenCore patches to emulate this. Some professional workstations/laptops will have this toggle directly in the BIOS GUI itself but not so much at the prosumer level.

Also, keep in mind that this is an issue that's accounted for directly in the OpenCore Install Guide itself. This is a well beaten path; there's just slightly different procedures based on the motherboard manufacturer.

If you're still unsure, you can even follow dreamwhite's guide I linked above and de-compile our bios firmware yourself to verify firsthand that the 0x5BD register is correct. It only takes about 5-10 minutes but smallssnow already did the "heavy" lifting on that part. That register is going to be the same for every 9570.

@Fyobl
Copy link

Fyobl commented Oct 14, 2020

Brilliant I will have a look at doing this tonight and see if it makes any difference on my 9570.

@frbuccoliero
Copy link
Contributor

Seems interesting. @mr-prez could you make a short step-guide here in the thread so we can link it in the main readme? Please also provide a link to all the material needed.

@Fyobl
Copy link

Fyobl commented Oct 14, 2020

Done.

There is an extra step us (9570) users need to check in BIOS so we can run modGRUBShell.efi.

Enabling "Allow legacy EFI ROMs" in BIOS.

When I didn't have this enabled I got a black screen with "-" in top left corner of screen when trying to boot system.

But the steps to do this are pretty simple, I will keep my eyes on how its proforming over the next few days.

@mr-prez
Copy link
Author

mr-prez commented Oct 14, 2020

@frbuccoliero Sure, I'll do that below.
@Fyobl yeah, I had to do a bit of searching to figure that out haha.

Native Power Management / Disabling CFG Lock - XPS 9570

To begin we'll need a few tools:

1 - We need to create a Tools folder in the OC directory of our EFI and copy those two .efi files there.

2- Restart and boot into BIOS. Go to the "Advanced Boot Options" section and select the "Enable Legacy Option Roms" box. Without this, we cannot boot modGrubShell.

3- Next, add boot entries for modGrubShell and VerifyMsrE2 in the 'Boot Sequence' entry of our BIOS. Click "Add Boot Option", name each entry, and select the EFI file you're creating an entry for. You will need to make one entry for each efi file. Save the settings. And note that you'll need to spam the F12 button at restart to bring up the boot option selector.

3A - Alternatively, we can use ProperTree to add these efi files to our OC boot menu using the snapshot function. However, first option may be preferable since this will only need to be done once (or every time you update your BIOS) and it may be overkill to add this boot entry to OC only to remove them later. But either way will work as long as you Enable Legacy Option Roms in BIOS. Keep in mind that ProperTree will require homebrew, python and other prerequisites to use.

4 - Boot VerifyMsrE2.efi. It should tell us that CFG Lock is enabled. After a few seconds, it will automatically exit.

5 - Next, boot into modGrubShell. We can verify again that CFG Lock is enabled by running the command:

setup_var 0x5BD

The shell should return the value 0x01, denoting that CFG Lock is, in fact, enabled. We can simply correct this value with the following command:

setup_var 0x5BD 0x00

6 - Exit modgub shell (i think you can just type exit) and power the computer off. Simply restarting will not work.

7 - Turn the laptop back on and boot VerifyMsrE2.efi. It should show that CFG Lock is disabled. Afterwards we can boot into MacOS normally.

We now need to remove the AppleCpuPmCfgLock and AppleXcpmCfgLock patches from our config.plist. This can be achieved with ProperTree or PlistEdit Pro.

8 - Use either program to navigate to the following section: Root > Kernel > Quirks. Set AppleCpuPmCfgLock and AppleXcpmCfgLock to No for PlistEdit Pro or False for ProperTree. Save the config and power cycle your laptop. You've now completed the process!

Additional Note: If you update your BIOS, you will need to disable CFG Lock again.

Optional

  • If you would like an additional verification that MacOS reports that CFG lock is disabled, use hackintool. Run the app, select the utilities tab at the top, then select the processor looking icon at the bottom left called "Get AppleIntelInfo" Scroll down to the MSR_PMG_CST_CONFIG_CONTROL section. We should see the following:

- CFG Lock............................. : 0 (MSR not locked)

  • If you would like to decompile the BIOS firmware yourself and verify the registers firsthand, follow this guide by dreamwhite.

  • Here is a table of additional values you can edit, if you wish. Do your own research as to what exactly these do and proceed at your own risk.

name address write value Remarks
CFG-LOCK 0x5BD 0x00(unlock)/0x01(lock) Unlock E2 Register
Overclocking Lock 0x659 0x00(unlock)/0x01(lock) Overclocking Lock
PL1 enable 0x5AB 0x00(disable)/0x01(enable) PL1 Power Wall
PL2 Enable 0x5B1 0x00(disable)/0x01(enable) PL2 Power Wall
DVMT Pre-Allocated 0x8E6 0x00(0m)/0x01(32m)/0x02(64m) 0x03(undefined) Please note that there is no 96m
TDP Lock 0x5BF 0x00(disable)/0x01(enable) TDP thermal design power wall
DPTF 0x39E 0x00(disable)/0x01(enable) CPU cooling dynamic adjustment
source Smallssnow

@frbuccoliero
Copy link
Contributor

Perfect, i'm including this in the readme in a pull request. About the config stuff, idk, there's a little mess about that. FHD/4K , 1820A/Not1820A , including also this would result in a little mess @jaromeyer don't you think so?
Maybe a quick python tool to easily switch between configs would be nice, i saw that in few other repos. Unfortunately for freetime reasons i can't really put much effort on it. If someone is able, it can be a great thing.

@mr-prez
Copy link
Author

mr-prez commented Oct 14, 2020

@frbuccoliero Honestly, manually adding the boot option in the BIOS is probably the easiest option. This is something that will only need to be done once (or any time the BIOS is updated) so it may be too much to have a dedicated config for it.

However I wouldn't mind looking into that python tool you mentioned. Do you have any more information on what it's called? I couldn't find anything with a cursory google search.

@frbuccoliero
Copy link
Contributor

frbuccoliero commented Oct 15, 2020 via email

@Fyobl
Copy link

Fyobl commented Oct 20, 2020

So far so good. Noticed a slight difference in performance and fans don’t come on randomly now.

@jaromeyer
Copy link
Owner

jaromeyer commented Oct 21, 2020

Thank you very much for the extensive guide @mr-prez. Personally I have never had any problems with PM and throttling, but good to know that there is a solution for people who experience it. I think we can close this issue now.

@Fyobl
Copy link

Fyobl commented Oct 21, 2020

@jaromeyer all credit goes to @mr-prez i just tested it on my system :)

@jaromeyer
Copy link
Owner

@jaromeyer all credit goes to @mr-prez i just tested it on my system :)

Whoops wrong tag🙈

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

No branches or pull requests

4 participants