Sometimes unable to suspend OS: Failed to map NvKmsKapiMemory

It happens from time to time on

  • Ubuntu 24.04 (kernel 6.11.0-24-generic, Wayland, Gnome 46)
  • nVidia driver 570.144
  • HW: MSI GeForce RTX 4060 VENTUS 2X BLACK 8G OC

Sometimes when I press the Power button on my PC, the display will blank ✅, but OS is still running (and the Power LED doesn’t start blinking) 🐞.
I have to press a key or the mouse left button twice, then the display wakes up and then when I press the Power button again, suspending is finally successful (the Power LED will start blinking).

Here is a syslog when the issue occurs.
syslog.txt (11.2 KB)

This is my nVidia config

$ cat /etc/modprobe.d/nvidia-graphics-drivers-kms.conf

# Set value to 0 to disable modesetting
options nvidia-drm modeset=1
options nvidia-drm fbdev=1
# To fix textures when resuming from suspend, see https://bugs.launchpad.net/ubuntu/+source/mutter/+bug/1876632
options nvidia NVreg_PreserveVideoMemoryAllocations=1 NVreg_TemporaryFilePath="/var/tmp"

I tried the latest beta 575.51.02 and the issue doesn’t happen.

So it seems to be fixed, maybe within

  • Fixed a bug that could cause graphics applications to not render correctly after a system suspend/resume cycle, if using the nvidia.ko kernel module parameter NVreg_PreserveVideoMemoryAllocations=1.

No, unfortunately still happening, with 575.51.02.

