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

Fix for Hibernation (hibernatemode 25) on IceLake Surface devices #133

Closed
jlempen opened this issue Jul 25, 2024 · 9 comments
Closed

Fix for Hibernation (hibernatemode 25) on IceLake Surface devices #133

jlempen opened this issue Jul 25, 2024 · 9 comments

Comments

@jlempen
Copy link
Contributor

jlempen commented Jul 25, 2024

Source: Surface-IceLake-macOS-Hibernation-Fix

Surface-IceLake-macOS-Hibernation-Fix

After many hours of tinkering, I finally found a way to fix ACPI S4 Hibernation (hibernatemode 25) on the i5 Surface Pro 7 on macOS 13.6.7 Ventura, 15-Inch i7 Surface Laptop 3 on macOS 14.5 Sonoma, i5 Surface Laptop Go 1 on macOS 13.6.7 Ventura and very likely on the Surface Book 3 (untested) as well. ACPI S3 Sleep (hibernatemode 0) is still broken, though, but perhaps the Hibernation fix will lead the way to a full S3 Sleep fix at some point in the future.

The key to the fix is to enable ACPI S3 Sleep in the DSDT. This is actually very easy and I'm stunned nobody tried this before. Searching for _S3 in the DSDT.aml file leads us to this:

    If (SS3)
    {
        Name (_S3, Package (0x04)  // _S3_: S3 System State
        {
            0x05, 
            Zero, 
            Zero, 
            Zero
        })
    }

So to enable _S3, SS3 needs to return One. Now searching for SS3 leads us to this:

    Name (SS1, Zero)
    Name (SS2, Zero)
    Name (SS3, Zero)
    Name (SS4, One)

Enable ACPI S3 Sleep

Change Name (SS3, Zero) to Name (SS3, One) to enable ACPI S3 Sleep with the following ACPI patch in ACPI -> Patch:

Comment: Rename Name (SS3, Zero) to One - Enable S3 Sleep
Find: 5353335F00
Replace: 5353335F01

Before the rename, the system log shows:

(AppleACPIPlatform) ACPI: sleep states S4 S5

After the rename, the system log shows:

(AppleACPIPlatform) ACPI: sleep states S3 S4 S5

and commands such as pmset -g log or pmset -g log | grep -e "Sleep.*due to" -e "Wake.*due to" now clearly show that the device is entering sleep and (eventually) waking up from sleep.

Add Reserved Memory region

This fix was found in Tyler Nguyen's x1c6-hackintosh repo. Thank you @benbender @1Revenger1 @savvamitrofanov and @vit9696!

Get rid of the black screen on Wake with the following Reserved Memory region in NVRAM -> ReservedMemory:

Comment: Fix hibernate mode 25 black screen on wake
Address: 569344
Size: 4096
Type: RuntimeCode
Enabled: true

Enable DiscardHibernateMap

This doesn't seem to be required on every Surface device, but at least on the Surface Laptop 3, it fixes a kernel panic on Wake.

Enable the following Booter Quirk in Booter -> Quirks:

DiscardHibernateMap=true

Set HibernateMode to NVRAM

In Misc -> Boot, set HibernateMode to NVRAM:

HibernateMode=NVRAM

I would also recommend enabling HibernateSkipsPicker in Misc -> Boot:

HibernateSkipsPicker=true

Add the GPRW instant wake patch

At least on the Surface Pro 7 and the Surface Laptop Go 1, the GPRW instant wake patch is required as well.

Add SSDT-GPRW.aml to the ACPI folder of your EFI. Then add SSDT-GPRW.aml to ACPI -> Add and the following ACPI patch to ACPI -> Patch in the config.plist file:

Comment: Change Method(GPRW,2,N) to XPRW, pair with SSDT-GPRW.aml
Find: 4750525702
Replace: 5850525702

Enable hibernatemode 25 in macOS

Open the Terminal and enter the following commands, then reboot for the changes to take effect:

sudo pmset restoredefaults
sudo pmset -a hibernatemode 25

If for whatever reason Hibernate is still not working on your system, you should reset the Power Management settings and rebuild the sleepimage file. To do so, open the Terminal and enter the following commands, then reboot for the changes to take effect:

sudo rm /Library/Preferences/com.apple.PowerManagement*
sudo rm /var/vm/sleepimage
sudo pmset hibernatefile /var/vm/sleepimage

Once you are back in macOS, disable Sleep and enable Hibernate again, then reboot:

sudo pmset restoredefaults
sudo pmset -a hibernatemode 25

Fix broken Bluetooth on Wake from Hibernation

After the device wakes up from Hibernation, Bluetooth may be broken / unable to connect.

