Skip to contentSkip to conversation

drm/amdgpu/mes: initialize the dbgext work before it can be cancelled

PATCH In review Jesse Zhang 2 participants 2 messages Nov 3 – Nov 4

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu/mes: initialize the dbgext work before it can be cancelled

The dbgext work is only initialized when the debug extension starts, but stopping it cancels the work unconditionally, and every MES suspend stops it. With the extension off, which is the default, each GPU reset, suspend or disable through debugfs then cancels a work without a function:

  WARNING: kernel/workqueue.c:4335 at __flush_work+0xa6d/0xd10, CPU#1: kworker/u64:4/406
  Workqueue: amdgpu-reset-dev amdgpu_debugfs_reset_work [amdgpu]
   cancel_work_sync+0x8d/0xa0
   amdgpu_mes_dbgext_stop_locked+0x197/0x420 [amdgpu]
   amdgpu_mes_dbgext_stop+0x2d/0x40 [amdgpu]
   mes_v12_0_suspend+0x35/0x50 [amdgpu]
   amdgpu_device_pre_asic_reset+0x403/0x8d0 [amdgpu]

Initialize the work once in amdgpu_mes_init(). On navi48 three GPU resets through amdgpu_gpu_recover and the mes-dbgext-wakes-gpu IGT no longer warn, and resets with the extension enabled still work.

Fixes 9dc106cb56d7 ("drm/amdgpu: add mes_dbgext core support")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3 -1
index 0409325017a2..2da4bb1994c5 100644
@@ -109,6 +109,7 @@ static inline u32 amdgpu_mes_get_hqd_mask(u32 num_pipe,
 }
 
 static void amdgpu_mes_userq_notify_unmap_work_handler(struct work_struct *work);
+static void amdgpu_mes_dbgext_work_fn(struct work_struct *work);
 
 int amdgpu_mes_init(struct amdgpu_device *adev)
 {
@@ -129,6 +130,8 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
 	mutex_init(&adev->mes.dbgext_lock);
 	mutex_init(&adev->mes.dbgext_drain_lock);
 	spin_lock_init(&adev->mes.dbgext_notify_lock);
+	/* stopping the debug extension cancels it, even if it never started */
+	INIT_WORK(&adev->mes.dbgext_work, amdgpu_mes_dbgext_work_fn);
 
 	for (i = 0; i < AMDGPU_MAX_MES_PIPES * num_xcc; i++)
 		spin_lock_init(&adev->mes.ring_lock[i]);
@@ -1765,7 +1768,6 @@ static int amdgpu_mes_dbgext_start_locked(struct amdgpu_device *adev)
 			return r;
 		}
 		mes->dbgext_log_size = size;
-		INIT_WORK(&mes->dbgext_work, amdgpu_mes_dbgext_work_fn);
 	} else {
 		/*
 		 * Resume: the log buffer is kept allocated across a suspend/
Signature · 1 line
2.50.1
Reviewed-by on v1 1/1
#1 lore raw

AMD General

Thanks for the fix.

________________________________
From: Jesse Zhang <[email protected]>
Sent: Tuesday, November 03, 2026 3:33 AM
To: [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Sun, Yongqiang <[email protected]>; Liu, Shaoyun <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
Subject: [PATCH] drm/amdgpu/mes: initialize the dbgext work before it can be cancelled

The dbgext work is only initialized when the debug extension starts, but stopping it cancels the work unconditionally, and every MES suspend stops it. With the extension off, which is the default, each GPU reset, suspend or disable through debugfs then cancels a work without a function:

  WARNING: kernel/workqueue.c:4335 at __flush_work+0xa6d/0xd10, CPU#1: kworker/u64:4/406
  Workqueue: amdgpu-reset-dev amdgpu_debugfs_reset_work [amdgpu]
   cancel_work_sync+0x8d/0xa0
   amdgpu_mes_dbgext_stop_locked+0x197/0x420 [amdgpu]
   amdgpu_mes_dbgext_stop+0x2d/0x40 [amdgpu]
   mes_v12_0_suspend+0x35/0x50 [amdgpu]
   amdgpu_device_pre_asic_reset+0x403/0x8d0 [amdgpu]

Initialize the work once in amdgpu_mes_init(). On navi48 three GPU resets through amdgpu_gpu_recover and the mes-dbgext-wakes-gpu IGT no longer warn, and resets with the extension enabled still work.

Fixes 9dc106cb56d7 ("drm/amdgpu: add mes_dbgext core support")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3 -1
index 0409325017a2..2da4bb1994c5 100644
@@ -109,6 +109,7 @@ static inline u32 amdgpu_mes_get_hqd_mask(u32 num_pipe,
 }
 
 static void amdgpu_mes_userq_notify_unmap_work_handler(struct work_struct *work);
+static void amdgpu_mes_dbgext_work_fn(struct work_struct *work);
 
 int amdgpu_mes_init(struct amdgpu_device *adev)
 {
@@ -129,6 +130,8 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
         mutex_init(&adev->mes.dbgext_lock);
         mutex_init(&adev->mes.dbgext_drain_lock);
         spin_lock_init(&adev->mes.dbgext_notify_lock);
+       /* stopping the debug extension cancels it, even if it never started */
+       INIT_WORK(&adev->mes.dbgext_work, amdgpu_mes_dbgext_work_fn);
 
         for (i = 0; i < AMDGPU_MAX_MES_PIPES * num_xcc; i++)
                 spin_lock_init(&adev->mes.ring_lock[i]);
@@ -1765,7 +1768,6 @@ static int amdgpu_mes_dbgext_start_locked(struct amdgpu_device *adev)
                         return r;
                 }
                 mes->dbgext_log_size = size;
-               INIT_WORK(&mes->dbgext_work, amdgpu_mes_dbgext_work_fn);
         } else {
                 /*
                  * Resume: the log buffer is kept allocated across a suspend/

--
2.50.1