2025-05-11T20:43:12.420585+02:00 rog systemd[1]: nvidia-suspend.service: Deactivated successfully.
2025-05-11T20:43:12.420692+02:00 rog systemd[1]: Finished nvidia-suspend.service - NVIDIA system suspend actions.
2025-05-11T20:43:12.420727+02:00 rog systemd[1]: nvidia-suspend.service: Consumed 1.070s CPU time.
2025-05-11T20:43:12.430037+02:00 rog systemd[1]: Starting systemd-suspend.service - System Suspend...
2025-05-11T20:43:12.433718+02:00 rog systemd-sleep[17877]: Performing sleep operation 'suspend'...
2025-05-11T20:43:12.433937+02:00 rog kernel: PM: suspend entry (deep)
2025-05-11T20:43:12.582926+02:00 rog kernel: Filesystems sync: 0.148 seconds
2025-05-11T20:43:32.632460+02:00 rog kernel: Freezing user space processes
2025-05-11T20:43:32.632547+02:00 rog kernel: Freezing user space processes failed after 20.005 seconds (1 tasks refusing to freeze, wq_busy=0):
2025-05-11T20:43:32.632549+02:00 rog kernel: task:gnome-shell     state:R  running task     stack:0     pid:4455  tgid:4455  ppid:4202   flags:0x0000400e
2025-05-11T20:43:32.632550+02:00 rog kernel: Call Trace:
2025-05-11T20:43:32.632550+02:00 rog kernel:  <TASK>
2025-05-11T20:43:32.632551+02:00 rog kernel:  ? _nv030454rm+0x10/0x10 [nvidia]
2025-05-11T20:43:32.632552+02:00 rog kernel:  _nv030561rm+0x4/0x10 [nvidia]
2025-05-11T20:43:32.632552+02:00 rog kernel:  ? os_get_current_tick+0x3c/0xb0 [nvidia]
2025-05-11T20:43:32.632552+02:00 rog kernel:  ? _nv030560rm+0x6b/0x130 [nvidia]
2025-05-11T20:43:32.632552+02:00 rog kernel:  ? _nv012125rm+0x115/0x270 [nvidia]
2025-05-11T20:43:32.632553+02:00 rog kernel:  ? _nv015626rm+0x65/0x170 [nvidia]
2025-05-11T20:43:32.632553+02:00 rog kernel:  ? _nv058068rm+0x80/0x170 [nvidia]
2025-05-11T20:43:32.632554+02:00 rog kernel:  ? _nv039758rm+0x8a/0xd0 [nvidia]
2025-05-11T20:43:32.632554+02:00 rog kernel:  ? _nv039961rm+0x10a/0x360 [nvidia]
2025-05-11T20:43:32.632554+02:00 rog kernel:  ? _nv033882rm+0xed/0x1f0 [nvidia]
2025-05-11T20:43:32.632555+02:00 rog kernel:  ? _nv033882rm+0xbd/0x1f0 [nvidia]
2025-05-11T20:43:32.632555+02:00 rog kernel:  ? _nv033850rm+0x6d8/0x11e0 [nvidia]
2025-05-11T20:43:32.632556+02:00 rog kernel:  ? _nv025507rm+0x147f/0x1f70 [nvidia]
2025-05-11T20:43:32.632556+02:00 rog kernel:  ? _nv013700rm+0x100/0x1f0 [nvidia]
2025-05-11T20:43:32.632556+02:00 rog kernel:  ? _nv038659rm+0x1e5/0x4a0 [nvidia]
2025-05-11T20:43:32.632556+02:00 rog kernel:  ? _nv038659rm+0x18f/0x4a0 [nvidia]
2025-05-11T20:43:32.632557+02:00 rog kernel:  ? _nv042572rm+0xb67/0xf00 [nvidia]
2025-05-11T20:43:32.632557+02:00 rog kernel:  ? _nv054948rm+0x28c/0x3a0 [nvidia]
2025-05-11T20:43:32.632557+02:00 rog kernel:  ? _nv052914rm+0xfd/0x160 [nvidia]
2025-05-11T20:43:32.632557+02:00 rog kernel:  ? _nv052912rm+0x5c/0x90 [nvidia]
2025-05-11T20:43:32.632558+02:00 rog kernel:  ? _nv052912rm+0x32/0x90 [nvidia]
2025-05-11T20:43:32.632558+02:00 rog kernel:  ? _nv013968rm+0x67/0xa0 [nvidia]
2025-05-11T20:43:32.632558+02:00 rog kernel:  ? _nv013968rm+0x28/0xa0 [nvidia]
2025-05-11T20:43:32.632558+02:00 rog kernel:  ? rm_kernel_rmapi_op+0x92/0x273 [nvidia]
2025-05-11T20:43:32.632559+02:00 rog kernel:  ? nvkms_call_rm+0x4c/0x90 [nvidia_modeset]
2025-05-11T20:43:32.632559+02:00 rog kernel:  ? _nv003139kms+0x4c/0x60 [nvidia_modeset]
2025-05-11T20:43:32.632559+02:00 rog kernel:  ? _nv000593kms+0xb4/0x110 [nvidia_modeset]
2025-05-11T20:43:32.632560+02:00 rog kernel:  ? _nv000593kms+0x8e/0x110 [nvidia_modeset]
2025-05-11T20:43:32.632560+02:00 rog kernel:  ? __memcg_slab_post_alloc_hook+0x247/0x3f0
2025-05-11T20:43:32.632560+02:00 rog kernel:  ? __nv_drm_gem_nvkms_map+0x82/0x100 [nvidia_drm]
2025-05-11T20:43:32.632561+02:00 rog kernel:  ? __nv_drm_gem_nvkms_mmap+0x17/0x40 [nvidia_drm]
2025-05-11T20:43:32.632561+02:00 rog kernel:  ? nv_drm_mmap+0xe3/0x190 [nvidia_drm]
2025-05-11T20:43:32.632561+02:00 rog kernel:  ? mmap_region+0x243/0xa60
2025-05-11T20:43:32.632562+02:00 rog kernel:  ? do_mmap+0x35b/0x620
2025-05-11T20:43:32.632562+02:00 rog kernel:  ? vm_mmap_pgoff+0xf0/0x1a0
2025-05-11T20:43:32.632562+02:00 rog kernel:  ? ksys_mmap_pgoff+0x17a/0x250
2025-05-11T20:43:32.632562+02:00 rog kernel:  ? __x64_sys_mmap+0x33/0x70
2025-05-11T20:43:32.632563+02:00 rog kernel:  ? x64_sys_call+0x1fa4/0x25f0
2025-05-11T20:43:32.632563+02:00 rog kernel:  ? do_syscall_64+0x7e/0x170
2025-05-11T20:43:32.632564+02:00 rog kernel:  ? __x64_sys_ioctl+0xbb/0xf0
2025-05-11T20:43:32.632564+02:00 rog kernel:  ? syscall_exit_to_user_mode+0x4e/0x250
2025-05-11T20:43:32.632564+02:00 rog kernel:  ? do_syscall_64+0x8a/0x170
2025-05-11T20:43:32.632564+02:00 rog kernel:  ? syscall_exit_to_user_mode+0x18d/0x250
2025-05-11T20:43:32.632565+02:00 rog kernel:  ? do_syscall_64+0x8a/0x170
2025-05-11T20:43:32.632565+02:00 rog kernel:  ? syscall_exit_to_user_mode+0x4e/0x250
2025-05-11T20:43:32.632565+02:00 rog kernel:  ? do_syscall_64+0x8a/0x170
2025-05-11T20:43:32.632565+02:00 rog kernel:  ? syscall_exit_to_user_mode+0x4e/0x250
2025-05-11T20:43:32.632566+02:00 rog kernel:  ? do_syscall_64+0x8a/0x170
2025-05-11T20:43:32.632566+02:00 rog kernel:  ? syscall_exit_to_user_mode+0x4e/0x250
2025-05-11T20:43:32.632567+02:00 rog kernel:  ? do_syscall_64+0x8a/0x170
2025-05-11T20:43:32.632567+02:00 rog kernel:  ? sysvec_apic_timer_interrupt+0x57/0xc0
2025-05-11T20:43:32.632567+02:00 rog kernel:  ? entry_SYSCALL_64_after_hwframe+0x76/0x7e
2025-05-11T20:43:32.632567+02:00 rog kernel:  </TASK>
2025-05-11T20:43:32.632568+02:00 rog kernel: OOM killer enabled.
2025-05-11T20:43:32.633928+02:00 rog kernel: Restarting tasks ... done.
2025-05-11T20:43:32.633934+02:00 rog kernel: random: crng reseeded on system resumption
2025-05-11T20:43:32.637052+02:00 rog systemd[1]: NetworkManager-dispatcher.service: Deactivated successfully.
2025-05-11T20:43:32.744538+02:00 rog bluetoothd[2011]: Controller resume with wake event 0x0
2025-05-11T20:43:32.744938+02:00 rog kernel: PM: suspend exit
2025-05-11T20:43:32.744945+02:00 rog kernel: PM: suspend entry (s2idle)
2025-05-11T20:43:32.746915+02:00 rog kernel: Filesystems sync: 0.001 seconds
2025-05-11T20:43:41.252742+02:00 rog kernel: Freezing user space processes
2025-05-11T20:43:41.252766+02:00 rog kernel: [drm:__nv_drm_gem_nvkms_map [nvidia_drm]] *ERROR* [nvidia-drm] [GPU ID 0x00000100] Failed to map NvKmsKapiMemory 0x00000000c777a63e
2025-05-11T20:43:41.252767+02:00 rog kernel: Freezing user space processes completed (elapsed 7.680 seconds)
2025-05-11T20:43:41.252768+02:00 rog kernel: OOM killer disabled.
2025-05-11T20:43:41.252769+02:00 rog kernel: Freezing remaining freezable tasks
2025-05-11T20:43:41.252770+02:00 rog kernel: Freezing remaining freezable tasks completed (elapsed 0.000 seconds)
2025-05-11T20:43:41.252771+02:00 rog kernel: printk: Suspending console(s) (use no_console_suspend to debug)
2025-05-11T20:43:41.252771+02:00 rog kernel: amdgpu 0000:0c:00.0: amdgpu: Power consumption will be higher as BIOS has not been configured for suspend-to-idle.
2025-05-11T20:43:41.252771+02:00 rog kernel: To use suspend-to-idle change the sleep mode in BIOS setup.
2025-05-11T20:43:41.252778+02:00 rog kernel: OOM killer enabled.
2025-05-11T20:43:41.252779+02:00 rog kernel: Restarting tasks ...

