jaromeyer / XPS9570-Catalina

macOS Big Sur for the Dell XPS 15 9570 using the OpenCore bootloader.
195 stars 22 forks source link

Native Power Management #44

Closed mr-prez closed 4 years ago

mr-prez commented 4 years ago

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 commented 4 years ago

Is there any risk of bios damage when doing this?

mr-prez commented 4 years ago

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 commented 4 years ago

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

frbuccoliero commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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

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

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

Yeah, about the config thing i said the same thing. About the python script, i don’t remember exactly what repository did have it. I’ll try to make a quick search later

Francesco Buccoliero Software Developer Engineering Student @ PoliMi     @frbuccoliero On 15 Oct 2020, 00:19 +0200, mr-prez notifications@github.com, wrote:

@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. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Fyobl commented 4 years ago

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

jaromeyer commented 4 years ago

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 commented 4 years ago

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

jaromeyer commented 4 years ago

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

Whoops wrong tag🙈