From nobody Sat Feb 7 11:38:05 2026 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 619A540756F for ; Wed, 21 Jan 2026 11:37:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768995435; cv=pass; b=l26/YjuHCltHE78uU/Ff1UG6gLfppSrpAsoe9s5eK1MGOHhSGX0EN0RVvUs0bkg2uzRrNOZ+t3y+r8SP4fCyl204BN80tHRNJM50ucXLbj61Nwp3Vf2yAZ5ADgcV+Ic17bMkOJh7t+LzOsUZ4DjpTX4OITacKmKFju3dETsVkIE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768995435; c=relaxed/simple; bh=gl2ASFkMw1wv3LnRtAVCLQwGzHMLFwG5vgQ0uSaJLVk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=ZLxa+IUd7rmYswScVlurAtpvYf3j7WgjaKU18z26HTIhJsYf6lIlU/bk1JKdyDNXiXfCbOhE1qOv0q8dY4KysC20jKAte2FpioTbphd5oY9aYN/VK/inVyaZkiLBpLkJFGZ0/FueCAmoMa+1IQCEMHb4IZgGrihg7bvhK4cs9MU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty; spf=pass smtp.mailfrom=linux.beauty; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b=ejAWSczX; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.beauty Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b="ejAWSczX" ARC-Seal: i=1; a=rsa-sha256; t=1768995417; cv=none; d=zohomail.com; s=zohoarc; b=LfsGDFhho8f+pL7xRcCxxdlWbHCaHNEsPGIRCzYXVqcGSKINHMplgNgqMo8gbJfFf8qfUKiUrb/P3IfdCS2IlYgI1qRqrkNmBWfDEaRwNZLLZTEr12dem12pmeLrVNGydvymO8yhpATneDfJ8ZHLxQbwjqAvLKo3uqbHwWOQoAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768995417; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=+AdrJzDFk+iZHM5mX4cSeLtnmX3YwtJuX07LPIMl/gc=; b=YhiqdlS87yV8l5X3P+q9z9BVDCs4Q/uxcNeM5GBDiUMyQlvl3ieG82mnhLw+9fQwj4ltESDDqpjdMvYf8xCSgfB3OdAHOdkw5cx6DMq27XnaMuq5ougNP6AsieKhhEv6FyxCQtj8ssmlPbSpruNCju81duX+zlZiWCtEB/QXGfw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=linux.beauty; spf=pass smtp.mailfrom=me@linux.beauty; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1768995417; s=zmail; d=linux.beauty; i=me@linux.beauty; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=+AdrJzDFk+iZHM5mX4cSeLtnmX3YwtJuX07LPIMl/gc=; b=ejAWSczXNnRN+Om/j0kIoMt3Po43+7YyvzJpqxx8RXgh0NZo590IOBunKtLuustH 1yVFZ9E209BJqy61SfF0EBzGC0zwfNV6zS3UJOF6EVl3zby0sjpzvdUjMfPUTiE3uv8 yzQGzxXgZqh2XljT8bQjzqV1X2DW1zRBsNNqrGRc= Received: by mx.zohomail.com with SMTPS id 1768995413291852.3338382709496; Wed, 21 Jan 2026 03:36:53 -0800 (PST) From: Li Chen To: Dave Airlie , Lyude Paul , Danilo Krummrich , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Li Chen Subject: [PATCH v2] nouveau: pci: quiesce GPU on shutdown Date: Wed, 21 Jan 2026 19:36:44 +0800 Message-ID: <20260121113646.111561-1-me@linux.beauty> X-Mailer: git-send-email 2.52.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External 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+0= x2e7/0x300, CPU#2: kexec/1300 Call Trace: ? srso_return_thunk+0x5/0x5f ? enable_work+0x3a/0x100 nouveau_display_destroy+0x39/0x70 [nouveau c19e0da7fd83583a023f855c510d9a3= 903808734] nouveau_drm_device_fini+0x7b/0x1f0 [nouveau c19e0da7fd83583a023f855c510d9a= 3903808734] nouveau_drm_shutdown+0x52/0xc0 [nouveau c19e0da7fd83583a023f855c510d9a3903= 808734] 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: drm_mode_config_cleanup+0x248/0x300 ? __pfx___drm_printfn_dbg+0x10/0x10 ? drm_mode_config_cleanup+0x1dc/0x300 nouveau_display_destroy+0x39/0x70 [nouveau c19e0da7fd83583a023f855c510d9a3= 903808734] nouveau_drm_device_fini+0x7b/0x1f0 [nouveau c19e0da7fd83583a023f855c510d9a= 3903808734] nouveau_drm_shutdown+0x52/0xc0 [nouveau c19e0da7fd83583a023f855c510d9a3903= 808734] 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: nouveau_drm_device_fini+0x93/0x1f0 [nouveau c19e0da7fd83583a023f855c510d9a= 3903808734] nouveau_drm_shutdown+0x52/0xc0 [nouveau c19e0da7fd83583a023f855c510d9a3903= 808734] 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 Reviewed-by: Dave Airlie --- 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/nouvea= u/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; } =20 +static void +nouveau_drm_shutdown(struct pci_dev *pdev) +{ + struct nouveau_drm *drm =3D pci_get_drvdata(pdev); + int ret; + + if (!drm) + return; + + if (drm->dev->switch_power_state =3D=3D DRM_SWITCH_POWER_OFF || + drm->dev->switch_power_state =3D=3D DRM_SWITCH_POWER_DYNAMIC_OFF) + return; + + ret =3D 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=E2=80=99s mirroring the existing + * nouveau_pmops_suspend() behavior, which already does + * udelay(200) right after pci_set_power_state(..., pci_d3hot). In + * ->shutdown() we=E2=80=99re 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 =3D { .id_table =3D nouveau_drm_pci_table, .probe =3D nouveau_drm_probe, .remove =3D nouveau_drm_remove, + .shutdown =3D nouveau_drm_shutdown, .driver.pm =3D &nouveau_pm_ops, }; =20 --=20 2.52.0