Skip to contentSkip to conversation

drm/amdgpu/userq: skip unmapped queues in amdgpu_userq_wait_for_signal

PATCH In review Jesse Zhang 2 participants 2 messages Aug 18 – Aug 19

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

PATCH 1/1 drm/amdgpu/userq: skip unmapped queues in amdgpu_userq_wait_for_signal

amdgpu_userq_wait_for_signal() does an unbounded dma_fence_wait() on every queue's last_fence before eviction. A queue disabled via MODIFY with queue_percentage == 0 is unmapped but stays in the xarray, and its pending fence never signals because the work will not run while the queue is unmapped. Eviction then blocks forever, hanging the task and wedging the GPU on a forced reset.

Only wait on fences of queues that are still mapped.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +10 -0
index feffebb210ea..cfbfecb05768 100644
@@ -1302,6 +1302,16 @@ amdgpu_userq_wait_for_signal(struct amdgpu_userq_mgr *uq_mgr)
 		if (!f)
 			continue;
 
+		/*
+		 * Only a mapped queue can make progress on its fences. A queue
+		 * that has been unmapped (e.g. disabled through a MODIFY with
+		 * queue_percentage == 0) will never execute its pending work,
+		 * so its last_fence would never signal. Waiting on it here would
+		 * block the eviction path forever, so skip such queues.
+		 */
+		if (queue->state != AMDGPU_USERQ_STATE_MAPPED)
+			continue;
+
 		dma_fence_wait(f, false);
 	}
 }
Signature · 1 line
2.49.0
#1 lore raw

AMD General

A dereferenced queue may remain in the XArray. To avoid retrieving an unmapped queue, amdgpu_userq_destroy() should remove the queue from the process's queue XArray first. If there are any other paths that fail to remove dereferenced queues from the XArray, amdgpu_userq_wait_for_last_fence() should also skip those stale entries as a defensive safeguard.

Regards,
Prike

Quoted 48 lines

-----Original Message-----
From: Jesse Zhang <[email protected]>
Sent: Tuesday, August 18, 2026 3:29 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Liang, Prike <[email protected]>; Khatri, Sunil <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
Subject: [PATCH] drm/amdgpu/userq: skip unmapped queues in amdgpu_userq_wait_for_signal

amdgpu_userq_wait_for_signal() does an unbounded dma_fence_wait() on every queue's last_fence before eviction. A queue disabled via MODIFY with queue_percentage == 0 is unmapped but stays in the xarray, and its pending fence never signals because the work will not run while the queue is unmapped. Eviction then blocks forever, hanging the task and wedging the GPU on a forced reset.

Only wait on fences of queues that are still mapped.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +10 -0
index feffebb210ea..cfbfecb05768 100644
@@ -1302,6 +1302,16 @@ amdgpu_userq_wait_for_signal(struct
 amdgpu_userq_mgr *uq_mgr)
              if (!f)
                      continue;
 
+             /*
+              * Only a mapped queue can make progress on its fences. A queue
+              * that has been unmapped (e.g. disabled through a MODIFY with
+              * queue_percentage == 0) will never execute its pending work,
+              * so its last_fence would never signal. Waiting on it here would
+              * block the eviction path forever, so skip such queues.
+              */
+             if (queue->state != AMDGPU_USERQ_STATE_MAPPED)
+                     continue;
+
              dma_fence_wait(f, false);
      }

}
--
2.49.0