Skip to contentSkip to conversation

drm/amdgpu: run user queue hung detect before decrementing userq_count on destroy

PATCH New Jesse Zhang 1 participant 1 message Mar 30

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

PATCH 1/1 drm/amdgpu: run user queue hung detect before decrementing userq_count on destroy

amdgpu_userq_detect_and_reset_queues() only invokes per-IP detect_and_reset when userq_count for that type is non-zero. Decrementing the count before that call skipped recovery when freeing the last queue of an IP.

Move atomic_dec() to after detect_and_reset and before unmap so the final queue teardown still runs hung detection, then update accounting and remove the hardware mapping.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -1
index aa0e6eea9436..d64cc9d700a9 100644
@@ -652,11 +652,11 @@ amdgpu_userq_destroy(struct amdgpu_userq_mgr *uq_mgr, struct amdgpu_usermode_que
 	}
 	amdgpu_bo_unref(&queue->wptr_obj.obj);
 
-	atomic_dec(&uq_mgr->userq_count[queue->queue_type]);
 #if defined(CONFIG_DEBUG_FS)
 	debugfs_remove_recursive(queue->debugfs_queue);
 #endif
 	amdgpu_userq_detect_and_reset_queues(uq_mgr);
+	atomic_dec(&uq_mgr->userq_count[queue->queue_type]);
 	r = amdgpu_userq_unmap_helper(queue);
 	/*TODO: It requires a reset for userq hw unmap error*/
 	if (unlikely(r != AMDGPU_USERQ_STATE_UNMAPPED)) {
Signature · 1 line
2.49.0