Also 535, 550 and 570 stable drivers are affected.
But interestingly the “New Feature Branch” 560.35.03 works well, so far no issue with suspend. Also reported on Suspend doesn't work when PreserveVideoMemoryAllocations is enabled · Issue #472 · NVIDIA/open-gpu-kernel-modules · GitHub

The issue persists even with the latest stable driver 580.82.07

As a workaround I created the shell script /usr/lib/systemd/system-sleep/gnome-nvidia-fix

#!/bin/bash

case "${1}" in
    pre)
        # Before suspend: pause gnome-shell to prevent it from interfering
        logger "gnome-nvidia-fix: Pausing gnome-shell before suspend"
        pkill -STOP gnome-shell
        sleep 1
        logger "gnome-nvidia-fix: gnome-shell paused"
        ;;
    post)
        # After resume: resume gnome-shell
        logger "gnome-nvidia-fix: Resuming gnome-shell after resume"
        pkill -CONT gnome-shell
        logger "gnome-nvidia-fix: gnome-shell resumed"
        ;;
esac

It helps when an issue with the nVidia driver occurs during a suspend. Then a suspending is slower, but it’s always finished successfully.

It’s working on Ubuntu 24.04

I am having the same error on Fedora 42, running `580.82.09`. For me however it doesn’t happen while suspending the OS, but when Brave browser has a video playback on a tab, specifically the Synology Surveillance Station client.

