drm/v3d: Ensure job pointer is set to NULL after job completion
Subsystems (3)
Maíra Canal
maintainerPATCH 1/2 drm/v3d: Ensure job pointer is set to NULL after job completion
After a job completes, the corresponding pointer in the device must be set to NULL. Failing to do so triggers a warning when unloading the driver, as it appears the job is still active. To prevent this, assign the job pointer to NULL after completing the job and signaling the fence, indicating the job has finished.
--- drivers/gpu/drm/v3d/v3d_irq.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/v3d/v3d_irq.c +4 -0
@@ -108,6 +108,7 @@ v3d_irq(int irq, void *arg)v3d_job_update_stats (&v3d->bin_job->base,V3D_BIN );trace_v3d_bcl_irq (&v3d->drm, fence->seqno);dma_fence_signal (&fence->base); + v3d->bin_job =NULL ; status =IRQ_HANDLED ; }
@@ -118,6 +119,7 @@ v3d_irq(int irq, void *arg)v3d_job_update_stats (&v3d->render_job->base,V3D_RENDER );trace_v3d_rcl_irq (&v3d->drm, fence->seqno);dma_fence_signal (&fence->base); + v3d->render_job =NULL ; status =IRQ_HANDLED ; }
@@ -128,6 +130,7 @@ v3d_irq(int irq, void *arg)v3d_job_update_stats (&v3d->csd_job->base,V3D_CSD );trace_v3d_csd_irq (&v3d->drm, fence->seqno);dma_fence_signal (&fence->base); + v3d->csd_job =NULL ; status =IRQ_HANDLED ; }
@@ -165,6 +168,7 @@ v3d_hub_irq(int irq, void *arg)v3d_job_update_stats (&v3d->tfu_job->base,V3D_TFU );trace_v3d_tfu_irq (&v3d->drm, fence->seqno);dma_fence_signal (&fence->base); + v3d->tfu_job =NULL ; status =IRQ_HANDLED ; }
Signature · 1 line
2.39.5 (Apple Git-154)
Maíra Canal
maintainerPATCH 2/2 drm/v3d: Remove `v3d->cpu_job`
CPU jobs, like Clean Cache jobs, execute synchronously once the DRM scheduler starts running them. Consequently, a global v3d->cpu_job variable is unnecessary, as everything is managed within the v3d_cpu_job_run() function.
This commit removes the v3d->cpu_job pointer, as it is not needed.
--- drivers/gpu/drm/v3d/v3d_drv.h | 1 - drivers/gpu/drm/v3d/v3d_sched.c | 2 -- 2 files changed, 3 deletions(-)
drivers/gpu/drm/v3d/v3d_drv.h +0 -1
@@ -147,7 +147,6 @@ struct v3d_dev {struct v3d_render_job *render_job;struct v3d_tfu_job *tfu_job;struct v3d_csd_job *csd_job; -struct v3d_cpu_job *cpu_job;struct v3d_queue_state queue[V3D_MAX_QUEUES ];
drivers/gpu/drm/v3d/v3d_sched.c +0 -2
@@ -656,8 +656,6 @@ v3d_cpu_job_run(struct drm_sched_job *sched_job)struct v3d_cpu_job *job =to_cpu_job (sched_job);struct v3d_dev *v3d = job->base.v3d; - v3d->cpu_job = job; -if (job->job_type >=ARRAY_SIZE (cpu_job_function)) {DRM_DEBUG_DRIVER ("Unknown CPU job: %d\n" , job->job_type);return NULL ;
Signature · 1 line
2.39.5 (Apple Git-154)
Re: [PATCH 2/2] drm/v3d: Remove `v3d->cpu_job`
Quoted 38 lines · Maíra Canal
CPU jobs, like Clean Cache jobs, execute synchronously once the DRM scheduler starts running them. Consequently, a global
v3d->cpu_jobvariable is unnecessary, as everything is managed within thev3d_cpu_job_run()function.This commit removes the
v3d->cpu_jobpointer, as it is not needed.Signed-off-by Maíra Canal <[email protected]>--- drivers/gpu/drm/v3d/v3d_drv.h | 1 - drivers/gpu/drm/v3d/v3d_sched.c | 2 -- 2 files changed, 3 deletions(-)drivers/gpu/drm/v3d/v3d_drv.h +0
-1@@ -147,7 +147,6 @@ struct v3d_dev {struct v3d_render_job *render_job;struct v3d_tfu_job *tfu_job;struct v3d_csd_job *csd_job; -struct v3d_cpu_job *cpu_job;struct v3d_queue_state queue[V3D_MAX_QUEUES ];drivers/gpu/drm/v3d/v3d_sched.c +0
-2@@ -656,8 +656,6 @@ v3d_cpu_job_run(struct drm_sched_job *sched_job)struct v3d_cpu_job *job =to_cpu_job (sched_job);struct v3d_dev *v3d = job->base.v3d; - v3d->cpu_job = job; -if (job->job_type >=ARRAY_SIZE (cpu_job_function)) {DRM_DEBUG_DRIVER ("Unknown CPU job: %d\n" , job->job_type);return NULL ;
Maíra Canal
maintainerRe: [PATCH 2/2] drm/v3d: Remove `v3d->cpu_job`
Hi Chema,
Quoted 1 line · Chema Casanova
Reviewed-by Jose Maria Casanova Crespo <[email protected]>
Thanks for the review! Applied to misc/kernel.git (drm-misc-next).
Best Regards,
- Maíra
Quoted 37 lines · Maíra Canal
Quoted 35 lines
CPU jobs, like Clean Cache jobs, execute synchronously once the DRM scheduler starts running them. Consequently, a global
v3d->cpu_jobvariable is unnecessary, as everything is managed within thev3d_cpu_job_run()function.This commit removes the
v3d->cpu_jobpointer, as it is not needed.Signed-off-by Maíra Canal <[email protected]>---
drivers/gpu/drm/v3d/v3d_drv.h | 1 -
drivers/gpu/drm/v3d/v3d_sched.c| 2 --2 files changed, 3 deletions(-)drivers/gpu/drm/v3d/v3d_drv.h +0
-1@@ -147,7 +147,6 @@ struct v3d_dev { struct v3d_render_job *render_job; struct v3d_tfu_job *tfu_job; struct v3d_csd_job *csd_job; - struct v3d_cpu_job *cpu_job; struct v3d_queue_state queue[V3D_MAX_QUEUES];drivers/gpu/drm/v3d/v3d_sched.c +0
-2@@ -656,8 +656,6 @@ v3d_cpu_job_run(struct drm_sched_job *sched_job) struct v3d_cpu_job *job = to_cpu_job(sched_job); struct v3d_dev *v3d = job->base.v3d; - v3d->cpu_job = job; - if (job->job_type >= ARRAY_SIZE(cpu_job_function)) { DRM_DEBUG_DRIVER("Unknown CPU job: %d\n", job->job_type); return NULL;
Quoted 7 lines · Maíra Canal
After a job completes, the corresponding pointer in the device must be set to NULL. Failing to do so triggers a warning when unloading the driver, as it appears the job is still active. To prevent this, assign the job pointer to NULL after completing the job and signaling the fence, indicating the job has finished.
Fixes 14d1d1908696 ("drm/v3d: Remove the bad signaled() implementation")
Just a question, should we add next commit to the Fixes tag:
Quoted 34 lines
Signed-off-by Maíra Canal <[email protected]>--- drivers/gpu/drm/v3d/v3d_irq.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/v3d/v3d_irq.c +3
-0@@ -108,6 +108,7 @@ v3d_irq(int irq, void *arg)v3d_job_update_stats (&v3d->bin_job->base,V3D_BIN );trace_v3d_bcl_irq (&v3d->drm, fence->seqno);dma_fence_signal (&fence->base); + v3d->bin_job =NULL ; status =IRQ_HANDLED ; }@@ -118,6 +119,7 @@ v3d_irq(int irq, void *arg)v3d_job_update_stats (&v3d->render_job->base,V3D_RENDER );trace_v3d_rcl_irq (&v3d->drm, fence->seqno);dma_fence_signal (&fence->base); + v3d->render_job =NULL ; status =IRQ_HANDLED ; }@@ -128,6 +130,7 @@ v3d_irq(int irq, void *arg)v3d_job_update_stats (&v3d->csd_job->base,V3D_CSD );trace_v3d_csd_irq (&v3d->drm, fence->seqno);dma_fence_signal (&fence->base); + v3d->csd_job =NULL ; status =IRQ_HANDLED ; }
drivers/gpu/drm/v3d/v3d_irq.c v3d_hub_irq(int irq, void *arg) · line 174
Quoted 7 lines
drivers/gpu/drm/v3d/v3d_irq.c +1
-0@@ -165,6 +168,7 @@ v3d_hub_irq(int irq, void *arg)v3d_job_update_stats (&v3d->tfu_job->base,V3D_TFU );trace_v3d_tfu_irq (&v3d->drm, fence->seqno);dma_fence_signal (&fence->base); + v3d->tfu_job =NULL ; status =IRQ_HANDLED ; }
With or without my previous comment this is:
Thanks for fixing this so fast.
Regards,
Chema
Maíra Canal
maintainerHi Chema,
Thanks for the review!
Quoted 7 lines · Chema Casanova
Quoted 6 lines · Maíra Canal
After a job completes, the corresponding pointer in the device must be set to NULL. Failing to do so triggers a warning when unloading the driver, as it appears the job is still active. To prevent this, assign the job pointer to NULL after completing the job and signaling the fence, indicating the job has finished.
Quoted 5 lines
Quoted 1 line
Fixes 14d1d1908696 ("drm/v3d: Remove the bad signaled() implementation")Just a question, should we add next commit to the Fixes tag:
Fixes 79d94360d50f ("drm/v3d: wait for all jobs to finish before unregistering")
I believe it is better to have the older reference, as it will ease the backport to kernels older than 79d94360d50f.
I just applied the patch to misc/kernel.git (drm-misc-fixes).
Best Regards,
- Maíra
Quoted 49 lines
Quoted 32 lines
Signed-off-by Maíra Canal <[email protected]>---
drivers/gpu/drm/v3d/v3d_irq.c| 4 ++++1 file changed, 4 insertions(+)drivers/gpu/drm/v3d/v3d_irq.c +3
-0@@ -108,6 +108,7 @@ v3d_irq(int irq, void *arg) v3d_job_update_stats(&v3d->bin_job->base, V3D_BIN); trace_v3d_bcl_irq(&v3d->drm, fence->seqno); dma_fence_signal(&fence->base); + v3d->bin_job = NULL; status = IRQ_HANDLED; }@@ -118,6 +119,7 @@ v3d_irq(int irq, void *arg) v3d_job_update_stats(&v3d->render_job->base, V3D_RENDER); trace_v3d_rcl_irq(&v3d->drm, fence->seqno); dma_fence_signal(&fence->base); + v3d->render_job = NULL; status = IRQ_HANDLED; }@@ -128,6 +130,7 @@ v3d_irq(int irq, void *arg) v3d_job_update_stats(&v3d->csd_job->base, V3D_CSD); trace_v3d_csd_irq(&v3d->drm, fence->seqno); dma_fence_signal(&fence->base); + v3d->csd_job = NULL; status = IRQ_HANDLED; }drivers/gpu/drm/v3d/v3d_irq.c v3d_hub_irq(int irq, void *arg) · line 173
Quoted 6 lines
drivers/gpu/drm/v3d/v3d_irq.c +1
-0@@ -165,6 +168,7 @@ v3d_hub_irq(int irq, void *arg) v3d_job_update_stats(&v3d->tfu_job->base, V3D_TFU); trace_v3d_tfu_irq(&v3d->drm, fence->seqno); dma_fence_signal(&fence->base); + v3d->tfu_job = NULL; status = IRQ_HANDLED; }With or without my previous comment this is:
Reviewed-by Jose Maria Casanova Crespo <[email protected]>Thanks for fixing this so fast.
Regards,
Chema