3 ms·
> Why does Linux have so much trouble sleeping and waking? To successfully suspend and resume a laptop, BIOS/UEFI and all drivers in the system, e.g. GPU, net
by segfaultbuserr 6y ago
> Why does Linux have so much trouble sleeping and waking?
To successfully suspend and resume a laptop, BIOS/UEFI and all drivers in the system, e.g. GPU, network, audio, USB, must have perfectly working power management code, a single bug in a driver is enough to prevent the entire system from sleeping.
> [...] I've had Macs and PCs which don't seem to suffer from the same issue.
Macs and PCs are fully tested by the vendor with all driver issues fixed before they are shipped - if they can't wake up, it's vendor's problem. On the other hand, if a laptop does not offer explicit Linux support, they are not tested at all. Linux developers are left on their own to figure it out. Worse, for some types of hardware, documentation is often lacking or nonexistent (OEMs have internal support from all device vendors). By saying "on their own", I really mean it - I've personally diagnosed and fixed a driver issue in the Linux kernel for my laptop, despite not being a kernel developer. If you have a popular machine, someone else will eventually fix it. But if you have an unique machine, sometimes there's really nobody that would do it for you.
By far, the most notorious suspended/wakeup problem I've ever encountered was on a Windows tablet. Once the machine is suspended (ACPI S3), it's impossible to wakeup the machine again. After a long thread in the Linux bugzilla, ultimately the problem was identified - a developer disassembled the ACPI DSDT from BIOS, and discovered this scandal.
Device (PWRB)
{
/*
* Power Button Device.
* _PRW: Power Resources for Wake.
*/
Name (_HID, EisaId ("PNP0C0C")
Method (_PRW, 0, NotSerialized)
{
Return (Package (0x02)
{
0x00,
0x00
})
}
}
Yes, it means what you think it meant, even if you don't speak ACPI.
power_button_wakeup() {
return 0;
}
There's literally no code in BIOS to wakeup the system from ACPI S3, the only instruction is "return 0", it's not implemented at all!
Why does it work in Windows then? In Windows, it uses Microsoft InstantGo (ConnectedStandy) - a proprietary Microsoft standby mode with network connection (to allow smartphone-like "push notification"). The vendor decided that implementing industry standards are not necessary - you only need to implement Microsoft - and simultaneously, they also decided that, rather than simply saying ACPI S3 is not supported, you should define a broken ACPI S3 just to screw up everyone who is not using Microsoft Windows.
- gobblegobble2 6y agoIsn't InstantGo/ConnectedStandby basically the same thing as S0IX ACPI state? (according to this: https://www.thurrott.com/mobile/microsoft-surface/64867/trying-to-explain-the-surface-sleep-problems https://www.thurrott.com/mobile/microsoft-surface/64867/tryi...) It's seems doable with modern kernels: https://01.org/blogs/qwang59/2018/how-achieve-s0ix-states-linux https://01.org/blogs/qwang59/2018/how-achieve-s0ix-states-li.... Maybe you should give it a try.
- segfaultbuserr 6y agoThanks for the comment, it's a great suggestion. The Intel documentation is really comprehensive (too bad that it didn't exist back when I was still using the tablet). Yes, I knew s0ix. Unfortunately, the last time I've checked, s0ix had its own problems. Since then, I've given up and switched to a Thinkpad with coreboot. I just rechecked, it seems the s0ix bug is already resolved by a combination of BIOS update and a kernel parameter workaround, so suspend should finally be usable by now, hooray! Despite I'm not using it anymore, I'd still call it progress.
- halz 6y agoYes, ACPI DSDT being utterly broken seems to be a pretty common trip point for Linux suspend/sleep. For my Dell Precision 5510, I was able to patch[1] a missing device back into the DSDT, as well as 'fix' some thunderbolt port enumeration race condition. The hackintosh community was helpful in providing ACPI dumps from similar enough Dell systems in the same generation that I was able to paste in the missing device to get very consistent S3 performance. Using `acpiexec` was very helpful to simulate invoking sleep/suspend and being able to follow the execution path of where it would get stuck. Also want to add that random wakeups can be triggered by interrupts hitting devices in `/proc/acpi/wakeup`. These wakeup sources can be selectively disabled once the problematic ones are identified. I disable XHC (USB ports), because it seems my routine closes the lid to suspend and _then_ remove peripherals.. which can cause a wakeup! [1] https://gist.github.com/mailhost/d5b27b247fa26d8bdc8a5d2022347306 https://gist.github.com/mailhost/d5b27b247fa26d8bdc8a5d20223...
- 6y ago