This is the dmesg:

[ 8865.620486] [drm:__nv_drm_gem_nvkms_map [nvidia_drm]] *ERROR* [nvidia-drm] [GPU ID 0x00000100] Failed to map NvKmsKapiMemory 0x00000000a859faf0
[ 8865.630849] traps: ThreadPoolForeg[51219] trap invalid opcode ip:55d253844016 sp:7ff11adfa160 error:0 in brave[b583016,55d24b6bd000+d6ff000]

Thank you, suspend hasn’t worked for me with any driver newer than 550.163.01, your script is the first workaround that actually works. Suspend is also faster than 550.163.01 without the script.

I’m on Rocky Linux 10 with a 4070 Ti Super.

Seems like I celebrated too soon, after several succesful suspend/resume operations I rebooted the machine and suspend is no longer succesful, gnome-shell is not stopped when the script runs:

Nov 16 14:23:07 north root[4848]: gnome-nvidia-fix: Pausing gnome-shell before suspend
Nov 16 14:23:33 north kernel: watchdog: BUG: soft lockup - CPU#1 stuck for 27s! [gnome-shell:3255]
[...]
Nov 16 14:25:17 north kernel: Freezing user space processes failed after 20.007 seconds (2 tasks refusing to freeze, wq_busy=0):
Nov 16 14:25:17 north kernel: task:gnome-shell     state:R  running task     stack:0     pid:3255  tgid:3255  ppid:2871   flags:0x0000400e
[...]
Nov 16 14:25:17 north kernel: task:pkill           state:D stack:0     pid:4849  tgid:4849  ppid:4846   flags:0x00000006
[...]
ov 16 14:25:17 north systemd-sleep[4843]: Failed to put system to sleep. System resumed again: Device or resource busy

There seems to be a timing problem between Gnome and the NVIDIA driver during suspend, this post explains the problem and has a solution based on systemd services that pause gnome-shell before suspend and unpauses it after resume.

I have implemented the solution and it looks promising, several suspend/resume operations still working after several reboots. I’ve been searching for a solution for this issue for a long time and I’m cautiously optimistic.

Interesting. For me when the event “Freezing user space processes failed after 20 seconds” happens, then the suspending is repeated (and again and again ..) and finally succeeds, I would say max 1 minute.
When suspending is without errors and it’s done within 5 secs on my station.

Good to see another solution that works for you.

The same here on Debian Sid with 580.105.08

lis 17 07:42:48 titan kernel: [drm:__nv_drm_gem_nvkms_map [nvidia_drm]] `*`ERROR`*` [nvidia-drm] [GPU ID 0x00000800] Failed to map NvKmsKapiMemory 0x0000000089c23a2c
lis 17 07:42:48 titan kernel: traps: Media[17810] trap invalid opcode ip:55d732c0f756 sp:7f92d4e93bd0 error:0 in brave[aaec756,55d72b18f000+d2cb000]

