[PATCH V2 4/9] drm/amdgpu/userq: properly clean up userq fence driver on failure

Khatri, Sunil sukhatri at amd.com
Fri Apr 11 16:02:20 UTC 2025


LGTM, thanks Alex
Reviewed-by: Sunil Khatri <sunil.khatri at amd.com>

On 4/11/2025 7:42 PM, Alex Deucher wrote:
> If userq creation fails, we need to properly unwind and free the
> user queue fence driver.
>
> v2: free idr as well (Sunil)
>
> Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
> index 79f4df4255c50..41a095c12f956 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
> @@ -330,6 +330,7 @@ amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq *args)
>   	r = uq_funcs->mqd_create(uq_mgr, &args->in, queue);
>   	if (r) {
>   		DRM_ERROR("Failed to create Queue\n");
> +		amdgpu_userq_fence_driver_free(queue);
>   		kfree(queue);
>   		goto unlock;
>   	}
> @@ -337,6 +338,7 @@ amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq *args)
>   	qid = idr_alloc(&uq_mgr->userq_idr, queue, 1, AMDGPU_MAX_USERQ_COUNT, GFP_KERNEL);
>   	if (qid < 0) {
>   		DRM_ERROR("Failed to allocate a queue id\n");
> +		amdgpu_userq_fence_driver_free(queue);
>   		uq_funcs->mqd_destroy(uq_mgr, queue);
>   		kfree(queue);
>   		r = -ENOMEM;
> @@ -346,6 +348,8 @@ amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq *args)
>   	r = uq_funcs->map(uq_mgr, queue);
>   	if (r) {
>   		DRM_ERROR("Failed to map Queue\n");
> +		idr_remove(&uq_mgr->userq_idr, qid);
> +		amdgpu_userq_fence_driver_free(queue);
>   		uq_funcs->mqd_destroy(uq_mgr, queue);
>   		kfree(queue);
>   		goto unlock;


More information about the amd-gfx mailing list