I had to make one tweak to your code, and now suspend-then-hibernate
is 100% working: I had to put sleep 4
after /usr/bin/nvidia-sleep.sh "resume"
, otherwise my laptop would hang after resuming from hibernation.
I suspect this is because the echo "resume" > /proc/driver/nvidia/suspend
and echo "hibernate" > /proc/driver/nvidia/suspend
calls (via /usr/bin/nvidia-sleep.sh
) occur too rapidly for the nvidia driver to handle properly.
To debug, I put this at the top of /lib/systemd/system-sleep/nvidia
:
echo "$(date) $1 $2 $SYSTEMD_SLEEP_ACTION" >> /var/log/my-sleep-log
Before adding the sleep
, I saw:
Sun Jun 12 08:58:41 PM CDT 2022 pre suspend-then-hibernate suspend
Sun Jun 12 08:58:53 PM CDT 2022 post suspend-then-hibernate suspend
Sun Jun 12 08:58:54 PM CDT 2022 pre suspend-then-hibernate hibernate
After the sleep
I see:
Sun Jun 12 09:28:19 PM CDT 2022 pre suspend-then-hibernate suspend
Sun Jun 12 09:28:31 PM CDT 2022 post suspend-then-hibernate suspend
Sun Jun 12 09:28:36 PM CDT 2022 pre suspend-then-hibernate hibernate
Sun Jun 12 09:29:18 PM CDT 2022 post suspend-then-hibernate hibernate
So it looks like before my tweak the nvidia driver wouldn’t properly prepare for hibernation, causing the system to crash/hang immediately after the first frame of video painted to screen, showing a frozen desktop.
While it would be nice if nvidia would write proper drivers, I would be happy if they at least rolled out this change to /lib/systemd/system-sleep/nvidia
so suspend-then-hibernate
isn’t broken by default (and so I don’t have to keep manually altering this file after package updates). If support can forward this to the dev team, it would be much appreciated.