>
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.