System fails to resume after hibernation due to Nvidia

Hi, I’ve been trying to configure my system to “Hibernate” (suspend to disk). I followed this guide (with some changes as I’m systemd-based) and the hibernate button is now available in KDE, the system suspends with no issues.

When I start up again after the suspend, the system boots normally instead of resuming. In dmesg, I can see that the swapfile is loaded successfully but there are some errors from nvidia that cause it to boot from scratch.

[    4.601338] PM: hibernation: Marking nosave pages: [mem 0x00000000-0x00000fff]
[    4.601346] PM: hibernation: Marking nosave pages: [mem 0x0009e000-0x0009efff]
[    4.601350] PM: hibernation: Marking nosave pages: [mem 0x000a0000-0x000fffff]
[    4.601356] PM: hibernation: Marking nosave pages: [mem 0x85984000-0x85984fff]
[    4.601360] PM: hibernation: Marking nosave pages: [mem 0x9099a000-0x909dffff]
[    4.601365] PM: hibernation: Marking nosave pages: [mem 0x93bfa000-0x93bfafff]
[    4.601368] PM: hibernation: Marking nosave pages: [mem 0x95db5000-0x99ffefff]
[    4.601956] PM: hibernation: Marking nosave pages: [mem 0x9a000000-0xffffffff]
[    4.602798] PM: hibernation: Basic memory bitmaps created
[    4.651518] PM: Using 3 thread(s) for lzo decompression
[    4.651520] PM: Loading and decompressing image data (872611 pages)...
[    4.719112] PM: Image loading progress:   0%
[    5.284108] PM: Image loading progress:  10%
[    5.415718] PM: Image loading progress:  20%
[    5.545200] PM: Image loading progress:  30%
[    5.667252] PM: Image loading progress:  40%
[    5.787451] PM: Image loading progress:  50%
[    5.898473] PM: Image loading progress:  60%
[    6.002815] PM: Image loading progress:  70%
[    6.163241] PM: Image loading progress:  80%
[    6.251344] PM: Image loading progress:  90%
[    6.328626] PM: Image loading progress: 100%
[    6.328634] PM: Image loading done
[    6.328640] PM: hibernation: Read 3490444 kbytes in 1.67 seconds (2090.08 MB/s)
[    6.328977] PM: Image successfully loaded
[    6.328980] printk: Suspending console(s) (use no_console_suspend to debug)
[    6.371239] NVRM: GPU 0000:01:00.0: PreserveVideoMemoryAllocations module parameter is set. System Power Management attempted without driver procfs suspend interface. Please refer to the 'Configuring Power Management Support' section in the driver README.
[    6.371250] nvidia 0000:01:00.0: PM: pci_pm_freeze(): nv_pmops_freeze [nvidia] returns -5
[    6.371695] nvidia 0000:01:00.0: PM: dpm_run_callback(): pci_pm_freeze.llvm.11904911950140034564 returns -5
[    6.371710] nvidia 0000:01:00.0: PM: failed to quiesce async: error -5
[    6.438999] PM: hibernation: Failed to load image, recovering.
[    6.521441] PM: hibernation: Basic memory bitmaps freed
[    6.521853] OOM killer enabled.
[    6.521853] Restarting tasks: Starting
[    6.522104] Restarting tasks: Done
[    6.522112] efivarfs: resyncing variable state
[    6.538395] efivarfs: finished resyncing variable state
[    6.538403] PM: hibernation: resume failed (-5)

My understanding of the issue is that the system memory was saved to disk successfully, but the video memory was not, forcing a regular boot. This happens consistently so far.

I’ve enabled the nvidia-resume, nvidia-hibernate, and nvidia-suspend systemd services, and set NVreg_PreserveVideoMemoryAllocations=1 in /etc/modprobe.d/nvidia-power-management.conf.

/proc/driver/nvidia/params contains the expected lines PreserveVideoMemoryAllocations: 1 and TemporaryFilePath: "/var/tmp".

Others online (and the Arch docs) mentioned Early KMS, causing the failure because the nvidia driver can’t load from its saved files before the disk is mounted. As far as I can tell this isn’t enabled on my system, my mkinitcpio hooks are base systemd autodetect keyboard sd-vconsole modconf block sd-encrypt btrfs filesystems resume fsck and the MODULES list is empty.

I also found this issue on GitHub which leads me to believe this is an issue with the open source Nvidia drivers - but it also seems that the proprietary ones are no longer available for CachyOS?

Any help or pointers is appreciated, thanks!

i have a 4070 super and i also cant resume from standby.

Same problem here. It would be a game change if you can fix the problem. See my old thread for the same issue https://discuss.cachyos.org/t/could-not-get-hibernate-to-work/10130

After some debugging I think I found the root cause: CachyOS loads the Nvidia modules early into the initramfs via chwd (/etc/mkinitcpio.conf.d/10-chwd.conf adds nvidia nvidia_modeset nvidia_uvm nvidia_drm to MODULES), while at the same time nvidia-sleep.conf sets NVreg_PreserveVideoMemoryAllocations=1.

I thinkt the problem is that when the Nvidia driver is loaded this early during boot, the /proc/driver/nvidia/suspend interface isn’t ready yet. So when the kernel tries to resume, the driver fails to restore video memory and returns error -5, causing the resume to fail.

The nvidia-hibernate.service and nvidia-resume.service systemd services are designed to interact with this procfs interface, but I think they run too late — the driver has already been loaded and failed by that point.