accel/amdxdna: Fix dma_fence leak when job is canceled
Lizhi Hou
maintainerPATCH 1/1 accel/amdxdna: Fix dma_fence leak when job is canceled
Currently, dma_fence_put(job->fence) is called in job notification callback. However, if a job is canceled, the notification callback is never invoked, leading to a memory leak. Move dma_fence_put(job->fence) to the job cleanup function to ensure the fence is always released.
--- drivers/accel/amdxdna/aie2_ctx.c | 1 - drivers/accel/amdxdna/amdxdna_ctx.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-)
drivers/accel/amdxdna/aie2_ctx.c +0 -1
@@ -189,7 +189,6 @@ aie2_sched_notify(struct amdxdna_sched_job *job)up (&job->hwctx->priv->job_sem); job->job_done = true; -dma_fence_put (fence);mmput_async (job->mm);aie2_job_put (job); }
drivers/accel/amdxdna/amdxdna_ctx.c +1 -0
@@ -422,6 +422,7 @@ void amdxdna_sched_job_cleanup(struct amdxdna_sched_job *job)trace_amdxdna_debug_point (job->hwctx->name, job->seq,"job release" );amdxdna_arg_bos_put (job);amdxdna_gem_put_obj (job->cmd_bo); +dma_fence_put (job->fence); } int amdxdna_cmd_submit(struct amdxdna_client *client,
Signature · 1 line
2.34.1
Quoted 7 lines · Lizhi Hou
Currently,
dma_fence_put(job->fence)is called in job notification callback. However, if a job is canceled, the notification callback is never invoked, leading to a memory leak. Movedma_fence_put(job->fence)to the job cleanup function to ensure the fence is always released.Fixes aac243092b70 ("accel/amdxdna: Add command execution")Signed-off-by Lizhi Hou <[email protected]>
Quoted 28 lines
drivers/accel/amdxdna/aie2_ctx.c | 1 - drivers/accel/amdxdna/amdxdna_ctx.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-)drivers/accel/amdxdna/aie2_ctx.c +0
-1@@ -189,7 +189,6 @@ aie2_sched_notify(struct amdxdna_sched_job *job)up (&job->hwctx->priv->job_sem); job->job_done = true; -dma_fence_put (fence);mmput_async (job->mm);aie2_job_put (job); }drivers/accel/amdxdna/amdxdna_ctx.c +1
-0@@ -422,6 +422,7 @@ void amdxdna_sched_job_cleanup(struct amdxdna_sched_job *job)trace_amdxdna_debug_point (job->hwctx->name, job->seq,"job release" );amdxdna_arg_bos_put (job);amdxdna_gem_put_obj (job->cmd_bo); +dma_fence_put (job->fence); } int amdxdna_cmd_submit(struct amdxdna_client *client,
Applied to drm-misc-next.
Quoted 39 lines · Mario Limonciello (AMD) (kernel.org)
Quoted 7 lines · Lizhi Hou
Currently,
dma_fence_put(job->fence)is called in job notification callback. However, if a job is canceled, the notification callback is never invoked, leading to a memory leak. Movedma_fence_put(job->fence)to the job cleanup function to ensure the fence is always released.Fixes aac243092b70 ("accel/amdxdna: Add command execution")Signed-off-by Lizhi Hou <[email protected]>Reviewed-by Mario Limonciello (AMD) <[email protected]>> ---Quoted 27 lines
drivers/accel/amdxdna/aie2_ctx.c | 1 -
drivers/accel/amdxdna/amdxdna_ctx.c| 1 +2 files changed, 1 insertion(+), 1 deletion(-)drivers/accel/amdxdna/aie2_ctx.c +0
-1@@ -189,7 +189,6 @@ aie2_sched_notify(struct amdxdna_sched_job *job) up(&job->hwctx->priv->job_sem); job->job_done = true; - dma_fence_put(fence); mmput_async(job->mm); aie2_job_put(job); }drivers/accel/amdxdna/amdxdna_ctx.c +1
-0@@ -422,6 +422,7 @@ void amdxdna_sched_job_cleanup(struct amdxdna_sched_job *job) trace_amdxdna_debug_point(job->hwctx->name, job->seq, "job release"); amdxdna_arg_bos_put(job); amdxdna_gem_put_obj(job->cmd_bo); + dma_fence_put(job->fence); } int amdxdna_cmd_submit(struct amdxdna_client *client,