Repository navigation
Restore hibernated sessions when the NVIDIA driver loads in the initramfs - #21042
Open
migbernsil wants to merge 3 commits into
Open
migbernsil wants to merge 3 commits into
migbernsil wants to merge 3 commits into
Conversation
…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.
Contributor
[Medium impact] The PR appears safe to merge; the previous page-size finding is fixed. SummaryAdds
Reviews (3) · Last reviewed commit: "Build the NVIDIA resume test's swap fixt..." · Reviewed by Greptile |
This was referenced Dec 1, 2026
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:The cause is in the driver:
nv_pm_notifier()inkernel-open/nvidia/nv.chandlesPM_HIBERNATION_PREPAREbut notPM_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 beforeresumewhennvidiais inMODULES. When the swap atresume=/resume_offset=carries a hibernation signature, the hook stops the splash (omarchy-splash, or Plymouth on older images) and unloadsnvidia_uvm,nvidia_drm,nvidia_modesetandnvidia, 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
nvidiais still inMODULES.No migration needed. The hook is an
omarchy-*file in/etc/initcpio/and the drop-in lives inmkinitcpio.conf.d/.omarchy-boot-sync-initcpiohashes 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 beforeresume. 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/kmsgand splash paths pointed into a fixture, andrmmod/modproberecording their calls. A swap without an image keeps the driver.S1SUSPENDstops 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.noresumedoes 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).ash -n). The signature read was checked on synthetic swap headers:S1SUSPENDandULSUSPENDunload the driver,SWAPSPACE2does nothing.pm_test=devicesruns or in 3 more real cycles. Both happen on the hibernate side and are unrelated to this change.quattro, which no release ships yet. There the hook calls/usr/lib/omarchy-splash/stopdirectly, because the splash's Plymouth stand-in answers only a barequit. 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.