^ is as far as I have gotten, as well most of the AMD OS X community. Frustrating isn't it? So close and in your grasp yet the solution still alludes us.
Alternative 2:
- Find a way to make sleep work even with PO9, PO10, PO11 turned on.
- Will this require patching the AppleUSB20XHCIPort function in the appropriate kext?
^ is what I have been thinking for months now, it's just that the knowhow is beyond my knowledge. I am SO GLAD TMX86 laxed the rules on AMD, simply because I know that a solution would be found here.
Regarding the question about patching AppleUSB20XHCIPort, here's an initial look at the problem. First, let's look at the log messages once again...
Code:
kernel: (AppleUSBXHCI) 000097.916083 PO9@00900000: AppleUSB20XHCIPort::resume: timeout waiting for U0
kernel: (AppleUSBXHCI) 000097.916094 PO9@00900000: AppleUSB20XHCIPort::resume: unexpected non-U0 link state (PORTSC 0x0e000e63)
kernel: (AppleUSBXHCI) 000097.917338 PO10@00a00000: AppleUSB20XHCIPort::resume: timeout waiting for U0
kernel: (AppleUSBXHCI) 000097.917349 PO10@00a00000: AppleUSB20XHCIPort::resume: unexpected non-U0 link state (PORTSC 0x0a000e63)
kernel: (AppleUSBXHCI) 000097.918603 PO11@00b00000: AppleUSB20XHCIPort::resume: timeout waiting for U0
kernel: (AppleUSBXHCI) 000097.918614 PO11@00b00000: AppleUSB20XHCIPort::resume: unexpected non-U0 link state (PORTSC 0x0a000663)
kernel: (AppleUSBXHCI) 000097.966204 PO9@00900000: AppleUSB20XHCIPort::resume: timeout waiting for U0
kernel: (AppleUSBXHCI) 000097.966211 PO9@00900000: AppleUSB20XHCIPort::resume: unexpected non-U0 link state (PORTSC 0x0e000e63)
kernel: (AppleUSBXHCI) 000097.969157 PO10@00a00000: AppleUSB20XHCIPort::resume: timeout waiting for U0
kernel: (AppleUSBXHCI) 000097.969167 PO10@00a00000: AppleUSB20XHCIPort::resume: unexpected non-U0 link state (PORTSC 0x0a000e63)
kernel: (AppleUSBXHCI) 000097.970407 PO11@00b00000: AppleUSB20XHCIPort::resume: timeout waiting for U0
kernel: (AppleUSBXHCI) 000097.970417 PO11@00b00000: AppleUSB20XHCIPort::resume: unexpected non-U0 link state (PORTSC 0x0a000663)
...and decode some of these fields:
- 000097.916083 -- this column appears to be the elapsed time since wake in micro seconds? Regardless, it is a measure of time.
- PO9@00900000 -- this consists of two parts: PO9 is the USB port name and 00900000 is its address in the USB bus.
- AppleUSB20XHCIPort -- this is the name of the class in the source code.
- ::resume -- this is the name of the class member function in the source code.
- timeout waiting for U0 and unexpected non-U0 link state are of course the description strings.
- 0x0a000663 and 0x0a000e63 are link state values.
The class
AppleUSB20XHCIPort is in the kext
AppleUSBXHCI, which in turn exists in the kext
/System/Library/Extensions/AppleUSBHostFamily.kext/Contents/Plugins.
When we open AppleUSBXHCI in
Hopper Disassembler, we can locate the entire
AppleUSB20XHCIPort class and narrow in on the
resume member function. We can further convert the assembly code into
pseudo-code and find the exact location where these messages are captured into the system log file:
From our earlier work on Titan Ridge Thunderbolt Bus activation using SSDT (not flashing), we found that
Link State would start off normally (link states 0x2, 0x7, 0x101) but would flip to an inactive and/or error state within 20 seconds after boot. That inactive/error state had a very similar value (0xe00002eb) to what we see here.
So it seems that the USB 2 port itself is not moving into a proper Link State after wake-from-sleep. Because of the bad state, the system subsequently fails to wake fully.
A fix for this problem would be to understand how to control USB 2 ports at the register level and set them to the right active state.
Speculation Zone:
- It seems as if the USB driver is not doing this correctly -- maybe because AMD's USB host controller behaves differently from Intel's?
- Alternatively, we know that Intel's USB implementation has been quirky. So if macOS is handling those quirks in an Intel-specific way, then those quirks may not be working on non-Intel chipset-based USB controllers.
- I wonder if USB 2.0 drivers from Linux can be ported to macOS in the same way that Intel WiFi and Intel Bluetooth drivers from Linux are being ported...
- Again, this is speculation -- but that's all we have right now.