On Thu, Jun 11, 2026 at 10:59 AM Srinivasan Shanmugam
<[email protected]> wrote:
>
> Tie the eventfd manager lifetime strictly to the drm_file (amdgpu_fpriv)
> by embedding the manager instead of storing a pointer.
>
> This removes the need for reference counting and avoids destroying the
> manager from IRQ context
>
> 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.h     | 3 +++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 5 +++++
>  2 files changed, 8 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 5d7bfa59424a..a75c68195df9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -104,6 +104,7 @@
>  #include "amdgpu_fdinfo.h"
>  #include "amdgpu_mca.h"
>  #include "amdgpu_aca.h"
> +#include "amdgpu_eventfd.h"
>  #include "amdgpu_ras.h"
>  #include "amdgpu_cper.h"
>  #include "amdgpu_xcp.h"
> @@ -455,6 +456,8 @@ struct amdgpu_fpriv {
>
>         /** GPU partition selection */
>         uint32_t                xcp_id;
> +
> +       struct amdgpu_eventfd_mgr       eventfd_mgr;
>  };
>
>  int amdgpu_file_to_fpriv(struct file *filp, struct amdgpu_fpriv **fpriv);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 24526e92f9b8..f5719500527f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -1460,6 +1460,8 @@ int amdgpu_driver_open_kms(struct drm_device *dev, 
> struct drm_file *file_priv)
>                 goto out_suspend;
>         }
>
> +       amdgpu_eventfd_mgr_init(&fpriv->eventfd_mgr);
> +
>         pasid = amdgpu_pasid_alloc(16);
>         if (pasid < 0) {
>                 dev_warn(adev->dev, "No more PASIDs available!");
> @@ -1556,6 +1558,9 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
>         if (!fpriv)
>                 return;
>
> +       /* Drop all subscriptions before fpriv goes away. */
> +       amdgpu_eventfd_mgr_fini(&fpriv->eventfd_mgr);
> +
>         pm_runtime_get_sync(dev->dev);
>
>         if (amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_UVD) != 
> NULL)
> --
> 2.34.1
>

Reply via email to