So recently I noticed that my new Lenovo did not properly enter Hibernation after staying in Suspend for some time.
Looking at the error logs I saw the following.
Dez 09 13:28:49 arthur kernel: xhci_hcd 0000:00:14.0: PM: failed to freeze async: error -16 Dez 09 13:28:49 arthur kernel: xhci_hcd 0000:00:14.0: PM: dpm_run_callback(): pci_pm_freeze+0x0/0xf0 returns -16 Dez 09 13:28:49 arthur kernel: xhci_hcd 0000:00:14.0: PM: pci_pm_freeze(): hcd_pci_suspend+0x0/0x20 returns -16
So what is happening during a suspend-then-hibernate cycle.
- System enters suspend
- System wakes from suspend then enters Hibernate
The problem apparently lies with the second step. When the system starts up again the USB subsystem is started up as well and then the systems tries to hibernate before the USB stack is active so it errors out. To work around this issue I added the following small script to my systemd-sleep configuration.
/lib/systemd/systemd-sleep/hibernate
#!/bin/sh if [ "$SYSTEMD_SLEEP_ACTION" = "hibernate" ] && [ "$1" = "pre" ]; then sleep 5; fi
It more or less adds a sleep between the suspend and the hibernate process giving the USB stack enough time to settle.