A very simple fix for this issue is to download and install Bluesnooze. Launch the app, enable Launch at login and you're done!

A few comments / Help needed!

Hibernation seems to be working perfectly on my i5 / 8GB / 256GB Surface Pro 7 and i5 / 8GB / 256GB Surface Laptop Go 1 both running on macOS Ventura 13.6.7 with the SMBIOS MacBookAir9,1 and using Xiashangning's BigSurface.kext v6.5. Everything comes back online after waking up from hibernation.

However, my i7 / 16GB / 2TB WD SN770M 15-Inch Surface Laptop 3 running macOS Sonoma 14.5 with the SMBIOS MacBookPro16,2 and with Xiashangning's BigSurface.kext v6.2 wakes up with a dead trackpad. I have yet to find a way to fix the dead trackpad.

The main difference between the Surface Pro 7 or Surface Laptop Go 1 and the Surface Laptop 3 or Surface Book 3 is that on the former, the keyboard and trackpad are attached through USB, whereas on the latter, they are attached through a proprietary interface.

Both the Surface Laptop 3 and the Surface Book 3 are plagued by a nasty issue with the trackpad on macOS. Fixing the issue is possible, but requires downgrading the firmware to 13.101.140.0 and BigSurface.kext to 6.2, that's why it still runs with BigSurface.kext v6.2.
The trackpad works with the latest BigSurface.kext v6.5, though, but the trackpad lags and skips every few seconds. Furthermore, tests show that the BigSurface.kext v6.5 doesn't fix the dead trackpad after wake from hibernation.

Playing around trying to unload the BigSurface.kext or VoodooSerial.kext plug-in before hibernate and reloading it on wake from hibernate has been a dead end until now, as I'm unable to do so due to various errors with the kextstat, kextunload and kextload commands in macOS.

So, the first steps to troubleshoot the trackpad issue would be to downgrade macOS to 13.6.7 Ventura and change the SMBIOS back to MacBookAir9,1, but I must admit I'm not all too confident that would fix the dead trackpad after wake from hibernation. We would probably need to find someone who is able to fix the BigSurface.kext and I'm not sure Xiashangning is still maintaining his BigSurface repo, as there hasn't been any activity for over a year now, since July 14th 2023.

@jamieernest
Copy link

Just tried this overnight sleeping, when I woke up the laptop only had 1% battery left, I think sudo pmset -a tcpkeepalive 0 also has to be done, I'll give it a try again when my laptop is back to full battery

@jlempen
Copy link
Contributor Author

jlempen commented Jul 27, 2024

@jamieernest In hibernate mode, the device is basically totally powered off, so it shouldn't use any battery power at all. And things like tcpkeealive and powernap won't power on the laptop during hibernation.

My first guess would be that you didn't restart your Surface Pro 7 after setting sudo pmset -a hibernatemode 25, so it's still only turning off the display and idling, that would explain the battery drain.

Waking up from hibernation is different from waking up from sleep: you have to press the power button on the device, then you'll see the Surface logo with the red padlock on top for a second, then the display will be black for a few seconds until you see the lock screen. If you haven't set HibernateSkipsPicker=true in Misc -> Boot, you'll even see the OpenCore picker when you wake up from hibernation.

@jamieernest
Copy link

@jlempen hmm I'm not sure why it sleeps and wakes properly but it still drains battery... any more tips? I've tried everything in your last post, any commands I can run to determine the issue?

@jlempen
Copy link
Contributor Author

jlempen commented Jul 27, 2024

I have the impression that S3 Sleep is still not enabled on your SP7. Please check your system log:
log show --last boot | grep "sleep states" should return

(AppleACPIPlatform) ACPI: sleep states S3 S4 S5

If it returns

(AppleACPIPlatform) ACPI: sleep states S4 S5

that means there's something wrong with your SS3 renaming patch.

@jamieernest
Copy link

Hmm yes there seems to be an issue with my patch, can you check my work?

image

@jlempen
Copy link
Contributor Author

jlempen commented Jul 27, 2024

Leave TableSignature empty or replace your 46414350 ("FACP" in hex) with 44534454 ("DSDT" in hex). You probably copied the Rename PM Profile patch which applies only to the FACP table :-)
Then reboot and check your system log again, but I'm quite confident that Hibernate should work now :-)

@jamieernest
Copy link

Nice, it seems to be working now, let me try sleeping it overnight :)

@jamieernest
Copy link

Cool, it works! Thank you so much for your help! I might submit a PR for this sleep patch so people don't have to do it manually 👍

@badstorm
Copy link
Owner

Release build 1901

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

3 participants