]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu/userq: Fix doorbell object cleanup of queue
authorSunil Khatri <sunil.khatri@amd.com>
Tue, 19 May 2026 09:32:00 +0000 (15:02 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 27 May 2026 15:55:28 +0000 (11:55 -0400)
Unpin and unref the door bell obj if queue creation fails before
initialization is complete.

Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 8c7506f7ba945f21e5abe7f8eac0a3acca6b5330)

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c

index f070ea37d9188def17f2bcc928966be76650a409..2301a44a03b13eaa4887df049cdd42d23010166c 100644 (file)
@@ -787,7 +787,7 @@ amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args)
        r = uq_funcs->mqd_create(queue, &args->in);
        if (r) {
                drm_file_err(uq_mgr->file, "Failed to create Queue\n");
-               goto clean_mapping;
+               goto clean_doorbell_bo;
        }
 
        /* Update VM owner at userq submit-time for page-fault attribution. */
@@ -808,7 +808,7 @@ amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args)
                if (r) {
                        drm_file_err(uq_mgr->file, "Failed to map Queue\n");
                        mutex_unlock(&uq_mgr->userq_mutex);
-                       goto clean_doorbell;
+                       goto erase_doorbell;
                }
        }
 
@@ -831,10 +831,15 @@ amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args)
        args->out.queue_id = qid;
        return 0;
 
-clean_doorbell:
+erase_doorbell:
        xa_erase_irq(&adev->userq_doorbell_xa, index);
 clean_mqd:
        uq_funcs->mqd_destroy(queue);
+clean_doorbell_bo:
+       amdgpu_bo_reserve(queue->db_obj.obj, true);
+       amdgpu_bo_unpin(queue->db_obj.obj);
+       amdgpu_bo_unreserve(queue->db_obj.obj);
+       amdgpu_bo_unref(&queue->db_obj.obj);
 clean_mapping:
        amdgpu_bo_reserve(fpriv->vm.root.bo, true);
        amdgpu_userq_buffer_vas_list_cleanup(adev, queue);