omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

NVIDIA hybrid GPU: kernel crashes on lid close with s2idle default sleep

Open Arzamendiaariel opened this issue 7 months ago • 8 comments

System details

ASUS laptop with hybrid GPU (Intel iGPU + NVIDIA dGPU), Omarchy on kernel 6.19.10-arch1-1, Hyprland, supergfxctl in Hybrid mode.

What's wrong?

Closing the laptop lid triggers suspend, but the system crashes or enters a broken state. On the following boot, the journal is full of NVIDIA assertion failures:

NVRM: GPU0 nvAssertOkFailedNoLog: Assertion failed: Generic Error: Invalid state [NV_ERR_INVALID_STATE] (0x00000040)
  returned from mmuWalkUnmap(userCtx.pGpuState->pWalk, vaLo, vaHi) @ gpu_vaspace.c:2084

This repeats dozens of times in the previous boot's kernel log (journalctl -b -1 -k).

Root cause

The kernel defaults to s2idle (S0ix / Low-power S0 idle) instead of deep (S3) sleep:

$ cat /sys/power/mem_sleep
[s2idle] deep

s2idle keeps power to devices and relies on firmware and drivers to manage their own low-power states. The NVIDIA driver does not handle this reliably in Hybrid mode — it fails to properly save/restore GPU VA space mappings (mmuWalkUnmap assertion), leading to a crash or compositor freeze on resume.

The existing /usr/lib/systemd/system-sleep/nvidia script handles the resume path (nvidia-sleep.sh resume) but doesn't address the fundamental s2idle incompatibility.

Additionally, the 10-nvidia-no-freeze-session.conf drop-in from nvidia-utils disables user session freezing during suspend (SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=false), which compounds the issue as Wayland clients continue running while the GPU is being suspended — related to #4891.

Note on force-igpu sleep script

The force-igpu script in default/systemd/system-sleep/ is designed for Integrated mode only (installed by omarchy-toggle-hybrid-gpu when switching to Integrated, removed when switching to Hybrid). It should not be manually installed for Hybrid mode — it would forcibly switch the GPU to Integrated after every wake.

Possible fix

Adding mem_sleep_default=deep to kernel parameters forces S3 deep sleep instead of s2idle, which gives the NVIDIA driver a clean power-off/power-on cycle. This is more reliable for hybrid GPU laptops.

For systemd-boot:

# Add to kernel cmdline in boot entry
mem_sleep_default=deep

After applying:

$ cat /sys/power/mem_sleep
s2idle [deep]

Omarchy could detect NVIDIA hybrid GPU setups and default to deep sleep, or document this as a recommended configuration for affected hardware.

Arzamendiaariel avatar Apr 10 '26 20:04 Arzamendiaariel

similar issue on Asus with a ryzen 7 700 series no integrated GPU just a Dedicated GPU. On lid close or suspend when the lid is opened the keyboard lighting is on but the screen is black only way to recover is to do a hard reset (long pressing the power button)

EMMD474 avatar Apr 11 '26 16:04 EMMD474

same on lenovo legion 7, 4060, i7-14700HX

Neliq avatar Apr 12 '26 13:04 Neliq

Adding mem_sleep_default=deep to kernel parameters forces S3 deep sleep instead of s2idle, which gives the NVIDIA driver a clean power-off/power-on cycle. This is more reliable for hybrid GPU laptops.

Please do explore this fix in a PR 👍

dhh avatar Apr 15 '26 09:04 dhh

Counter-data-point: this reproduces on deep (S3) sleep, so mem_sleep_default=deep is not a sufficient fix.

My laptop already defaults to deep — not via any kernel parameter, it's just the firmware/kernel default here:

$ cat /sys/power/mem_sleep
s2idle [deep]

$ grep -o 'mem_sleep_default=[a-z]*' /proc/cmdline
(nothing — not set)

And the freeze still happens, in genuine S3:

2026-07-27T20:28:43 systemd-sleep: User sessions remain unfrozen on explicit request ($SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=0).
2026-07-27T20:28:43 systemd-sleep: Performing sleep operation 'suspend'...
2026-07-27T20:28:43 kernel: PM: suspend entry (deep)
2026-07-27T21:53:27 kernel: ACPI: PM: Preparing to enter system sleep state S3
2026-07-27T21:53:27 kernel: ACPI: PM: Waking up from system sleep state S3
2026-07-27T21:53:27 kernel: [drm:__nv_drm_semsurf_wait_fence_work_cb [nvidia_drm]] *ERROR* [nvidia-drm] [GPU ID 0x00000100] Failed to register auto-value-update on pre-wait value for sync FD semaphore surface

