MacPro7,1 = ASRock X570 ITX/TB3, 5900X, RX-570: chasing sleep/wake stability

Aluveitie

Donator
Donator
Joined
May 2, 2020
Messages
755
If there is a Beta 1 of a new macOS I want it :D

I don't have high hopes for this particular issue since it looks like a hackintosh only thing.
Apfelnico's guide for ACPI USB mapping mentions a fix for it, but his method is not directly applicable (AMD boards have the ports defined in the DSDT not an SSDT).
I tried to only apply the power management fix to the internal USB port but that broke entering sleep instead... Will have to do more testing in that regard.
 

atanvarno

Donator
Donator
Joined
May 2, 2020
Messages
119
Apfelnico is..? I found such user on hackintosh-forum.de, not sure what guide you refer to.

If you can point me to URL, I would love to read.
 

atanvarno

Donator
Donator
Joined
May 2, 2020
Messages
119
Aluveitie sent me to well of knowledge with no end. I have 10+ tabs open, full of dense information regarding the infamous _PWR method. This Sleep / Wake thing is amazing, really.

For starters, a refresher what sleep states exist:

GxNameSxDescription
G0WorkingS0The computer is running and the CPU executes instructions. "Awaymode" is a subset of S0, where monitor is off but background tasks are running
G1SleepingS0ixModern Standby,[37] or "Low Power S0 Idle". Partial processor SoC sleep.[38][39] Known to ARM and x86 devices.
S1Power on Suspend (POS): Processor caches are flushed, and the CPU(s) stops executing instructions. The power to the CPU(s) and RAM is maintained. Devices that do not indicate they must remain on may be powered off
S2CPU powered off. Dirty cache is flushed to RAM
S3commonly referred to as Standby, Sleep, or Suspend to RAM (STR): RAM remains powered
S4Hibernation or Suspend to Disk: All content of the main memory is saved to non-volatile memory such as a hard drive, and the system is powered down
G2Soft OffS5G2/S5 is almost the same as G3 Mechanical Off, except that the power supply unit (PSU) still supplies power, at a minimum, to the power button to allow return to S0. A full reboot is required. No previous content is retained. Other components may remain powered so the computer can "wake" on input from the keyboard, clock, modem, LAN, or USB device
G3Mechanical OffThe computer's power has been totally removed via a mechanical switch (as on the rear of a PSU). The power cord can be removed and the system is safe for disassembly (typically, only the real-time clock continues to run using its own small battery)

Okie, so S0 is fully awake, S5 is shutdown. S4 is hibernation and for desktop machines this is overkill to aim for.
Thus what we – on desktop Hackintosh – are chasing is S3.
We want to enter S3 reliably and wake from S3 back to S0.



Now — first to learn what _PRW is: Power Resources for Wake.

The typical form we see is this:
Code:
Method (_PRW, 0, NotSerialized)  // _PRW: Power Resources for Wake
{
    Return (Package (0x02)
    {
        0x69, 
        0x03
    })
}
Per docs from the link above, I understand that return value is
Code:
Package {
   EventInfo                      // Integer
   DeepestSleepState              // Integer
}
Important bits:

(1) With EventInfo being Integer, then: "If it is an Integer, then it contains the bit index of the wake event within the FADT-based GPE enable register." OK, will see later what FADT / GPE register is.

(2) DeepestSleepState is an Integer that contains the deepest power system sleeping state that can be entered while still providing wake functionality.

Now remembering what SSDT-GPRW (I used so far) does: finds _PRW instances where it returns 0x08 0x04 and changes that into 0x08 0x00.
If I get this correct — original value of 0x04 for second argument meant that these devices can enter S4 (hibernation) and still wake the system from it. By changing 4 to 0, it means device can now enter S0 (==fully awake) and in any other state it will not be able to perform wake. W.T.H?! This makes no sense. How is then mouse or keyboard able to wake-up the system from S3?

(This is the point where I asked myself do I even understand what I am reading).

For fun, I checked DSDT from actual MacPro7,1 and looked what _PRW implementations it has. Here's a typical one:

Code:
Method (_PRW, 0, NotSerialized)
{
    If (OSDW ())
    {
        Return (Package (0x02)
        {
            0x69, 
            0x03
        })
    }
    Else
    {
        Return (Package (0x02)
        {
            0x69, 
            0x04
        })
    }
}
OSDW method is checking if OS is Darwin, thus this thing returns S3 state for Mac and S4 for Linux, Windows etc. Which actually does make sense.

My conclusion so far is that SSDT-GPRW should be adjusted to return 0x03.

But that remains to be tested, which takes a loooot of time that's not easy to find at the moment. These tabs will stay open for quite a while.
 

Aluveitie

Donator
Donator
Joined
May 2, 2020
Messages
755
@atanvarno wow, thanks for condensing down your findings. Very interesting read!

Interestingly, one of the last two updates seemd to have fixed wake up again, even after several sleep cycles Bluetooth was still working properly.
 

AMDPUSH

