On Mon, Jul 13, 2026 at 1:39 PM Srinivasan Shanmugam
<[email protected]> wrote:
>
> Pending WAIT_EVENT records for queue-scoped events store queue pointers
> and own queue references while queued.
>
> Remove all WAIT_EVENT records associated with a user queue before USERQ
> drops its queue reference during queue teardown. This mirrors the
> EVENTFD queue cleanup path and prevents pending records from keeping
> stale queue state after the queue is removed from USERQ ownership.
>
> Cc: Alex Deucher <[email protected]>
> Cc: Christian König <[email protected]>
> Signed-off-by: Srinivasan Shanmugam <[email protected]>

Reviewed-by: Alex Deucher <[email protected]>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 21 +++++++++++++++++++++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h |  2 ++
>  2 files changed, 23 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> index 5bf231d7a630..b3ac1e81c9ca 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> @@ -56,6 +56,24 @@ amdgpu_userq_eventfd_mgr(struct amdgpu_userq_mgr 
> *userq_mgr)
>         return &fpriv->eventfd_mgr;
>  }
>
> +/*
> + * Get the per-file wait-event manager associated with this userq manager.
> + */
> +struct amdgpu_wait_event_mgr *
> +amdgpu_userq_wait_event_mgr(struct amdgpu_userq_mgr *userq_mgr)
> +{
> +       struct amdgpu_fpriv *fpriv;
> +
> +       if (WARN_ON(!userq_mgr || !userq_mgr->file))
> +               return NULL;
> +
> +       fpriv = userq_mgr->file->driver_priv;
> +       if (WARN_ON(!fpriv))
> +               return NULL;
> +
> +       return &fpriv->wait_event_mgr;
> +}
> +
>  u32 amdgpu_userq_get_supported_ip_mask(struct amdgpu_device *adev)
>  {
>         int i;
> @@ -1040,6 +1058,7 @@ int amdgpu_userq_ioctl(struct drm_device *dev, void 
> *data,
>                         return -ENOENT;
>
>                 amdgpu_eventfd_remove_queue(&fpriv->eventfd_mgr, queue);
> +               amdgpu_wait_event_remove_queue(&fpriv->wait_event_mgr, queue);
>
>                 amdgpu_userq_put(queue);
>                 break;
> @@ -1426,6 +1445,8 @@ void amdgpu_userq_mgr_fini(struct amdgpu_userq_mgr 
> *userq_mgr)
>
>                 
> amdgpu_eventfd_remove_queue(amdgpu_userq_eventfd_mgr(userq_mgr),
>                                             queue);
> +               
> amdgpu_wait_event_remove_queue(amdgpu_userq_wait_event_mgr(userq_mgr),
> +                                              queue);
>
>                 amdgpu_userq_put(queue);
>         }
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
> index 187bfd66eb13..6a53cd3208da 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
> @@ -203,4 +203,6 @@ int amdgpu_userq_input_cwsr_params_validate(
>         struct amdgpu_cwsr_params *cwsr_params);
>  struct amdgpu_eventfd_mgr *
>  amdgpu_userq_eventfd_mgr(struct amdgpu_userq_mgr *userq_mgr);
> +struct amdgpu_wait_event_mgr *
> +amdgpu_userq_wait_event_mgr(struct amdgpu_userq_mgr *userq_mgr);
>  #endif
> --
> 2.34.1
>

Reply via email to