Hibernate never powers off: nv_pci_shutdown blocks forever in nvkms_ioctl_from_kapi (PM lock still write-held) after the image is written
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 12/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- c, linux
调研方向
The lock is taken in kernel-open/nvidia-modeset/nvidia-modeset-linux.c, in nvkms_ioctl_from_kapi() and nvkms_suspend()/nvkms_resume(); the teardown runs through nv_pci_shutdown() and nv_drm_remove() in the nvidia and nvidia-drm kernel modules. Start by reading those functions and the PM notifier handling, then reproduce with hibernate and HibernateMode=shutdown. Done would mean hibernate powers off without the workaround, which needs maintainer-level design on the PM lock.
由索引模型根据 Issue 内容生成。
描述
NVIDIA Open GPU Kernel Modules Version
620.73.04 (prebuilt package linux-cachyos-nvidia-open 7.3.5-2, nvidia-utils 620.73.04-1)
Please confirm this issue does not happen with the proprietary driver (of the same version). This issue tracker is only for bugs specific to the open kernel driver.
- I confirm that this does not happen with the proprietary driver package.
Operating System and Version
CachyOS (Arch-based), KDE Plasma 6.8.3 on Wayland (KWin), systemd 262.2
Kernel Release
7.3.5-2-cachyos (clang 23.1.5, PREEMPT(full))
Please confirm you are running a stable release kernel (e.g. not a -rc). We do not accept bug reports for unreleased kernels.
- I am running on a stable kernel release.
Hardware: GPU
NVIDIA GeForce RTX 4060 Laptop GPU in an ASUS ROG Zephyrus G16 GA605WV (BIOS GA605WV.316, 07/24/2025), AMD integrated GPU also present. Display mux set to dGPU-direct: the internal panel and the HDMI port are both driven by the NVIDIA GPU. The same hang was seen earlier in hybrid (mux on the iGPU) mode.
Describe the bug
systemctl hibernate writes a complete, restorable image, and then the machine never powers off: screen
dark, fans and power LED on, until a forced power-off. On the next start the session resumes from the
image normally.
The task that performs the power-off is blocked inside the NVIDIA PCI shutdown callback:
nvidia 0000:65:00.0: shutdown
[drm] [nvidia-drm] [GPU ID 0x00006500] Removing device
Console: switching to colour dummy device 160x50
... 229 seconds without any further message ...
task:systemd-sleep state:D stack:0 pid:6507 tgid:6507 ppid:1 task_flags:0x80408100 flags:0x00080801
Call Trace:
<TASK>
__schedule+0x712/0x22a0
schedule+0x56/0x140
schedule_preempt_disabled+0x16/0x30
rwsem_down_read_slowpath+0x150/0x3f0
down_read+0x99/0xa0
nvkms_ioctl_from_kapi+0x6f/0xd0 [nvidia_modeset]
DestroySurface+0x48/0x60 [nvidia_modeset]
nv_drm_framebuffer_destroy+0x3c/0xf0 [nvidia_drm]
drm_mode_rmfb+0x1d3/0x2a0
drm_client_buffer_delete+0x3c/0xb0
drm_fbdev_ttm_fb_destroy+0x3f/0x7f0 [drm_ttm_helper]
unregister_framebuffer+0x109/0x110
drm_client_dev_unregister+0xaf/0xd0
drm_dev_unregister+0x28/0x1d0
drm_dev_unplug+0x25/0x40
nv_drm_remove+0x98/0xb0 [nvidia_drm]
nv_pci_remove_helper+0x77/0x480 [nvidia]
nv_pci_shutdown+0x4e/0x80 [nvidia]
pci_device_shutdown+0x3a/0x70
device_shutdown+0x178/0x220
kernel_power_off+0x36/0xe0
hibernate+0x3f4/0x4d0
state_store+0xeb/0x120
kernfs_fop_write_iter+0x107/0x190
__x64_sys_write+0x24d/0x450
do_syscall_64+0x93/0x3a0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
</TASK>
How the trace was obtained: initcall_debug=1 (so each driver logs "shutdown" before its callback), plus a
small debug module of my own that, 240 s after the hibernate request, prints the stack of systemd-sleep
(the task inside hibernate()) and panics, so that efi-pstore keeps the kernel log of the phase after the
snapshot. Nothing from that phase reaches the journal otherwise.
Reading of the cause
nvkms_ioctl_from_kapi()takesnvkms_pm_lockfor reading (nvkms_read_lock_pm_lock()), without a
timeout.nvkms_suspend()takes the same lock for writing and returns holding it; onlynvkms_resume()
releases it (kernel-open/nvidia-modeset/nvidia-modeset-linux.c, read frommainat 620.73.04).- With
NVreg_UseKernelSuspendNotifiers=1the driver is told about the hibernate before the snapshot and,
as far as I can tell, is only told to resume atPM_POST_HIBERNATION. The kernel sends that notification
afterhibernate()is done, but the power-off (power_down()->kernel_power_off()->
device_shutdown()) happens insidehibernate(). So the write lock is still held when
nv_pci_shutdown()runs. nv_pci_shutdown()->nv_pci_remove_helper()->nv_drm_remove()unplugs the DRM device. With
nvidia-drm fbdev=1that destroys the fbdev emulation framebuffer, which calls back into nvidia-modeset
throughnvkms_ioctl_from_kapi()and waits for the read lock. Nothing will ever release the write lock,
so the power-off never completes.- An ordinary shutdown or reboot is not affected: the PM lock is free there, and the same teardown finishes.
The same file already has nvkms_ioctl_from_kapi_try_pmlock() with the comment "PM lock must be allowed to
fail, see bug 4432810", which looks like the same class of problem on another path.
To Reproduce
- NVIDIA open modules 620.73.04,
nvidia-drm modeset=1 fbdev=1, a Wayland compositor running on the
NVIDIA GPU (or merely holding it open, as in hybrid mode). NVreg_UseKernelSuspendNotifiers=1,NVreg_PreserveVideoMemoryAllocations=2,
NVreg_EnableS0ixPowerManagement=1; thenvidia-suspend/hibernate/resumeservices disabled.- systemd
HibernateMode=shutdown(so/sys/power/disk=shutdown), swap file with a validresume=setup. systemctl hibernate.
Result: image written ("PM: Image saving done"), then no power-off. The same happens with
/sys/power/disk = reboot: no restart. (platform is not usable on this laptop for an unrelated
reason.) The staged kernel tests all pass on the same setup: pm_test = freezer, devices, platform,
processors, core, and test_resume (image written, read back and restored).
Bug Incidence
Always. Without the workaround below: 3 of 3 (shutdown twice, reboot once), each ending in a forced
power-off or the debug panic. Same symptom on this laptop since driver 610 (July 2026) and with 615.71.09
(September 2026, kernels 7.2.7 and 6.18 LTS), there without a captured stack.
Workaround that confirms the diagnosis
If the PCI core does not call nv_pci_shutdown() during the hibernate's power-off, everything works. I
use a small out-of-tree module that sets the shutdown pointer of the nvidia PCI driver to NULL at
PM_HIBERNATION_PREPARE and restores it at PM_POST_HIBERNATION:
static int nvhibfix_pm(struct notifier_block *nb, unsigned long action, void *data)
{
if (action == PM_HIBERNATION_PREPARE)
nvhibfix_skip(); /* save drv->shutdown, set it to NULL, hold a module reference */
else if (action == PM_POST_HIBERNATION)
nvhibfix_restore(); /* put the pointer back, drop the reference */
return NOTIFY_OK;
}
With it: 7 of 7 real hibernates powered off and restored the session (AC with an HDMI monitor, battery,
internal panel only, and by closing the lid). The kernel log of the power-off then reads:
nvhibfix: hibernate: skipping nv_pci_shutdown [nvidia] at power-off
PM: Image saving done
nvidia 0000:65:00.0: shutdown
ACPI: PM: Preparing to enter system sleep state S5
reboot: Power down
That is about 4 seconds from "Image saving done" to "Power down", against no power-off at all without it.
Possible directions for a fix
- In
nv_pci_shutdown()(ornv_pci_remove_helper(pci_dev, false)), do not tear down DRM and modeset
state while the system PM state is "hibernate"; the machine is about to lose power anyway. - Or make the teardown paths reached from shutdown use the try-lock variant and skip on failure.
Related reports
- Same hang on a ROG Zephyrus G16 GU605CR with nvidia-open 610.57, stack ending in
nv_pci_shutdown -> nv_drm_dev_unloadand an nvkms lock wait;fbdev=0did not help there, which fits
the reading above (the next nvkms call in the same teardown blocks instead):
https://forums.developer.nvidia.com/t/hibernate-never-powers-off-stuck-in-nv-pci-shutdown-nv-drm-dev-unload-rtx-5070-laptop-nvidia-open-610-57/382485 - "Hibernate (S4) no longer powers off, fans stay on, resume still works", from 580.105.08 on, with later
reports for 590, 595, 610 and 620:
https://forums.developer.nvidia.com/t/580-105-08-regression-hibernate-s4-no-longer-powers-off-fans-stay-on-resume-still-works/351504
Bug Incidence
Always
nvidia-bug-report.log.gz
nvidia-bug-report.redacted.log.gz
More Info
I can provide the complete pstore dump of the hung power-off (about 29 KB of kernel log, including every driver's "shutdown" line up to the hang), the dump of a successful power-off with the workaround, the source of both small modules, and I can test a patch.
- 主要语言
- C
- 星标
- 17.7k
- 派生
- 2k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NVIDIA/open-gpu-kernel-modules 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
NVIDIA/open-gpu-kernel-modules#1635 ·
维护者通常 1 天内回复
-
nvidia-drm: NULL dereference in nv_drm_create_sync_file() when sync_file_create() fails (kernel oops when fs.file-max is exhausted)可能重新可做 关联的 PR 已关闭且未合并。 未关闭bug
难度 2/5 1-3 小时 新手友好度 82/100
NVIDIA/open-gpu-kernel-modules#1601 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
NVIDIA/open-gpu-kernel-modules#1479 · 2 条评论 ·
维护者通常 1 天内回复
-
PlatformRequestHandler: missing !bInit guard on bSystemParamLimitUpdate causes NV_ERR_INVALID_DATA at boot可能已有人在做 @SammyTourani 于 69 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
NVIDIA/open-gpu-kernel-modules#1360 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
NVIDIA/open-gpu-kernel-modules#1343 · 3 条评论 ·
维护者通常 1 天内回复
查看 NVIDIA/open-gpu-kernel-modules 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
Jstar269/nakagawa-recomp#3753 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100
ly05010419/MacNativeGames#2474 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
Life-Framework/Life-Framework#7017 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
gjrtimmer/jetson-nvmpi#170 ·