Screen held a stale frame, no input accepted, kernel still alive underneath (it kept logging firewall packets for another 90s). Hard power-off was the only recovery — the journal ends mid-stream with no shutdown sequence at all.

The signature correlates 2-for-2 with hard power-offs

__nv_drm_semsurf_wait_fence_work_cb appears exactly twice in my entire journal history, and both times it landed in the same second as a resume from S3, and both of those boots ended in an unclean power-off:

semsurf error Suspend type How that boot ended
2026-06-28 21:18:09 deep (S3), after 7h34m suspended abrupt — no shutdown sequence
2026-07-27 21:53:27 deep (S3), after 1h24m suspended abrupt — no shutdown sequence

Both suspends logged SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=0 beforehand. Two for two, no false positives, no occurrences on any boot that shut down cleanly.

Triage note: osapi.c:2103 is a red herring

Worth flagging for anyone else digging through logs here — NVRM: nvAssertFailedNoLog: Assertion failed: 0 @ osapi.c:2103 also fires at boot time on my system, at 18:53:52, which is 1h35m before the suspend and while everything was working normally. It appears 4× across the freeze boot and is easy to mistake for the cause. The fence error above is the one that actually discriminates.

My failure mode is also distinct from the mmuWalkUnmap / NV_ERR_INVALID_STATE assertion in the original report — different code path, same outcome.

Why I think this points at #4891 rather than sleep-state selection

Since deep S3 gives the driver a real power-off/power-on cycle and it still fails, the s2idle explanation doesn't cover my case. The 10-nvidia-no-freeze-session.conf drop-in shipping SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=false looks like the better fit: with sessions unfrozen, Wayland clients keep submitting while the GPU is torn down, and the compositor ends up blocked on a fence that never signals — which is exactly what __nv_drm_semsurf_wait_fence_work_cb failing to register a pre-wait value describes.

Also relevant: systemd's own warning on that path explicitly calls out "setups with encrypted home directories", and my root is LUKS. That may be part of why some users see this and others don't.

I have not tried overriding SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=true myself, and I note #4891's reporter says doing so did not resolve it for them.

Environment

  • Omarchy: 3.8.4
  • Kernel: 7.1.4-arch1-1
  • Hyprland: 0.56.0
  • NVIDIA: nvidia-open-dkms 610.43.03
  • Laptop: ASUS TUF Gaming FX505GT
  • iGPU: Intel UHD Graphics 630 (CoffeeLake-H GT2) [8086:3e9b] — drives the eDP panel
  • dGPU: NVIDIA GTX 1650 Mobile / Max-Q (TU117M) [10de:1f91]
  • Root: LUKS-encrypted btrfs
  • Sleep: deep (S3), firmware default
  • NVreg_PreserveVideoMemoryAllocations=1 was already active during both freezes (set by /usr/lib/modprobe.d/gsr-nvidia.conf), as was NVreg_UseKernelSuspendNotifiers=1 and NVreg_TemporaryFilePath=/var/tmp (from /usr/lib/modprobe.d/nvidia-sleep.conf). So VRAM preservation is not the missing piece either.

ki11e6 avatar Jul 27 '26 17:07 ki11e6

@Arzamendiaariel do you want to test the fix I proposed in #8546? it's a one-line config change you can make yourself, i am not seeing the issue any longer on my box.

nhodges avatar Aug 28 '26 06:08 nhodges

Reproduced a hard freeze on suspend here. Not lid-close; systemctl suspend. mem_sleep is s2idle [deep]; the kernel then logged PM: suspend entry (deep).

MSI GS70 2QE, Haswell iGPU 8086:0416 + GTX 970M 10de:13d8, nvidia-580xx 580.178.04, Omarchy 4.0.1-1, kernel 7.1.9-arch1-2. NVreg_PreserveVideoMemoryAllocations=1 is set. nvidia-suspend.service / nvidia-resume.service / nvidia-hibernate.service were already enabled. Steam was mid first-run update.

nvidia-sleep.sh suspend oopsed in proprietary UVM:

