Skip to content

nvidia: skip teardown in nv_pci_shutdown() while GPU is hibernate-suspended (fixes no power-off after hibernation) - #1412

Open
expaso wants to merge 1 commit into
NVIDIA:mainfrom
expaso:fix-hibernate-poweroff-hang
Open

expaso wants to merge 1 commit into
NVIDIA:mainfrom
expaso:fix-hibernate-poweroff-hang

Conversation

@expaso

@expaso expaso commented Oct 1, 2026

Copy link
Copy Markdown

Problem

With the documented hibernation setup (NVreg_PreserveVideoMemoryAllocations=1 + nvidia-hibernate.service), the system never powers off after the hibernation image has been written. The image is complete (resume works after a forced power-off), but the machine sits there with the last console line:

[nvidia-drm] Unloading driver

Reproduced every time on 610.57.04 and 615.71.09 with HibernateMode=shutdown (/sys/power/disk = shutdown). reboot mode and a failed ACPI S4 entry in platform mode go through the same kernel_power_off()/device_shutdown() path.

Root cause

  1. nvidia-sleep.sh hibernate writes to /proc/driver/nvidia/suspend → nv_set_system_power_state() takes nv_system_pm_lock for write and suspends the GPU (NV_FLAG_SUSPENDED).
  2. The kernel freezes devices (nv_pmops_freeze), takes the snapshot and thaws devices to write the image. nv_pmops_thaw() is a no-op, so the GPU stays suspended and nv_system_pm_lock stays write-locked for the rest of the hibernation.
  3. After the image is written, kernel_power_off() → device_shutdown() → nv_pci_shutdown() → nv_pci_remove_helper() → nvidia_modeset_remove() → nvidia-drm unload: a full driver teardown against a suspended GPU, which never completes.

Fix

In nv_pci_shutdown(), if the device is still NV_FLAG_SUSPENDED, only clear bus mastering and return. The machine is about to lose power and the GPU state was already saved by the suspend path, so the teardown is neither needed nor possible. Normal shutdown/reboot are unaffected (the flag is not set then).

Testing

  • ASUS ROG Zephyrus G16 (GU605CW), RTX 5080 Laptop GPU (GB203), hybrid with Intel iGPU
  • Open kernel modules 615.71.09, Linux 7.3-rc5, Ubuntu 26.04, HibernateMode=shutdown
  • Before: hang at "Unloading driver" on every hibernation (also with 610.57.04)
  • After: powers off right after the image is written; resume works; normal shutdown/reboot unchanged

…pended

With the documented hibernation setup (NVreg_PreserveVideoMemoryAllocations=1
plus nvidia-hibernate.service), the system hangs after the hibernation image
has been written and never powers off. The last console line is
"[nvidia-drm] Unloading driver".

Sequence:
  1. nvidia-sleep.sh writes "hibernate" to /proc/driver/nvidia/suspend:
     nv_set_system_power_state() takes nv_system_pm_lock for write and
     suspends the GPU (NV_FLAG_SUSPENDED).
  2. The kernel freezes devices (nv_pmops_freeze), creates the snapshot and
     thaws devices to write the image. nv_pmops_thaw() is a no-op, so the GPU
     stays suspended and nv_system_pm_lock stays write-locked.
  3. After the image is written, HibernateMode=shutdown (or reboot, or a
     failed ACPI S4 entry) calls kernel_power_off() -> device_shutdown() ->
     nv_pci_shutdown() -> nv_pci_remove_helper() -> nvidia_modeset_remove()
     -> nv-drm unload, i.e. a full driver teardown against a suspended GPU.
     This never completes.

The machine is about to lose power and the GPU state was already saved by
the suspend path, so a teardown is neither needed nor possible here. When
the device is still NV_FLAG_SUSPENDED, only clear bus mastering and return.
Normal shutdown and reboot are unaffected because the flag is not set then.

Tested on an RTX 5080 Laptop GPU (GB203, ASUS GU605CW) with 615.71.09 and
Linux 7.3-rc5: before, hibernation hung at "Unloading driver" every time
(also with 610.57.04); after, the system powers off right after the image is
written and resumes normally.

Signed-off-by: Hans van Essen <hans@expaso.nl>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

2 participants