mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Fix runtime PM leak in amdgpu_debugfs_test_ib_show()
@ 2026-09-16  9:58 Wentao Liang
  2026-09-16 14:29 ` Deucher, Alexander
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-16  9:58 UTC (permalink / raw)
  To: Dennis.Li
  Cc: airlied, alexander.deucher, amd-gfx, christian.koenig, dri-devel,
	linux-kernel, monk.liu, simona, Wentao Liang, stable

amdgpu_debugfs_test_ib_show() resumes the device with
pm_runtime_get_sync() before taking the reset domain semaphore with
down_write_killable().  If the write lock acquisition is interrupted,
the function returns without calling pm_runtime_put_autosuspend(),
leaking the runtime PM reference acquired for the device and keeping
the GPU awake.

Drop the runtime PM reference on the interrupted down_write_killable()
error path before returning.

Fixes: 6049db43d6dd ("drm/amdgpu: change reset lock from mutex to rw_semaphore")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index 092fd3309099..adc0252f6400 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
@@ -1764,8 +1764,10 @@ static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused)
 
 	/* Avoid accidently unparking the sched thread during GPU reset */
 	r = down_write_killable(&adev->reset_domain->sem);
-	if (r)
+	if (r) {
+		pm_runtime_put_autosuspend(dev->dev);
 		return r;
+	}
 
 	/* hold on the scheduler */
 	for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [PATCH] drm/amdgpu: Fix runtime PM leak in amdgpu_debugfs_test_ib_show()
  2026-09-16  9:58 [PATCH] drm/amdgpu: Fix runtime PM leak in amdgpu_debugfs_test_ib_show() Wentao Liang
@ 2026-09-16 14:29 ` Deucher, Alexander
  0 siblings, 0 replies; 2+ messages in thread
From: Deucher, Alexander @ 2026-09-16 14:29 UTC (permalink / raw)
  To: Wentao Liang, Li, Dennis
  Cc: airlied, amd-gfx, Koenig, Christian, dri-devel, linux-kernel,
	Liu, Monk, simona, stable

AMD General

Applied.  Thanks!

> -----Original Message-----
> From: Wentao Liang <vulab@iscas.ac.cn>
> Sent: Wednesday, September 16, 2026 5:58 AM
> To: Li, Dennis <Dennis.Li@amd.com>
> Cc: airlied@gmail.com; Deucher, Alexander <Alexander.Deucher@amd.com>;
> amd-gfx@lists.freedesktop.org; Koenig, Christian
> <Christian.Koenig@amd.com>; dri-devel@lists.freedesktop.org; linux-
> kernel@vger.kernel.org; Liu, Monk <Monk.Liu@amd.com>; simona@ffwll.ch;
> Wentao Liang <vulab@iscas.ac.cn>; stable@vger.kernel.org
> Subject: [PATCH] drm/amdgpu: Fix runtime PM leak in
> amdgpu_debugfs_test_ib_show()
>
> amdgpu_debugfs_test_ib_show() resumes the device with
> pm_runtime_get_sync() before taking the reset domain semaphore with
> down_write_killable().  If the write lock acquisition is interrupted, the function
> returns without calling pm_runtime_put_autosuspend(), leaking the runtime
> PM reference acquired for the device and keeping the GPU awake.
>
> Drop the runtime PM reference on the interrupted down_write_killable() error
> path before returning.
>
> Fixes: 6049db43d6dd ("drm/amdgpu: change reset lock from mutex to
> rw_semaphore")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> index 092fd3309099..adc0252f6400 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> @@ -1764,8 +1764,10 @@ static int amdgpu_debugfs_test_ib_show(struct
> seq_file *m, void *unused)
>
>       /* Avoid accidently unparking the sched thread during GPU reset */
>       r = down_write_killable(&adev->reset_domain->sem);
> -     if (r)
> +     if (r) {
> +             pm_runtime_put_autosuspend(dev->dev);
>               return r;
> +     }
>
>       /* hold on the scheduler */
>       for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
> --
> 2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-16 14:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16  9:58 [PATCH] drm/amdgpu: Fix runtime PM leak in amdgpu_debugfs_test_ib_show() Wentao Liang
2026-09-16 14:29 ` Deucher, Alexander

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®