BUG: kernel NULL pointer dereference, address: 0000000000000000
Oops: 0000 [#1] SMP PTI
CPU: 3 UID: 0 PID: 615985 Comm: nvidia-sleep.sh Tainted: P OE
RIP: 0010:_raw_q_schedule+0x2f/0xb0 [nvidia_uvm]
Call Trace:
  nv_kthread_q_flush
  uvm_suspend
  uvm_suspend_entry
  nv_uvm_suspend
  nv_set_system_power_state
  nv_procfs_write_suspend
note: nvidia-sleep.sh exited with irqs disabled
note: nvidia-sleep.sh exited with preempt_count 1
PM: suspend entry (deep)

Machine did not come back; hard reboot. Will not retest sleep on this box.

Related: #8126 (PreserveVideoMemoryAllocations + 580xx). Enabling the sleep units was not enough here.

  • atavacron, Grok 4.6 (high)

atavacron avatar Aug 28 '26 14:08 atavacron

A fix for (at least one mechanism of) this is now under test with three confirmations: PR #8546 sets NVreg_EnableS0ixPowerManagement=1 on systems whose active sleep mode is s2idle.

Diagnosed cause on the original machine: with NVreg_PreserveVideoMemoryAllocations active (which it effectively is distro-wide — nvidia-utils ships UseKernelSuspendNotifiers=1 and the preserve default is AUTO, so removing gpu-screen-recorder does not help), suspend has the driver talk to the GSP of a runtime-suspended dGPU, and the GSP intermittently stops answering (Xid 119 from systemd-sleep). The suspend wedges half-entered: lid closed, never in low power, overheats, drains, hard power-off. An iGPU is not required — one confirmed machine is dGPU-only.

Results so far: RTX 3080 Ti hybrid (2 wedges in 2 days before → 5/5 clean over 12 days after, incl. a 45-min closure), GeForce 930M (confirmed working), RTX 2050 dGPU-only (0 clean / 6 hangs over 16 weeks before → 24/24 clean after — on a machine where deep is not offered in mem_sleep at all, so the mem_sleep_default=deep workaround discussed above was never available to it).

To test without the PR:

sudo tee /etc/modprobe.d/nvidia-s0ix.conf <<< 'options nvidia NVreg_EnableS0ixPowerManagement=1'
sudo limine-mkinitcpio

then reboot and run lid-close cycles. Triage tip when checking your journal: the reliable signature is a PM: suspend entry (s2idle) with no matching PM: suspend exit on a boot ending in a hard power-off. Xid 119 corroborates when present, but journald often never flushes it before the power cut — its absence rules nothing out.

This does not claim the deep-S3 resume freeze @ki11e6 documented above — different phase, different signature, and the PR's s2idle gate deliberately leaves S3 machines untouched. Reports either way on #8546 would be very welcome.

Filed by Claude Fable 5 via Claude Code.

nhodges avatar Sep 09 '26 19:09 nhodges

Triage of this issue against quattro at 902fd8a. It was read by Claude Opus 5.5 and independently by Codex Medium; both reached the same conclusion, and since the second reviewer can read this session's notes, that agreement is not guaranteed to be independent.

Not fixed on quattro yet. install/hardware/nvidia.sh sets only nvidia_drm modeset=1 and early-loads the modules. Nothing in migrations/, default/systemd/ or bin/ sets an NVIDIA S0ix option or mem_sleep_default=deep for NVIDIA machines; the only mem_sleep_default=deep in the tree is the T2 Mac fix.

Not a duplicate. #4200 (black screen on resume, preserve-VRAM proposal) and #4891 (compositor freeze with session freezing disabled) are nearby, but neither one has the same cause and fix as the s2idle suspend failure reported here.

#8546 addresses one mechanism, not the whole issue. It sets NVreg_EnableS0ixPowerManagement=1 on machines whose active sleep mode is s2idle, which covers the wedged-suspend path with GSP timeouts (Xid 119) described above. By design it leaves deep S3 machines alone. That means it does not cover the S3 resume freeze @ki11e6 reported (__nv_drm_semsurf_wait_fence_work_cb) or the nvidia_uvm NULL dereference in nvidia-sleep.sh suspend @atavacron hit under S3. So #8546 references this issue rather than closing it. That seems right, and I have not linked it as a fix.

Not reproduced. Omabot's test machines are virtual and have no NVIDIA GPU, so these driver failures can't be reproduced there. Confirming a fix needs before-and-after lid-close cycles on affected hardware. The most useful reports go on #8546 and include cat /sys/power/mem_sleep, the driver version, and whether every PM: suspend entry in journalctl -k has a matching PM: suspend exit.

Next step: the maintainer decides on #8546. The S3 failures in the comments are likely a separate bug.

omarchybot avatar Oct 08 '26 00:10 omarchybot