[PATCH 3/9] drm/amdgpu: wait for the user objects done before destroying
Christian König
christian.koenig at amd.com
Mon Jun 2 11:05:11 UTC 2025
On 5/30/25 09:54, Prike Liang wrote:
> The userq buffer should complete its attached work before
> being destroyed.
That doesn't make sense at all. We should wait for the requested signal fences, but apart from that it is the responsibility for userspace to make sure that queues are only destroyed after they are idle.
If the kernel does this it should *never* wait for anything ongoing, it should only forcefully unmap the queue and destroy it.
Regards,
Christian.
>
> 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);
> }
More information about the amd-gfx
mailing list