[PATCH] drm/amdgpu: put ctx's ref count in amdgpu_ctx_mgr_entity_fini()
Tvrtko Ursulin
tursulin at ursulin.net
Wed Jun 25 11:39:53 UTC 2025
On 25/06/2025 03:14, cao, lin wrote:
> [AMD Official Use Only - AMD Internal Distribution Only]
>
>
> Hi Ursulin, Christian,
>
> I find the upstream patch: https://git.kernel.org/pub/scm/linux/kernel/
> git/torvalds/linux.git/commit/?
> id=dd64956685fa48358c4152d952070c8c073e5f89 <https://git.kernel.org/pub/
> scm/linux/kernel/git/torvalds/linux.git/commit/?
> id=dd64956685fa48358c4152d952070c8c073e5f89>
>
> May I ask if I can modify the commit msg as:
>
> drm/amdgpu: Fix memory leak in amdgpu_ctx_mgr_entity_fini
>
> patch "dd64956685fa drm/amdgpu: Remove duplicated "context still
> alive" check" removed ctx put, which will cause amdgpu_ctx_fini()
> cannot be called and then cause some finished fence that added by
> amdgpu_ctx_add_fence() cannot be released and cause memleak.
>
> Fixes: dd64956685fa ("drm/amdgpu: Remove duplicated "context still
> alive" check")
> Signed-off-by: Lin.Cao <lincao12 at amd.com>
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at igalia.com>
> Acked-by: Christian König <christian.koenig at amd.com>
Looks good to me.
Regards,
Tvrtko
> ------------------------------------------------------------------------
> *From:* Koenig, Christian <Christian.Koenig at amd.com>
> *Sent:* Tuesday, June 24, 2025 21:11
> *To:* Tvrtko Ursulin <tursulin at ursulin.net>; cao, lin <lin.cao at amd.com>;
> amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>
> *Cc:* Chang, HaiJun <HaiJun.Chang at amd.com>
> *Subject:* Re: [PATCH] drm/amdgpu: put ctx's ref count in
> amdgpu_ctx_mgr_entity_fini()
> On 24.06.25 11:46, Tvrtko Ursulin wrote:
>>
>> On 24/06/2025 10:18, Lin.Cao wrote:
>>> patch "daf823f1d0cd drm/amdgpu: Remove duplicated "context still
>>> alive" check" removed ctx put, which will cause amdgpu_ctx_fini()
>>> cannot be called and then cause some finished fence that added by
>>> amdgpu_ctx_add_fence() cannot be released and cause memleak.
>>
>> Ouch I removed the wrong one. :( Probably misread kref_put as kref_read..
>>
>> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at igalia.com>
>
> Acked-by: Christian König <christian.koenig at amd.com>
>
>>
>> But is the SHA correct? I see it is dd64956685fa.
>
> That could be because our internal branch is not yet rebased.
>
>>
>> Which would mean adding:
>>
>> Fixes: dd64956685fa ("drm/amdgpu: Remove duplicated "context still alive" check")
>
> And maybe CC stable? Or in which release is that patch upstream?
>
> Regards,
> Christian.
>
>>
>> Regards,
>>
>> Tvrtko
>>
>>> Signed-off-by: Lin.Cao <lincao12 at amd.com>
>>> ---
>>> drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 1 +
>>> 1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
>>> index 85567d0d9545..f5d5c45ddc0d 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
>>> @@ -944,6 +944,7 @@ static void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr)
>>> drm_sched_entity_fini(entity);
>>> }
>>> }
>>> + kref_put(&ctx->refcount, amdgpu_ctx_fini);
>>> }
>>> }
>>>
>>
>
More information about the amd-gfx
mailing list