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,579 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
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 の本文から書いたものです。

説明

bug
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() takes nvkms_pm_lock for reading (nvkms_read_lock_pm_lock()), without a
    timeout. nvkms_suspend() takes the same lock for writing and returns holding it; only nvkms_resume()
    releases it (kernel-open/nvidia-modeset/nvidia-modeset-linux.c, read from main at 620.73.04).
  • With NVreg_UseKernelSuspendNotifiers=1 the driver is told about the hibernate before the snapshot and,
    as far as I can tell, is only told to resume at PM_POST_HIBERNATION. The kernel sends that notification
    after hibernate() is done, but the power-off (power_down() -> kernel_power_off() ->
    device_shutdown()) happens inside hibernate(). 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=1 that destroys the fbdev emulation framebuffer, which calls back into nvidia-modeset
    through nvkms_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
  1. 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).
  2. NVreg_UseKernelSuspendNotifiers=1, NVreg_PreserveVideoMemoryAllocations=2,
    NVreg_EnableS0ixPowerManagement=1; the nvidia-suspend/hibernate/resume services disabled.
  3. systemd HibernateMode=shutdown (so /sys/power/disk = shutdown), swap file with a valid resume= setup.
  4. 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() (or nv_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

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.

hung-poweroff-kernel-log.txt

主要言語
C
スター
17.7k
フォーク
2k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NVIDIA/open-gpu-kernel-modules のほかの issue

NVIDIA/open-gpu-kernel-modules の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。