[PATCH 3/9] drm/amdgpu: wait for the user objects done before destroying

Alex Deucher alexdeucher at gmail.com
Fri May 30 21:35:55 UTC 2025


On Fri, May 30, 2025 at 4:20 AM Prike Liang <Prike.Liang at amd.com> wrote:
>
> The userq buffer should complete its attached work before
> being destroyed.

I don't think that is possible.  The user may not have a fence
associated with the queue.  If the user destroys the queue, we should
just unmap it and clean up.

Alex

>
> Signed-off-by: Prike Liang <Prike.Liang at amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c  | 3 ++-
>  drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 3 +++
>  2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> index 8eea0e1e1b6a..f45585bd5872 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> @@ -217,6 +217,8 @@ int amdgpu_userq_create_object(struct amdgpu_userq_mgr *uq_mgr,
>  void amdgpu_userq_destroy_object(struct amdgpu_userq_mgr *uq_mgr,
>                                  struct amdgpu_userq_obj *userq_obj)
>  {
> +       amdgpu_bo_sync_wait(userq_obj->obj, AMDGPU_FENCE_OWNER_UNDEFINED,
> +                       false);
>         amdgpu_bo_kunmap(userq_obj->obj);
>         amdgpu_bo_unref(&userq_obj->obj);
>  }
> @@ -317,7 +319,6 @@ amdgpu_userq_destroy(struct drm_file *filp, int queue_id)
>                 amdgpu_bo_unpin(queue->db_obj.obj);
>                 amdgpu_bo_unreserve(queue->db_obj.obj);
>         }
> -       amdgpu_bo_unref(&queue->db_obj.obj);
>         r = amdgpu_userq_unmap_helper(uq_mgr, queue);
>         if (r != AMDGPU_USERQ_STATE_UNMAPPED) {
>                 drm_dbg_driver(adev_to_drm(uq_mgr->adev), "Can't unmap the queue for destroying.\n");
> diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> index 1457fb49a794..b46e67b179fc 100644
> --- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> +++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> @@ -336,6 +336,9 @@ mes_userq_mqd_destroy(struct amdgpu_userq_mgr *uq_mgr,
>                       struct amdgpu_usermode_queue *queue)
>  {
>         amdgpu_userq_destroy_object(uq_mgr, &queue->fw_obj);
> +       if (queue->db_obj.obj->tbo.pin_count)
> +               amdgpu_bo_unpin(queue->db_obj.obj);
> +       amdgpu_userq_destroy_object(uq_mgr, &queue->db_obj);
>         kfree(queue->userq_prop);
>         amdgpu_userq_destroy_object(uq_mgr, &queue->mqd);
>  }
> --
> 2.34.1
>


More information about the amd-gfx mailing list