Debugging sleep issues…

A lot of people are still facing sleep/wake related issues and I like to figure out why so please check:

IOService:/AppleACPIPlatformExpert/IOPMrootDomain/PMStatusCode

1.) Is that number a zero or some other value?
2.) Do you have a property with the name: IOPMDeepIdleSupported?
3.) Do you have a property with the name: IOPMSystemSleepType?

If the answer for the first question is zero, then I would like to know if you are using a dGPU or IGPU only.

The second question can be solved by adding the following code to your ACPI tables:

Scope (\_SB)
{
    Method (LPS0, 0, NotSerialized)
    {
        Store ("Method \\_SB._LPS0 Called", Debug)
        Return (One)
    }
}

Scope (\_GPE)
{
    Method (LXEN, 0, NotSerialized)
    {
        Store ("Method \\_GPE.LXEN Called", Debug)
        Return (One)
    }
}

If the answer for the last question is yes, then what value is it, and what SMBIOS are you using? Please note that this specific property is not part of Yosemite. The value represents the lowest possible sleep state and is checked by the following kexts:

AppleACPIPlatform.kext
AppleIntelBDWGraphicsFramebuffer.kext
AppleIntelFramebufferAzul.kext
AppleIntelSKLGraphicsFramebuffer.kext
AppleSDXC.kext
AppleStorageDrivers.kext
IO80211Family.kext
IOBluetoothFamily.kext
IONVMeFamily.kext
IOUSBAttachedSCSI.kext
IOUSBMassStorageDriver.kext

That should be enough reasons for you to want that property.

I also added the following code to my ACPI tables:

Scope (\)
{
   Name (SLTP, Zero)

   Method (_TTS, 1, NotSerialized)
   {
       Store ("Method \\__TTS Called", Debug)
       Store (Arg0, SLTP)
   }
}

This, with additional checks, is used by Apple to skip parts for the NVMe SSD (RP01/IOPP/SSD0@0), AirPort (RP09/IOPP/ARP@0) and camera (RP10@1D,1/IOPP/CMRA) devices

NVRAM

There are two interesting NVRAM properties:

#define kIOSleepWakeDebugKey        "Persistent-memory-note"
#define kIOEFIBootRomFailureKey     "wake-failure"

That has to be it for now. Maybe later more…

Edit:

Ok. Jaybee asked (see comments) how he should validate the values. That is a good question. Let’s start with PMStatusCode. This should be 0x0 (success).

IOPMDeepIdleSupported. This should be there with a value of true.

IOPMSystemSleepType is the lowest possible sleep state and this is set to 7 on my MacBook Pro. This will also issue a sleep request for the iGPU.

Some people said that this property wasn’t there on their setup. For some not until after a sleep/wake cycle, and then it was set to 2.

I have yet to figure out how important this value is and if that can cause any trouble.

