Correcting Sleep Problems

Are you experiencing a condition where you tell your computer to sleep, and it starts to do as instructed but then laughs in your face? Well, you are not alone! That's a condition that most of us face, but we can fix it! There are a few things that can cause this problem, some of which we've corrected before ever reaching this section (How about that!). Let's talk about each one.

USB Port Mapping

That's right..if you're using USBInjectAll in its default configuration, or you have no USB port injection at all, it could cause this condition. That isn't a problem for you though because we've already fixed it.

Disabling Hibernation

Hibernation isn't well supported on hackintoshes, and in some cases it doesn't work at all. We can mitigate this problem by configuring macOS to use standby mode which will preserve what's in memory on sleep but will not write it out to disk and power off the machine. This may help to lenghten your SSD's lifespan but at the cost of losing all your work if the laptop was in sleep mode and power ran out or when the power is so low macOS will just shutdown and not enter hibernation mode.

sudo pmset hibernatemode 0
sudo pmset standby 0
sudo pmset autopoweroff 0

Finding Wake Reasons for Correction

Before talking about the remaining items that cause wakeups, we need to talk about how to tell what's waking your system up. There are a couple of very common reasons and the correction is similar for all of them. To find out what's waking your system, put it to sleep. Do it right now. Alright, it's probably already woken up so let's take a look at the log.

pmset -g log | grep -e "Wake.*due to "

Yep, that's a ton of data. You're looking for a couple of specific things though and they should be pretty close to the bottom of the log.

Wake on GLAN

If you see an entry in the log that looks similar to this one, you'll need to disable Wake on Lan in your BIOS. If that doesn't work, a patch is necessary.

Wake [CDNVA] due to GLAN: Using AC

Wake on HDEF

This message looks similar to the GLAN log entry. If you see it, you definitely need a patch.

Wake [CDNVA] due to HDEF: Using AC

Wake on XHCI

This message is one of the most common that you may come across. It also looks similar to the other messages in the log. If you see it, you need a patch.

Wake [CDNVA] due to XHC: Using AC

RTC/Maintenance Wakes

Maintenance wakes are normal behavior, and are related to PowerNap. When PowerNap is enabled your computer will wake up to check email, initiate Time Machine backups, and sync with iCloud. Those wakes look similar to the following.

DarkWake from Normal Sleep [CDNPB] : due to RTC/Maintenance Using AC

If these wakes are not desired, disable PowerNap.

Wake on RTC Alarm

RTC Alarm wakes are generated by applications that use enhanced notifications that are left running while the system is asleep. Examples of applications that cause this wake type would be Messages, or Facebook. Those wakes may look like this.

Wake reason: RTC (Alarm)

If these wakes are undesirable, close any applications that may create them before allowing the device to sleep.

Patching To Correct Sleep Issues

The good news is that you can probably correct all of these issues with a single CLOVER configuration change and SSDT hotpatch from Rehabman! Determine which patch you need by inspecting your DSDT and matching the methods to the patches below.

Patch Method #1 (GPRW,2,N)

Search your DSDT for PRW. If you find method GPRW, use these patches.

Use your favorite plist editor to add this patch to the ACPI/DSDT/Patches array in config.plist.

Key

Type

Value

Comment

String

change Method(GPRW,2,N) to XPRW, pair with SSDT-GPRW.aml

Disabled

Bool

False

Find

Data

4750525702

Replace

Data

5850525702

Compile this patch with maciASL and save as CLOVER/ACPI/patches/SSDT-GPRW.aml.

// For solving instant wake by hooking GPRW or UPRW
// Credit: Rehabman
// Modified to work without some extra setup
DefinitionBlock("", "SSDT", 2, "hack", "_GPRW", 0)
{
External(XPRW, MethodObj)
// In DSDT, native GPRW is renamed to XPRW with OpenCore binpatch.
// As a result, calls to GPRW land here.
// The purpose of this implementation is to avoid "instant wake"
// by returning 0 in the second position (sleep state supported)
// of the return package.
Method(GPRW, 2)
{
For (,,)
{
If (0x6d == Arg0) { Return (Package() { 0x6d, 0, }) }
If (0x0d == Arg0) { Return (Package() { 0x0d, 0, }) }
Break
}
Return (XPRW(Arg0, Arg1))
}
}

Patch Method #2 (UPRW,2,N)

Search your DSDT for PRW. If you find method UPRW, use these patches.

Use your favorite plist editor to add this patch to the ACPI/DSDT/Patches array in config.plist.

Key

Type

Value

Comment

String

change Method(UPRW,2,N) to XPRW, pair with SSDT-UPRW.aml

Disabled

Bool

False

Find

Data

555052570a7012

Replace

Data

585052570a7012

Compile this patch with maciASL and save as CLOVER/ACPI/patches/SSDT-UPRW.aml.

// For solving instant wake by hooking GPRW or UPRW
// Credit: Rehabman
// Modified to work without some extra setup
DefinitionBlock("", "SSDT", 2, "hack", "_UPRW", 0)
{
External(XPRW, MethodObj)
// In DSDT, native UPRW is renamed to XPRW with OpenCore binpatch.
// As a result, calls to UPRW land here.
// The purpose of this implementation is to avoid "instant wake"
// by returning 0 in the second position (sleep state supported)
// of the return package.
Method(UPRW, 2)
{
For (,,)
{
If (0x6d == Arg0) { Return (Package() { 0x6d, 0, }) }
If (0x0d == Arg0) { Return (Package() { 0x0d, 0, }) }
}
Return (XPRW(Arg0, Arg1))
}
}

Patch Method #3 LANC (_PRW,2,N)

Search your DSDT for PRW. If you find method LANC _PRW, use these patches.

Use your favorite plist editor to add this patch to the ACPI/DSDT/Patches array in config.plist.

Key

Type

Value

Comment

String

change LANC (_PRW,0,S) to (XPRW,0,..), pair with SSDT-LANCPRW.aml

Disabled

Bool

False

Find

Data

00001900141f5f50525708

Replace

Data

00001900141f5850525708

Compile this patch with maciASL and save as CLOVER/ACPI/patches/SSDT-LANCPRW.aml.

// For solving instant wake by hooking GPRW
// Credit: Rehabman
// Modified to work without some extra setup
DefinitionBlock("", "SSDT", 2, "hack", "_LANCPRW", 0)
{
External(XPRW, MethodObj)
// In DSDT, native LANC._PRW is renamed XPRW with OpenCore binpatch.
// As a result, calls to LANC._PRW land here.
// The purpose of this implementation is to avoid "instant wake"
// by returning 0 in the second position (sleep state supported)
// of the return package.
// LANC._PRW is renamed to XPRW so we can replace it here
// LANC can be named as GLAN or other names, make sure you match it
// with the one in your ACPI.
External(_SB.PCI0.LANC.XPRW, MethodObj)
Method(_SB.PCI0.LANC._PRW)
{
Local0 = \_SB.PCI0.LANC.XPRW()
For (,,)
{
Local0[1] = 0
}
Return(Local0)
}
}

Laptop Still Have Insomnia?

In that case, you're going to have to create a custom patch for your system, here's a guide that should help you out.

[Guide] Using Clover to "hotpatch" ACPI