I found a working workaround for this issue on my system.

The suspend failure appears to involve `gnome-shell` being inside the
NVIDIA DRM/NVKMS path while userspace is being frozen. In the failed
case the kernel reported `gnome-shell` refusing to freeze, with a stack
involving:

```text
nvkms_call_rm [nvidia_modeset]
__nv_drm_gem_nvkms_map [nvidia_drm]
__nv_drm_gem_nvkms_mmap [nvidia_drm]
nv_drm_mmap [nvidia_drm]
```

I therefore added systemd services which explicitly stop GNOME Shell
before the NVIDIA suspend helper runs and continue it only after the
NVIDIA resume helper has completed.

The resulting ordering is:

```text
SIGSTOP gnome-shell
→ nvidia-suspend.service
→ systemd-suspend.service
→ suspend (deep)
→ nvidia-resume.service
→ wait 4 seconds
→ SIGCONT gnome-shell
```

The pre-suspend helper essentially does:

```bash
pkill -STOP -x gnome-shell
```

and the post-resume helper does:

```bash
sleep 4
pkill -CONT -x gnome-shell
```

with the systemd dependencies arranged so that the STOP happens before
`nvidia-suspend.service` and the CONT happens after `nvidia-
resume.service`.

With this workaround, suspend/resume completes successfully. In a
successful test the freezer completed almost immediately:

```text
Freezing user space processes completed (elapsed 0.003 seconds)
```

instead of timing out after 20 seconds with `gnome-shell` refusing to
freeze.

Initially I resumed GNOME Shell immediately after `nvidia-
resume.service`. Suspend worked, but all windows were moved to the
secondary/non-dynamic monitor and effectively ended up on workspace 1.

Adding a 2-second delay before SIGCONT improved this considerably, with
only one window being moved. With a 4-second delay, all windows remained
on their original monitors and dynamic workspaces after resume.

System:

* Ubuntu 24.04
* kernel 7.0.0-30-generic
* NVIDIA 580.173.02
* Quadro P1000 (Pascal)
* GNOME Wayland
* two DisplayPort monitors
* `NVreg_PreserveVideoMemoryAllocations=1`
* `mem_sleep_default=deep`

This is still a workaround rather than a proper fix, and the original
failure was intermittent, so I will continue testing it over additional
suspend/resume cycles.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2165319

Title:
  GNOME Shell intermittently refuses to freeze during suspend while
  blocked in NVIDIA NVKMS with nvidia-driver-580

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-580/+bug/2165319/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to