105 thoughts on “Debugging sleep issues…

  1. Hi Pike,
    I will check this out the next days on my x99 i5820k with asrock x99m extreme4 and gtx970 – with sleep issues (hard reset)

  2. interesting developments… 😉

    1) PMStatusCode = 0x0 : iGPU (i7-6700K)
    2) IOPMDeepIdleSupported : not present
    3) IOPMSystemSleepType : not present

  3. Mac-65CE76090165799A
    AAPL,ig-platform-id: 0x00, 0x00, 0x12, 0x19

    I added the acpi suggestion to my DSDT, (without the NVRAM suggestions) but the values didn’t show up in ioreg.
    Also no change in sleep/wake behaviour: reboot at wake.

  4. If it’s useful, my genuine MacBookPro10,1 (10.11.6) has the following information:

    1) 0x0, using iGPU (HD4000) | 0x0, using dGPU (GT650M)
    2) no
    3) yes, 0x5

    I can look on my Haswell hackintosh (iMac14,x?) in a few days, and also see what happens when I upgrade it to Skylake (iMac17,1).

    • Haswell (Xeon –> no iGPU), iMac14,2, Baord ID Mac-27ADBB7B4CEE8E61, using GTX 960

      Before sleep:
      1) 0x0
      2) does not exist (but I do have IOPMrD/Supported Features/DeepSleep == 0x2030007)
      3) does not exist

      After sleep:
      1) 0x0
      2) does not exist
      3) 0x2

  5. MacOS Sierra 10.12.2

    1) PMStatusCode = 0x0 : iGPU (i5-6200U)
    2) IOPMDeepIdleSupported : not present
    3) IOPMSystemSleepType : 0x3

    I use MacBook 9,1 SMBIOS

  6. MacOS Sierra 10.12.2

    17,1 SMBIOS
    Mac-65CE76090165799A
    AAPL,ig-platform-id: 0x00, 0x00, 0x12, 0x19

    1) PMStatusCode = 0x0 : iGPU (i7-6700K)
    2) IOPMDeepIdleSupported : not present
    3) IOPMSystemSleepType : not present

    But I am not using DSDT I tried but I always getting error and I didn’t find how two fix it and stopped using it.

    can I create a SSDT from your code? will it work?

  7. Note that IOPMSystemSleepType is present only after sleep ! Force your system to go to sleep and wake up it, and you will see this data appears.

    At least, it is the case for me ;). Nothing after a reboot, value after a sleep/wake up cycle.

    • Balamut, how did you manage to finally get the PMStatusCode entry? Did you succeed at all? Please help! My current status is still:

      1. PMStatusCode not present
      2. true
      3. 0x2 after wake

      Many thanks in advance!

  8. Mac-FC02E91DDD3FA6A4
    iMac13,2 SMBIOS
    AMD Radeon R7 250X ans Sierra 10.12.2

    1) present, 0x0
    2) not present
    3) not present

    That shouldn’t be an issue since my sleep is not working in any ways. It reboots after wake. MSI Z77A-G41. Heard that this is common issue on those motherboards.

  9. Ok. Here is the result;

    Before these codes;
    Display Sleeps/Wakes, Fans are still working.

    After these codes;
    Display Sleeps/Wakes, Fans are still working.

    Actually nothing changed from my side. My display sleeps and wakes with or without these codes. Fans are always working.

  10. I’ve having only the issue of sleep killing usb when using the lid to sleep, software, both timed and via button on the menu work without usb broken on wake…
    I tried the SSDT, but it seems to change nothing.
    I’m on Skylake Xiaomi laptop with MBP13,1 Smbios IGPU HD520 “0x19160000”

    presleep:
    PMStatusCode 0x0
    IOPMDeepIdleSupported (not present)
    IOPMSystemSleepType (not present)

    postsoftwaresleep:
    PMStatusCode 0x0
    IOPMDeepIdleSupported (not present)
    IOPMSystemSleepType 0x2

    postlidsleep:
    PMStatusCode 0x0
    IOPMDeepIdleSupported (not present)
    IOPMSystemSleepType 0x2

    Difference noticeable between lid and button:
    lid DriverPMAssertions 0x0
    but. DriverPMAssertions 0x4
    lid DriverPMAssertionsDetailed (not present)
    but. DriverPMAssertionsDetailed (6 entries) {all the USB ports}
    lid SleepRequestedByPID (not present)
    but. SleepRequestedByPID 0x62

    Hope you can help!

    Thanks a lot for all your awesome work!

    • If you can’t find IOPMDeepIdleSupported with the SSDT, then something obviously is not working properly. Perhaps it isn’t loading? For example. Maybe you already have a method _TTS somewhere in the ACPI tables, or one (or both) of the other method(s). Please check this (once more). That property must be there.

      Next step would be to check the USB related ACPI SSDT and routines. The code under the LID0 method may do something extra that the button doesn’t do, or the button code does something that it shouldn’t do.

      • I checked to be certain, all three methods are not present in my ACPI tables, and the added tiny-SSDT has no effect.

  11. Ciao, thanks for answering!
    I did some tests, and the SSDT is loading (without causing ACPI errors) as far as I can see from verbose, there aren’t conflicts on the other tables, I’ve even applied the methods on the DSDT itself, but nothing has changed…
    IOPMDeepIdleSupported is still not present.

    Regarding LID0 I’ve even tried removing everything about it on the tables and even if the laptop go to don’t sleep when closing the lid, when the laptop go to sleep with the timer, if the lid is closed usb is lost…
    I really tried everything to fix this issue…
    It seems a stupid thing but no one on IM or TMX had any “answer” to this “question”.

    Is there something else I could try?

    • A SSDT may load, but may also not make it into the ACPI namespace due to errors. Please add debug statements to the added methods like so:

      Store ("Method (_TTS) called", Debug)

      But use LPS0 and LXEN instead of _TTS for the other methods. After that you can check the log for these lines. Not seeing them is an error. Make sure that you are using the required boot arguments and/or arguments to the log binary.

      • Thanks, but the only ACPI tables that I could find are the few in Clover/patched and these are seriously broken. I can’t even open most of the SSDT tables.

        Edit: Can you please e-mail me your copy of iasl?

      • Brokens?
        Do you mean bad patching or corruption?
        Those are decompiled and recompiled with iasl 6.1…
        Btw I can send you the tables again alongside the origin unpatched ones

      • Thanks. Got it.

        First a quick question. Why did you remove Method _PRW from XHC? Did you remove more stuff in the patched ACPI tables? I would start by adding debug output to see if _Q52 and _Q53 are triggered. You should do the same for all _LNN methods. This will tell you what part it skips.

      • Ok thanks, I’m trying to add debug to those methods to understand better whats going on, I’ve removed _PRW from GLAN XDCI XHCI to “fix” instant wake on sleep, I know its kinda radical solution, but it’s the only one I’m aware, on the patched DSDT there are some other patches like Brightness to f14 f15, HDEF rename, IMEI rename and some other that I don’t remember right now…

      • So, first of all thanks again not only for helping, but even for teaching me this new stuff I’m really enjoying…
        I’ve checked and the SSDT is loading and I can see debug messages about _TTS being called after sleep, nothing about LPS0 and LXEN.
        The q52 and q53 methods are called when sleeping with lid, but removing them don’t help, still breaking sleep upon wake!
        And I can’t see any _LNN method on the tables.
        What should I look for next?

      • Ok. Now you see the debug output in the log output, which is good, and now you can also follow the path that the code follows. Also good. This helped me a lot. Keep using it, when you need it.

        The Q52/53 methods are indeed called when you open/close the lid, and are triggered by the embedded controller (EC). The methods notify (LID0, 0x80) about the lid state change, but method LID0 lacks any reference to _GPE code so what happens when you add the following code snippet to method LID0:

        Name (_GPE, 0x6D)
        Method (_PRW, 0, NotSerialized) // _PRW: Power Resources for Wake
        {
        Return (Package (0x02)
        {
        0x6D,
        0x04
        })
        }

        Now search for: “Method (_L”. You should find seven matches in the DSDT and the one you are looking for is:

        Scope (_GPE)
        {
        Method (_L6D, 0, Serialized) // _Lxx: Level-Triggered GPE
        {
        \_SB.PCI0.XHC.GPEH ()
        \_SB.PCI0.HDAS.GPEH ()
        \_SB.PCI0.GLAN.GPEH ()
        \_SB.PCI0.XDCI.GPEH ()
        }
        }

        What we did is that we added a reference to _GPE events, and that will trigger a notify on all of the listed devices. Just search for the GPEH methods in the DSDT and there you’ll find: Notify (XHC, 0x02) signalling a wake event. Let’s see what this brings…

        Edit: I checked my log and I see this:

        kernel: (kernel) [0x18] "Method \_SB._LPS0 Called"
        kernel: (kernel) [0x18] "Method \_GPE.LXEN Called"

        Please verify that they are in the right place.

      • Oh, I just saw your new post, I’m pretty sure that’s the problem is not related to my patches, cause the issue is present even when not using any patched table…

      • From the logs I can see LXEN called on boot time and _TTS called after wake, no sign of LPS0…
        I tried adding the snippet to LID, still having the issue…
        From logs when sleeping from LID I see

        AppleUSBXHCIPCI::hardwareException: controller lost power

        Noticed what you wanted to do by the way and found the XHC 0x02 under GPEH.

        This seems a little issue, and it is but its hard to figure out whats causing it…
        I can’t stop to thank you for your help and for every new idea!
        :->

      • Please re-check the scope of LPS0. It should be put into Scope (\_SB) and not Scope (\_SB.PCI0). Please note that my example code was wrong, but I fixed it later on. That may be the problem.

        When exactly do you get this error? This is why I want you to add debug output, so that we know what path it follows, and when errors occur.

      • Ok so, editing the scope now I have even LPS0 Notified on Boottime.
        After software sleep I see:
        PMStatusCode 0x0
        IOPMDeepIdleSupported true
        IOPMSystemSleepType 0x2

        Still losing USB only after LID sleep as said before…

        What could I debug?

      • Hmm. I forgot to check for device properties in you ACPI tables, and I cannot do that right now on my iPad. Did you add any power related properties under XHC?

      • Sorry Pike, I would not want to abuse your help, or stress you, but do you have any new idea?
        I’ve not added any power related property to XHC…

        Thanks! ^.^

      • Not really, but I gave you the tools to trace the problem i.e. keep adding debug output and note the difference(s) between software sleep and lid sleep. This will show you when, at what stage, the power lost error occurs, and then we can see what we can do about it.

      • Little update, using your sleep ssdt, now hibernation works correctly, before it was getting power on after creating the sleep image, and restores fine too using hibernation mode 29…
        Again there is something wrong with the lid, if I use it to start hibernation, after selecting the partition on Clover, the machine reboots, this is not happening with both timed and software sleep…

      • Ciao!
        I tried 10.10, and there the bug is not present, the machine seems to sleep, but without the blinking led and doesn’t wake opening the lid, but usb works even after lid sleeping…

      • Yeah. The USB stack has changed a lot since Yosemite, so that could explain it. El Capitan was a pain. For a lot of people. By the way. Did you connect to it from another computer and verified that USB is working?

  12. I don’t seem to be able to show debug messages from ACPI, the following line did show some debug messages coming from other sources, but nothing from ACPI.

    log show –debug –predicate ‘eventType == logEvent and messageType == debug’ –last 2m

    the next line also gives no results: (1 minute after reboot)
    log show –debug –predicate ‘eventMessage contains “LPS0″‘ –last 2m

    Am I forgetting something?
    Do I need boot-arguments? which ones?

  13. Hi there. Getting the sleep -> reboot issue as well! I have two monitors, one plugged into a dGPU and one plugged into an iGPU for boot monitoring.

    PMStatusCode is 0x1305000027 with the dGPU monitor plugged in and was 0x0 with the iGPU

    Nothing for the other two values but I’ll get an SSDT/DSDT up and running.

    Edit: Alas I get a kernel panic off the SSDT that was posted. Though I was saving it naming it as DSDT.aml and putting it in Clover Config.

    I am using the iMac Retina 5K system definition

  14. There is a change in the SLEEP/WAKE behaviour, before WAKE ended up in a reboot after 10-20 secs, but now my HD-led just keeps blinking endlessly (at least more than a minute) while nothing else seems to happen. I had to keep the power-switch pressed, for 3 secs or more, to get the machine out of that state, the reset-switch didn’t work anymore.

    _TTS is not called, due too the bad WAKE, at least it’s not present in Log.

    • Well that is interesting. Please check your caps-lock state. The light should go on/off. Does that still work? Also. Is hibernate enabled or disabled? I would also let it go for a while.

  15. Before any of the suggested DSDT edits:
    1) PMStatusCode = 0x2000000027 : iGPU (Intel HD4600)
    2) IOPMDeepIdleSupported: Not present
    3) IOPMSystemSleepType: 0x02

  16. Do I need to provide these values here when i have wake issues in Sierra? I’m not so pro into this but I have Skylake with GTX980TI and no whether what I cant fix wake. Someone said that it will never be fixed because model 17,1 will wake first iGPU and after that dGPU. Can you acknowledge that this last statement is incorrect and just wait until a fix comes out? Also DRM with iTunes is handled by iGPU if I’m correct and our desktop iGPU’s are different as the ones Apple uses. But DRM is offtopic. Thanks.

    • No. Providing the values won’t help fix wake. Sorry.

      The iMac17,1 does not use the IGPU for graphics. It doesn’t even use a proper frame buffer. People who say that the iGPU is woken up before the dGPU, by some mysterious code snippet that I have yet to find, are free to point me to it.

      For your info. It is the AppleIntelMEIDriver aka Intel Management Engine Interface (Intel MEI, previously known as HECI) that acts as an interface between the host and Intel ME. See also: OS X 10.11.4 wants IMEI, not HECI.

      Your best hope is that I will spent some serious time on this issue, because so far everything what I have read/seen is bogus.

      • Well that’s good news and bad news. I was almost thinking to sell all my stuff (Desktop skylake hack with 4K screen and macbook retina) to get me an iMac 5K retina. Because sleep with wake is a must for me. The good news is that you acknowledge that there is no technical barrier to let the hack working with good sleep and wake. The bad news is that its acknowledged its a serious issue. Can I help you in providing stuff to analyse it?

  17. Hey Piker, I tried to follow your info above and even created the mini SSDT from Balamut, but after restart I get
    1. PMStatusCode of 0x905000027
    2. Doesn’t Exist
    3. Doesn’t Exist

    The only thing that changed after I added the SSDT to patched was the PMStatusCode (wasn’t 0x0 before the SSDT either though)

    Any thoughts on how I can get a PMStatusCode of 0x0? I’m hoping I’m just overlooking something!

    If it helps at all, I’m running Intel HD530 iGPU and 17,1 iMac.

    Thanks

    • By removing my other SSDT’s and my DSDT from from the patched folder, I was able to get

      1. PMStatusCode of 0x0
      2. Doesn’t exist (despite me keeping the mini SSDT of Balmut’s in the patched folder)
      3. Doesn’t exist

      This obviously means I’ve got somethin screwy with my other SSDTs or DSDT so I’ll look into that. Still not sure why the mini SSDT isn’t working…

      • Ah that would make sense, thanks! Any thoughts regarding the mini SSDT (exactly the same as Balamut’s) not making IOPMDeepIdleSupported appear?

  18. Hey guys,

    i have a wake up problem with my hackintosh. I use a ga-z170x-gaming 3 with i7-6700K and only onboard HD530. After wake up macOS doesn’t start and my caps look led doesn’t work. I use SMBIOS Mac17,1.

    I will testing your solution, but I can’t use the code in the right way. I don’t no what I have to do…
    Can someone build a ssdt for my that I can use with clover? I would be very grateful!!

    Her are my results:

    PMStatusCode: 0xffffffff0400001f
    IOPMDeepIdleSupported: not presented
    IOPMSystemSleepType: not presented

      • thanks for your idea, but it doesn’t work. Which hibernate mode you are using?
        nvda_drv=1 is only für dGPU, right?

      • Yes I have skylake 6700K Asus Maximus VIII Gene based on Z710 but with GTX980TI.
        I also use AddDTGP fix in clover.

        This is the pmset -g output:

        Currently in use:
        standby 1
        Sleep On Power Button 1
        womp 0
        halfdim 1
        hibernatefile /var/vm/sleepimage
        powernap 0
        gpuswitch 2
        autorestart 1
        networkoversleep 0
        disksleep 10
        sleep 27
        autopoweroffdelay 28800
        hibernatemode 0
        autopoweroff 1
        ttyskeepawake 1
        displaysleep 27
        standbydelay 10800

  19. After enabling your patches, and with a correctly configured power management (HWP), my laptop (XPS 19 9360) does not go into sleep anymore.
    It correctly shuts down some peripherals (like Wifi) but system does not fully sleep (PBTN light stays on, SSD whining).

    ## Without patches:

    PMStatusCode: not present (?!)
    IOPMDeepIdleSupported: not present
    IOPMSystemSleepType: 0x2 <== after successful "normal" sleep

    ## With patches:

    PMStatusCode: not present (?!)
    IOPMDeepIdleSupported: true
    IOPMSystemSleepType: 0x7 <== after failed "deep" sleep

    But the interesting part is this: LOGS!
    Hint: look at "Normal Sleep" VS "Deep Idle" (<== IDLE) and S3 Wake VS S0 Wake

    ## Without patches:

    [SLEEP]
    (AppleACPIPlatform) ACPI: sleep states S0 S3 S4 S5
    (AirPortBrcm4360) ARPT: 85.680069: AirPort_Brcm43xx::powerChange: System Sleep
    (AirPortBrcm4360) ARPT: 86.182182: IOPMPowerSource Information: onSleep, SleepType: Normal Sleep,
    PMRD: System Sleep
    IOCPUSleepKernel
    (AppleACPIPlatform) ACPI SLEEP

    [WAKE]
    (AppleACPIPlatform) ACPI S3 WAKE
    (AirPortBrcm4360) ARPT: 88.445665: IOPMPowerSource Information: onWake, SleepType: Normal Sleep

    ## With patches:

    [SLEEP BTN]
    (AppleACPIPlatform) ACPI: sleep states S0 S3 S4 S5
    (AirPortBrcm4360) ARPT: 120.196527: AirPort_Brcm43xx::powerChange: System Sleep
    (AirPortBrcm4360) ARPT: 120.698649: IOPMPowerSource Information: onSleep, SleepType: Deep Idle,
    PMRD: System Sleep
    IOCPUSleepKernel
    (AppleACPIPlatform) ACPI SLEEP

    [WAKE BTN]
    (AppleACPIPlatform) ACPI S0 WAKE
    (AirPortBrcm4360) ARPT: 122.917374: IOPMPowerSource Information: onWake, SleepType: Deep Idle

    _____

    If I want to keep your sleep patches BUT restore sleep functionality, I have to delete IOPlatformSystemSleepPolicy in my platform X86PlatformPlugin plist. This error will be thrown and System will go in normal (0x2) sleep again.

    ” Failed to find sleep policy for this platform! Disabling deep sleep.”

    ___

    Now, listen to my absurd idea: What if this is the correct behaviour? Since new Macs have the “UnifiedSleepSliderPref” set to TRUE, maybe they don’t go in Normal sleep after all, but they prefer to go into Deep Idle as soon as the screen shuts off, and then they jump directly into hibernate after awhile, so to trick the user into believing that the screen is off but the system is on, when instead peripherals are into a deep-idle-low-power-super-fast-to-recover state all the time.

  20. After adding a SSDT (same as Balamut’ s) but with Scope (\_SB), I obtain the following result:

    1. PMStatusCode not present
    2. true
    3. 0x2 after wake

    No way to get the PMStatusCode entry. Any solution to go for?

Leave a comment