[PATCH 3/9] drm/amdgpu: wait for the user objects done before destroying
Liang, Prike
Prike.Liang at amd.com
Thu Jun 5 12:48:07 UTC 2025
[Public]
> From: Alex Deucher <alexdeucher at gmail.com>
> Sent: Saturday, May 31, 2025 5:36 AM
> To: Liang, Prike <Prike.Liang at amd.com>
> Cc: amd-gfx at lists.freedesktop.org; Deucher, Alexander
> <Alexander.Deucher at amd.com>; Koenig, Christian <Christian.Koenig at amd.com>;
> Lazar, Lijo <Lijo.Lazar at amd.com>
> Subject: Re: [PATCH 3/9] drm/amdgpu: wait for the user objects done before
> destroying
>
> 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.
[Prike] The user queue buffer object may add the eviction fence and page table update job scheduled fence,
and by dumping the queue object reservation, it shows the fences are attached well. In most cases, the queue
object fences are signaled at the user queue destroy phase, but somehow there is sometimes an attached fence
without being signaled prior to destroying the queue. In this case, do we still not wait or test that the buffer object's
fences are signaled before trying to destroy it?
> 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