Donator
Donator
Joined
May 2, 2020
Messages
178
For me, I just want to have a proper shut down with S5. I have the link :
https://dortania.github.io/OpenCore-Post-Install/usb/misc/shutdown.html.
Perphaps it seems to be very easy to do, but for me it's painful. I have my DSDT and was able to finf the _PWR (thanks to Shaneee) but after that i'am lost. If some body would be gentle to make a tutorial about it, i will be very very happy.
And i am pretty sure i won't be alone.
Thanks everyone
 

atanvarno

Donator
Donator
Joined
May 2, 2020
Messages
119
Interestingly, one of the last two updates seemd to have fixed wake up again, even after several sleep cycles Bluetooth was still working properly.
Hey, that's awesome. Please do report your tests - more tests, the merrier.

With the previous version of SSDT-GPRW, sleep/wake would often work but then occasionally would go to sleep but then half-wake up after 10-20s (not sure). Screen would be dead but rest of the comp would seem alive. Emphasis on "seem" becauase nothing responds, not even power button. Only pull the plug can turn it off. But the AIO pump and fans are working, motherboard and GPU RGB lights-up. Super weird.

So this is the version I have active now and will see how it behaves:

Code:
DefinitionBlock ("", "SSDT", 2, "XLNC", "GPRW", 0x00000000)
{
    External (XPRW, MethodObj)    // 2 Arguments

    Method (GPRW, 2, NotSerialized)
    {
        If (_OSI ("Darwin"))
        {
            If ((0x04 == Arg1))
            {
                Return (XPRW (Arg0, 0x03))
            }
        }

        Return (XPRW (Arg0, Arg1))
    }
}

Basically, for any _PRW where second argument is 0x04, it will override it to 0x03.

So far, one idle transition to sleep worked and more importantly: wake after 3h also worked.
Will see over the weekend how it goes.
 

atanvarno

Donator
Donator
Joined
May 2, 2020
Messages
119
Perphaps it seems to be very easy to do, but for me it's painful. I have my DSDT and was able to finf the _PWR (thanks to Shaneee) but after that i'am lost. If some body would be gentle to make a tutorial about it, i will be very very happy.
I'm not sure I can help. I never had shutdown issues with this build.
 

Aluveitie

Donator
Donator
Joined
May 2, 2020
Messages
755
@atanvarno My understanding was that by setting 0x0 you prevent the device from being put to sleep (since it cannot wake from anything). As Apfelnico mentions on his HS13, it should keep Bluetooth active during sleep to be able to wake up from bluetooth devices.
 

Aluveitie

Donator
Donator
Joined
May 2, 2020
Messages
755
Did you test to SSH into your machine when it did not wake up properly?
It is a long time since, but I think to remember I might have been able to. I guess this might have been what I fixed with the HibernationFixup kext and boot arg -hbfx-disable-patch-pci
 

atanvarno

Donator
Donator
Joined
May 2, 2020
Messages
119
Did you test to SSH into your machine when it did not wake up properly?
It is a long time since, but I think to remember I might have been able to. I guess this might have been what I fixed with the HibernationFixup kext and boot arg -hbfx-disable-patch-pci
I tried that and nope - it is not responding at all.

So far I am testing without WEG and bare minimum of SSDTs and kexts. I have lots of stuff to do over the weekend, so will set 1-2min sleep time and see how it behaves.
 

atanvarno

Donator
Donator
Joined
May 2, 2020
Messages
119
My understanding was that by setting 0x0 you prevent the device from being put to sleep (since it cannot wake from anything). As Apfelnico mentions on his HS13, it should keep Bluetooth active during sleep to be able to wake up from bluetooth devices.
My internal Bluetooth hub is on the XHC that falls under the 0x03. The last 3 sleep / wakes I did was either with mouse (Glorious MOW, has its own USB adapter) or Bt keyboard (Keychron K1). I don't personally care what I use to wake up the machine, as long as both peripherals are working after wake up.

I'll do comparisons with Windows 10, to see is it behaving the same. Particularly what happens with keyboard lights; I assume that if keyboard gets machine-went-to-sleep notification it will turn its lights off but that remains to be tested.
 

atanvarno

Donator
Donator
Joined
May 2, 2020
Messages
119
I am growing more confident the SSDT-GPRW from few posts back is the winner. Dozen of sleep/wake cycles went through, works great. Regardless of using wired or BT keyboard, it sleeps and wakes up reliably.

@Shaneee – try with that one, could possibly work for you.

Unless something suddenly changes, this is it. Everything I ever wanted from this machine is working.
 

Shaneee

The AMD Guy
Staff member
Administrator
Joined
Mar 13, 2020
Messages
1,422
I am growing more confident the SSDT-GPRW from few posts back is the winner. Dozen of sleep/wake cycles went through, works great. Regardless of using wired or BT keyboard, it sleeps and wakes up reliably.

@Shaneee – try with that one, could possibly work for you.

Unless something suddenly changes, this is it. Everything I ever wanted from this machine is working.

Unfortunately nothing changed. Still an instant wake.
 

atanvarno

Donator
Donator
Joined
May 2, 2020
Messages
119
Daaaamn - a random lock-up on wake today, after days and days of all working fine.

Really wish I knew how to track this down. I tried in the past with DEBUG builds and DebugEnhancer.kext and acpi-*** boot args and what not. Either I did not know how to setup/use all that or it did not reveal what's the lingering issue here.
 
Top Bottom