* [PATCH v2] nouveau: pci: quiesce GPU on shutdown
@ 2026-01-21 11:36 Li Chen
2026-02-09 20:17 ` Dave Airlie
0 siblings, 1 reply; 2+ messages in thread
From: Li Chen @ 2026-01-21 11:36 UTC (permalink / raw)
To: Dave Airlie, Lyude Paul, Danilo Krummrich, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
dri-devel, nouveau, linux-kernel
Cc: Li Chen
Kexec reboot does not reset PCI devices.
Invoking the full DRM/TTM teardown from ->shutdown can trigger WARNs when
userspace still holds DRM file descriptors.
Quiesce the GPU through the suspend path and then power down the PCI
function so the next kernel can re-initialize the device from a consistent
state.
WARNING: drivers/gpu/drm/drm_mode_config.c:578 at drm_mode_config_cleanup+0x2e7/0x300, CPU#2: kexec/1300
Call Trace:
<TASK>
? srso_return_thunk+0x5/0x5f
? enable_work+0x3a/0x100
nouveau_display_destroy+0x39/0x70 [nouveau c19e0da7fd83583a023f855c510d9a3903808734]
nouveau_drm_device_fini+0x7b/0x1f0 [nouveau c19e0da7fd83583a023f855c510d9a3903808734]
nouveau_drm_shutdown+0x52/0xc0 [nouveau c19e0da7fd83583a023f855c510d9a3903808734]
pci_device_shutdown+0x35/0x60
device_shutdown+0x11c/0x1b0
kernel_kexec+0x13a/0x160
__do_sys_reboot+0x209/0x240
do_syscall_64+0x81/0x610
? srso_return_thunk+0x5/0x5f
? __rtnl_unlock+0x37/0x70
? srso_return_thunk+0x5/0x5f
? netdev_run_todo+0x63/0x570
? netif_change_flags+0x54/0x70
? srso_return_thunk+0x5/0x5f
? devinet_ioctl+0x1e5/0x790
? srso_return_thunk+0x5/0x5f
? inet_ioctl+0x1e9/0x200
? srso_return_thunk+0x5/0x5f
? srso_return_thunk+0x5/0x5f
? sock_do_ioctl+0x7d/0x130
? srso_return_thunk+0x5/0x5f
? __x64_sys_ioctl+0x97/0xe0
? srso_return_thunk+0x5/0x5f
? srso_return_thunk+0x5/0x5f
? do_syscall_64+0x23b/0x610
? srso_return_thunk+0x5/0x5f
? put_user_ifreq+0x7a/0x90
? srso_return_thunk+0x5/0x5f
? sock_do_ioctl+0x107/0x130
? srso_return_thunk+0x5/0x5f
? __x64_sys_ioctl+0x97/0xe0
? srso_return_thunk+0x5/0x5f
? do_syscall_64+0x81/0x610
? srso_return_thunk+0x5/0x5f
? exc_page_fault+0x7e/0x1a0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
nouveau 0000:26:00.0: [drm] drm_WARN_ON(!list_empty(&fb->filp_head))
WARNING: drivers/gpu/drm/drm_framebuffer.c:833 at drm_framebuffer_free+0x73/0xa0, CPU#2: kexec/1300
Call Trace:
<TASK>
drm_mode_config_cleanup+0x248/0x300
? __pfx___drm_printfn_dbg+0x10/0x10
? drm_mode_config_cleanup+0x1dc/0x300
nouveau_display_destroy+0x39/0x70 [nouveau c19e0da7fd83583a023f855c510d9a3903808734]
nouveau_drm_device_fini+0x7b/0x1f0 [nouveau c19e0da7fd83583a023f855c510d9a3903808734]
nouveau_drm_shutdown+0x52/0xc0 [nouveau c19e0da7fd83583a023f855c510d9a3903808734]
pci_device_shutdown+0x35/0x60
device_shutdown+0x11c/0x1b0
kernel_kexec+0x13a/0x160
__do_sys_reboot+0x209/0x240
do_syscall_64+0x81/0x610
? srso_return_thunk+0x5/0x5f
? __rtnl_unlock+0x37/0x70
? srso_return_thunk+0x5/0x5f
? netdev_run_todo+0x63/0x570
? netif_change_flags+0x54/0x70
? srso_return_thunk+0x5/0x5f
? devinet_ioctl+0x1e5/0x790
? srso_return_thunk+0x5/0x5f
? inet_ioctl+0x1e9/0x200
? srso_return_thunk+0x5/0x5f
? srso_return_thunk+0x5/0x5f
? sock_do_ioctl+0x7d/0x130
? srso_return_thunk+0x5/0x5f
? __x64_sys_ioctl+0x97/0xe0
? srso_return_thunk+0x5/0x5f
? srso_return_thunk+0x5/0x5f
? do_syscall_64+0x23b/0x610
? srso_return_thunk+0x5/0x5f
? put_user_ifreq+0x7a/0x90
? srso_return_thunk+0x5/0x5f
? sock_do_ioctl+0x107/0x130
? srso_return_thunk+0x5/0x5f
? __x64_sys_ioctl+0x97/0xe0
? srso_return_thunk+0x5/0x5f
? do_syscall_64+0x81/0x610
? srso_return_thunk+0x5/0x5f
? exc_page_fault+0x7e/0x1a0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
WARNING: include/drm/ttm/ttm_resource.h:406 at nouveau_ttm_fini+0x257/0x270 [nouveau], CPU#2: kexec/1300
Call Trace:
<TASK>
nouveau_drm_device_fini+0x93/0x1f0 [nouveau c19e0da7fd83583a023f855c510d9a3903808734]
nouveau_drm_shutdown+0x52/0xc0 [nouveau c19e0da7fd83583a023f855c510d9a3903808734]
pci_device_shutdown+0x35/0x60
device_shutdown+0x11c/0x1b0
kernel_kexec+0x13a/0x160
__do_sys_reboot+0x209/0x240
do_syscall_64+0x81/0x610
? srso_return_thunk+0x5/0x5f
? __rtnl_unlock+0x37/0x70
? srso_return_thunk+0x5/0x5f
? netdev_run_todo+0x63/0x570
? netif_change_flags+0x54/0x70
? srso_return_thunk+0x5/0x5f
? devinet_ioctl+0x1e5/0x790
? srso_return_thunk+0x5/0x5f
? inet_ioctl+0x1e9/0x200
? srso_return_thunk+0x5/0x5f
? srso_return_thunk+0x5/0x5f
? sock_do_ioctl+0x7d/0x130
? srso_return_thunk+0x5/0x5f
? __x64_sys_ioctl+0x97/0xe0
? srso_return_thunk+0x5/0x5f
? srso_return_thunk+0x5/0x5f
? do_syscall_64+0x23b/0x610
? srso_return_thunk+0x5/0x5f
? put_user_ifreq+0x7a/0x90
? srso_return_thunk+0x5/0x5f
? sock_do_ioctl+0x107/0x130
? srso_return_thunk+0x5/0x5f
? __x64_sys_ioctl+0x97/0xe0
? srso_return_thunk+0x5/0x5f
? do_syscall_64+0x81/0x610
? srso_return_thunk+0x5/0x5f
? exc_page_fault+0x7e/0x1a0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Signed-off-by: Li Chen <me@linux.beauty>
Reviewed-by: Dave Airlie <airlied@redhat.com>
---
drivers/gpu/drm/nouveau/nouveau_drm.c | 32 +++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 1527b801f013..f2e04a048ac2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -1079,6 +1079,37 @@ nouveau_pmops_resume(struct device *dev)
return ret;
}
+static void
+nouveau_drm_shutdown(struct pci_dev *pdev)
+{
+ struct nouveau_drm *drm = pci_get_drvdata(pdev);
+ int ret;
+
+ if (!drm)
+ return;
+
+ if (drm->dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
+ drm->dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
+ return;
+
+ ret = nouveau_do_suspend(drm, false);
+ if (ret)
+ NV_ERROR(drm, "shutdown suspend failed with: %d\n", ret);
+
+ pci_save_state(pdev);
+ pci_disable_device(pdev);
+ pci_set_power_state(pdev, PCI_D3hot);
+ /*
+ * This is just to give the pci power transition time to settle
+ * before an immediate kexec jump. it’s mirroring the existing
+ * nouveau_pmops_suspend() behavior, which already does
+ * udelay(200) right after pci_set_power_state(..., pci_d3hot). In
+ * ->shutdown() we’re allowed to sleep, so I used usleep_range()
+ * instead of a busy-wait udelay().
+ */
+ usleep_range(200, 400);
+}
+
static int
nouveau_pmops_freeze(struct device *dev)
{
@@ -1408,6 +1439,7 @@ nouveau_drm_pci_driver = {
.id_table = nouveau_drm_pci_table,
.probe = nouveau_drm_probe,
.remove = nouveau_drm_remove,
+ .shutdown = nouveau_drm_shutdown,
.driver.pm = &nouveau_pm_ops,
};
--
2.52.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] nouveau: pci: quiesce GPU on shutdown
2026-01-21 11:36 [PATCH v2] nouveau: pci: quiesce GPU on shutdown Li Chen
@ 2026-02-09 20:17 ` Dave Airlie
0 siblings, 0 replies; 2+ messages in thread
From: Dave Airlie @ 2026-02-09 20:17 UTC (permalink / raw)
To: Li Chen
Cc: Dave Airlie, Lyude Paul, Danilo Krummrich, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, Simona Vetter, dri-devel,
nouveau, linux-kernel
On Wed, 21 Jan 2026 at 21:37, Li Chen <me@linux.beauty> wrote:
>
> Kexec reboot does not reset PCI devices.
> Invoking the full DRM/TTM teardown from ->shutdown can trigger WARNs when
> userspace still holds DRM file descriptors.
>
> Quiesce the GPU through the suspend path and then power down the PCI
> function so the next kernel can re-initialize the device from a consistent
> state.
>
I've applied this to drm-misc-next, which means it's targeting 7.1
Dave.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-09 20:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-21 11:36 [PATCH v2] nouveau: pci: quiesce GPU on shutdown Li Chen
2026-02-09 20:17 ` Dave Airlie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®