I can reproduce what appears to be the same issue on Ubuntu 24.04 with a Quadro P1000.

System:

  • Ubuntu 24.04
  • kernel 7.0.0-30-generic
  • NVIDIA driver 580.173.02
  • Quadro P1000 (Pascal)
  • GNOME on Wayland
  • two DisplayPort monitors
  • NVreg_PreserveVideoMemoryAllocations=1
  • nvidia-suspend.service / nvidia-resume.service enabled
  • suspend mode explicitly set to deep (s2idle [deep])

I previously had consistent resume failures with s2idle. Switching to deep fixed those: deep successfully completed suspend/resume both with GDM stopped and with a normal GNOME/Wayland session.

However, suspend is still intermittently failing before the system actually enters sleep. On the same boot with kernel 7.0.0-30, two deep suspend/resume cycles completed successfully, followed by one failed attempt.

During the failed attempt:

PM: suspend entry (deep)
Freezing user space processes failed after 20.005 seconds (1 tasks refusing to freeze)
task:gnome-shell

The gnome-shell stack is inside the NVIDIA DRM/NVKMS path:

nvkms_call_rm
__nv_drm_gem_nvkms_map
__nv_drm_gem_nvkms_mmap
nv_drm_mmap

Later the kernel reports:

INFO: task nvidia-sleep.sh ... blocked for more than 122 seconds
INFO: task nvidia-sleep.sh ... <writer> blocked on an rw-semaphore likely owned by task gnome-shell

followed by:

[nvidia-drm] Failed to map NvKmsKapiMemory
nvidia-modeset: WARNING: GPU:0: Lost display notification
nvidia-modeset: ERROR: GPU:0: Idling display engine timed out

systemd-suspend.service eventually fails because nvidia-sleep.sh cannot be terminated.

This therefore looks like a race/deadlock between GNOME Shell and the NVIDIA driver during suspend. deep fixes the separate s2idle resume problem on this machine, but does not prevent this intermittent pre-suspend GNOME/NVKMS freeze.

I can provide an nvidia-bug-report.log.gz and the complete journal from the failed attempt if useful.

You can try the driver 595. I helped me to fix this issue, see

Thanks for the suggestion. Unfortunately I cannot test driver 595 on this machine because the Quadro P1000 is a Pascal GPU, and NVIDIA 580 is the last driver branch supporting Pascal. So 595 is not an option for this system.

I did, however, test a workaround that directly targets the GNOME/NVIDIA suspend race.

I added two ordered systemd services that:

SIGSTOP gnome-shell
→ nvidia-suspend.service
→ systemd-suspend.service
→ nvidia-resume.service
→ SIGCONT gnome-shell

With kernel 7.0.0-30-generic, NVIDIA 580.173.02, GNOME Wayland and deep suspend, the first test completed successfully.

The journal showed:

Pausing gnome-shell before NVIDIA suspend
Starting nvidia-suspend.service
PM: suspend entry (deep)

Freezing user space processes completed (elapsed 0.003 seconds)
PM: suspend exit

Starting nvidia-resume.service
Finished nvidia-resume.service
Resuming gnome-shell after NVIDIA resume

There was no Freezing user space processes failed, no Failed to map NvKmsKapiMemory, and no display-engine timeout in that cycle.

The original problem is intermittent, so I’ll continue testing this workaround. If the underlying issue is fixed in 595, it would be very helpful if the relevant fix could also be backported to the 580 branch for Pascal users.

I am seeing the symptoms reported in the original post, on old hardware. For me the solution seems to be setting PreserveVideoMemoryAllocations to 0, in spite of much advice to the contrary. That change allowed the computer to suspend fully, but I’ve found that resume has required a few additional changes to /usr/bin/nvidia-sleep.sh.

Running driver 580.173.02 on an GeForce GTX 750 adapter in a 2014 Lenovo desktop. Driver was updated about two weeks ago from 535 and I’ve been struggling with suspend/resume ever since. The 535 driver worked fine in all ways except that it required the /usr/bin/nvidia-sleep.sh script to be bypassed by inserting exit 0 on the first non-comment line.