[RFC 2/3] drm/amdgpu: Remove duplicated "context still alive" check

Alex Deucher alexdeucher at gmail.com
Tue May 20 14:17:30 UTC 2025


Applied patches 1 and 2.

Alex

On Tue, May 20, 2025 at 3:59 AM Christian König
<christian.koenig at amd.com> wrote:
>
> On 5/19/25 18:37, Tvrtko Ursulin wrote:
> > When amdgpu_ctx_mgr_fini() calls amdgpu_ctx_mgr_entity_fini() it contains
> > the exact same "context still alive" check as it will do next. Remove the
> > duplicated copy.
> >
> > Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at igalia.com>
> > Cc: Alex Deucher <alexander.deucher at amd.com>
> > Cc: Christian König <christian.koenig at amd.com>
>
> I think we could also completely remove this check from both places.
>
> IIRC it was only added because somebody suggested that CTX could potentially outlive the file descriptor.
>
> We fortunately abandoned that idea even before amdgpu went upstream.
>
> Either way this here is clearly superfluous, so feel free to add Reviewed-by: Christian König <christian.koenig at amd.com>
>
> Regards,
> Christian.
>
>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 12 ------------
> >  1 file changed, 12 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> > index 4ff8552e872d..85567d0d9545 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> > @@ -949,19 +949,7 @@ static void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr)
> >
> >  void amdgpu_ctx_mgr_fini(struct amdgpu_ctx_mgr *mgr)
> >  {
> > -     struct amdgpu_ctx *ctx;
> > -     struct idr *idp;
> > -     uint32_t id;
> > -
> >       amdgpu_ctx_mgr_entity_fini(mgr);
> > -
> > -     idp = &mgr->ctx_handles;
> > -
> > -     idr_for_each_entry(idp, ctx, id) {
> > -             if (kref_put(&ctx->refcount, amdgpu_ctx_fini) != 1)
> > -                     DRM_ERROR("ctx %p is still alive\n", ctx);
> > -     }
> > -
> >       idr_destroy(&mgr->ctx_handles);
> >       mutex_destroy(&mgr->lock);
> >  }
>


More information about the amd-gfx mailing list