On Thu, Jun 11, 2026 at 10:44 AM Srinivasan Shanmugam <[email protected]> wrote: > > Provide a helper to retrieve the per-file eventfd manager associated > with a user queue manager. > > The helper resolves the eventfd manager through the existing drm_file -> > driver_priv link instead of storing an additional eventfd manager > pointer inside amdgpu_userq_mgr. > > This keeps the ownership model unchanged and avoids maintaining > duplicate references between USERQ and EVENTFD state. > > v10: (per Christian) > - Remove the extra eventfd_mgr pointer from userq_mgr. > - Use the existing drm_file link to access the eventfd manager when > needed. > > v11: > - Replace defensive NULL checks with WARN_ON() for conditions that > should never occur. (Christian) > > Cc: Alex Deucher <[email protected]> > Suggested-by: Christian König <[email protected]> > Signed-off-by: Srinivasan Shanmugam <[email protected]> > Reviewed-by: Christian König <[email protected]>
Reviewed-by: Alex Deucher <[email protected]> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 19 +++++++++++++++++++ > drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 2 ++ > 2 files changed, 21 insertions(+) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > index 99c711ddf71e..427c09c83d6b 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > @@ -34,6 +34,25 @@ > #include "amdgpu_hmm.h" > #include "amdgpu_userq_fence.h" > > +/* > + * Get the per-file eventfd manager associated with this userq manager. > + */ > +struct amdgpu_eventfd_mgr * > +amdgpu_userq_eventfd_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->eventfd_mgr; > +} > + > u32 amdgpu_userq_get_supported_ip_mask(struct amdgpu_device *adev) > { > int i; > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h > index d1751febaefe..8c4b55517a0a 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h > @@ -183,4 +183,6 @@ int amdgpu_userq_input_va_validate(struct amdgpu_device > *adev, > > void amdgpu_userq_gem_va_unmap_validate(struct amdgpu_device *adev, > struct amdgpu_bo_va_mapping *mapping); > +struct amdgpu_eventfd_mgr * > +amdgpu_userq_eventfd_mgr(struct amdgpu_userq_mgr *userq_mgr); > #endif > -- > 2.34.1 >
