[PATCH] drm/sched: Add return value for drm_sched_entity_push_job

2025-03-26 Thread Qianyi Liu
. This allows callers to: 1. Detect when job submission fails 2. Perform proper cleanup (e.g., release job and fence allocations) 3. Avoid potential memory leaks in error paths Signed-off-by: Qianyi Liu --- drivers/gpu/drm/scheduler/sched_entity.c | 8 ++-- include/drm/gpu_scheduler.h

[PATCH V4] drm/sched: Fix fence reference count leak

2025-03-15 Thread Qianyi Liu
From: qianyi liu The last_scheduled fence leaks when an entity is being killed and adding the cleanup callback fails. Decrement the reference count of prev when dma_fence_add_callback() fails, ensuring proper balance. Cc: sta...@vger.kernel.org Fixes: 2fdb8a8f07c2 ("drm/scheduler: r

[PATCH V3] drm/sched: Fix fence reference count leak

2025-03-10 Thread Qianyi Liu
> Sorry for the delay > > On Wed, 2025-02-26 at 17:05 +0800, Qianyi Liu wrote: >> From: qianyi liu >> >> The last_scheduled fence leaked when an entity was being killed and >> adding its callback failed. > > s/leaked/leaks > > s/was being/is being

[PATCH V3] drm/sched: Fix fence reference count leak

2025-03-10 Thread Qianyi Liu
xes: 2fdb8a8f07c2 ("drm/scheduler: rework entity flush, kill and fini") >> Signed-off-by: qianyi liu > >> From: qianyi liu >> >> The last_scheduled fence leaked when an entity was being killed and >> adding its callback failed. >> >> Decremen

[PATCH V3] drm/sched: Fix fence reference count leak

2025-02-26 Thread Qianyi Liu
From: qianyi liu The last_scheduled fence leaked when an entity was being killed and adding its callback failed. Decrement the reference count of prev when dma_fence_add_callback() fails, ensuring proper balance. Cc: sta...@vger.kernel.org Fixes: 2fdb8a8f07c2 ("drm/scheduler: rework e

Re: [PATCH V2] drm/sched: fix fence reference count leak

2025-02-25 Thread Qianyi Liu
Hello Markus, >… >> fence callback add fails. > failed? >> To fix this, we should decrement the reference count of prev when >… > See also: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.14-rc4#n94

Re: [PATCH] drm/scheduler: Fix mem leak when last_scheduled signaled

2025-02-25 Thread Qianyi Liu
> Oh, and importantly, I forgot: > Since this is clearly a bug fix, it needs a "Fixes: " tag and put the > stable kernel on Cc. OK, thanks for reminding. Qianyi.

[PATCH V2] drm/sched: fix fence reference count leak

2025-02-25 Thread Qianyi Liu
From: qianyi liu We leaked last_scheduled fences when the entity was being killed and the fence callback add fails. To fix this, we should decrement the reference count of prev when dma_fence_add_callback() fails, ensuring proper balance. v2: * Make commit message more clearly. (Philipp and

Re: [PATCH] drm/scheduler: Fix mem leak when last_scheduled signaled

2025-02-25 Thread Qianyi Liu
Hello Matt, >> >> But also be handy of could share the kmemleak trace. >> > Agree kmemleak trace would good, include in commit message, but the > patch looks correct to me. Unfortunately, as trace involves private code of our driver, our driver has not yet officially entered the community yet,

Re: [PATCH] drm/scheduler: Fix mem leak when last_scheduled signaled

2025-02-24 Thread Qianyi Liu
Hello Philipp, Thank you for your patient reply. Let's first clarify the issue and send a new patch if necessary. As soon as it enters the drm_sched_entity_kill function, the entity ->last_scheduled reference count is incremented by 1. If there are still jobs in the current entity, it will enter

Re: [PATCH] drm/scheduler: Fix mem leak when last_scheduled signaled

2025-02-24 Thread Qianyi Liu
Thank you for your patient reply. Let's first clarify the issue and send a new patch if necessary. As soon as it enters the drm_sched_entity_kill function, the entity ->last_stchedled reference count is incremented by 1. If there are still jobs in the current entity, it will enter the while loop,

[PATCH] drm/scheduler: Fix mem leak when last_scheduled signaled

2025-02-20 Thread qianyi liu
Problem: If prev(last_scheduled) was already signaled I encountred a memory leak in drm_sched_entity_fini. This is because the prev(last_scheduled) fence is not free properly. Fix: Balance the prev(last_scheduled) fence refcnt when dma_fence_add_callback failed. Signed-off-by: qianyi liu

[PATCH] drm/sched: coding style fixes: miscellaneous

2024-08-28 Thread qianyi liu
This patch fixes the following checkpatch: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' WARNING: Missing a blank line after declarations WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable Signed-off-by: qianyi liu --- drive