Skip to content

Restore hibernated sessions when the NVIDIA driver loads in the initramfs - #21042

Open
migbernsil wants to merge 3 commits into
omacom:quattrofrom
migbernsil:fix-nvidia-hibernation-resume
Open

migbernsil wants to merge 3 commits into
omacom:quattrofrom
migbernsil:fix-nvidia-hibernation-resume

Conversation

@migbernsil

@migbernsil migbernsil commented Dec 1, 2026 •

Copy link
Copy Markdown

What changes

On machines that load the NVIDIA driver in the initramfs (install/hardware/nvidia.sh), resuming from hibernation always fails. The boot kernel reads the whole image, then its freshly loaded NVIDIA driver refuses the device freeze that comes before the jump into the image, and the machine boots fresh, dropping the session:

PM: Image successfully loaded
NVRM: GPU 0000:01:00.0: PreserveVideoMemoryAllocations module parameter is set. System Power Management attempted without driver procfs suspend interface.
nvidia 0000:01:00.0: PM: pci_pm_freeze(): nv_pmops_freeze [nvidia] returns -5
PM: hibernation: Failed to load image, recovering.
PM: hibernation: resume failed (-5)

The cause is in the driver: nv_pm_notifier() in kernel-open/nvidia/nv.c handles PM_HIBERNATION_PREPARE but not PM_RESTORE_PREPARE, so on the restore path nothing prepares it (NVIDIA/open-gpu-kernel-modules#1343). The notifier is unchanged up to 620.73.04, the latest tag. Tracked here in #8352 and #10039.

This adds a busybox initramfs hook, omarchy-nvidia-resume, which a new drop-in, omarchy_resume_nvidia.conf, places immediately before resume when nvidia is in MODULES. When the swap at resume=/resume_offset= carries a hibernation signature, the hook stops the splash (omarchy-splash, or Plymouth on older images) and unloads nvidia_uvm, nvidia_drm, nvidia_modeset and nvidia, so nothing refuses the freeze. The restored kernel keeps its own driver, which was prepared when it hibernated. Without an image the hook does nothing, so early KMS and the unlock prompt on NVIDIA-wired displays stay as they are. If the image is not restored after all, the late hook loads the driver again.

Relation to #8263 and #16848 / #19328. Those stop early-loading NVIDIA on some hybrids. That fixes resume there, but not where the NVIDIA outputs are in use: laptops with DP/HDMI wired to the dGPU (as here), and NVIDIA-only desktops (#10039). #8263 also takes the unlock prompt off those outputs. This keeps early KMS and works alongside them, because the drop-in acts only while nvidia is still in MODULES.

No migration needed. The hook is an omarchy-* file in /etc/initcpio/ and the drop-in lives in mkinitcpio.conf.d/. omarchy-boot-sync-initcpio hashes both, so the settings upgrade rebuilds the image.

The unload-before-resume approach comes from michsob (NVIDIA #1343) and softerdk (#8352), who report repeated clean restores with it.

Verification

  • bash test/shell.d/mkinitcpio-hooks-test.sh: all 42 cases pass. I updated the existing "NVIDIA with hibernation" case to expect the hook before resume. It fails without the new drop-in and passes with it. The existing cases for NVIDIA without hibernation and hibernation without NVIDIA are unchanged and pass.
  • bash test/shell.d/boot-nvidia-resume-test.sh (new, 7 ok): runs the hook's own code with its sysfs, /run, /dev/kmsg and splash paths pointed into a fixture, and rmmod/modprobe recording their calls. A swap without an image keeps the driver. S1SUSPEND stops omarchy-splash directly, or asks Plymouth to --wait quit, then unloads the modules dependants first. A busy module gives up and reloads. The late hook reloads after a failed restore. noresume does nothing. Each check fails when the matching part of the hook is broken: the signature offset, the splash stop, the unload order, the late-hook reload and the give-up reload.
  • hibernation-setup-test.sh (13 ok), hibernation-available-test.sh (9 ok), boot-initcpio-sync-test.sh (11 ok).
  • Hook syntax checked with mkinitcpio's busybox (ash -n). The signature read was checked on synthetic swap headers: S1SUSPEND and ULSUSPEND unload the driver, SWAPSPACE2 does nothing.
  • Hardware: Dell Precision 7680 (Raptor Lake i915 driving eDP, RTX 2000 Ada with an external monitor on its outputs, tested over both USB-C DisplayPort and HDMI), Omarchy 4.5.0-3 (Plymouth), linux-omarchy 7.2.15, nvidia-open-dkms 615.78.08, LUKS + btrfs swapfile, Limine. Before: every resume booted fresh with the log above. With this hook (installed under another name on 4.5): the session was restored on all 7 hibernate/resume cycles, with hibernation entry and exit in the same boot and no Xid errors. Normal boots are unchanged, with the LUKS prompt still on the NVIDIA-wired monitor.
  • Separately, 2 of 9 hibernation attempts failed on the way in, before any image was complete, so this hook never ran for them. One rolled back on a wakeup event when the Thunderbolt USB controller failed to thaw, with the monitor on USB-C. One hung, which I could not reproduce in 4 pm_test=devices runs or in 3 more real cycles. Both happen on the hibernate side and are unrelated to this change.
  • Hardware, Omarchy 4.6 pre-release: same laptop, installed on a USB drive. It still boots with Plymouth. Without the hook, resume failed the same way. With it (installed under another name), the session was restored on all 4 hibernate/resume cycles.
  • Not checked on hardware: the omarchy-splash path on current quattro, which no release ships yet. There the hook calls /usr/lib/omarchy-splash/stop directly, because the splash's Plymouth stand-in answers only a bare quit. Also not checked: NVIDIA-only desktops, and systemd-boot.

Screenshots

No visible change: this is an initramfs hook. Boot and resume look the same, apart from a brief blank on NVIDIA outputs between unlock and the restored session.

Prepared with help from Claude Code; I tested it on my own machine as described above.

…amfs

The boot kernel's early-loaded NVIDIA driver refuses the freeze that comes
before jumping into a hibernation image (nv_pmops_freeze returns -5), because
its PM notifier ignores PM_RESTORE_PREPARE. Unload it right before resume when
the swap holds an image; boots without one keep early KMS.
@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; the previous page-size finding is fixed.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous page-size finding is fixed.

Summary

Adds omarchy-nvidia-resume before resume when NVIDIA loads early. It unloads NVIDIA only when a hibernation image is waiting and reloads it if the boot continues.

  • Hibernation restores can proceed without the early-loaded NVIDIA driver.

Reviews (3) · Last reviewed commit: "Build the NVIDIA resume test's swap fixt..." · Reviewed by Greptile

Run the hook's own code against a fixture: a swap without an image keeps
the driver; an image stops the splash and unloads the modules dependants
first; a busy module gives up and reloads; the late hook reloads after a
failed restore; noresume does nothing.
Comment thread test/shell.d/boot-nvidia-resume-test.sh Resolved
The hook reads the kernel's page size, so a fixture fixed at 4 KiB found no
image on 16 KiB (Apple Silicon) and 64 KiB (GB10) hosts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant