Skip to content

Commit

Permalink
drm/v3d: Set job pointer to NULL when the job's fence has an error
Browse files Browse the repository at this point in the history
Similar to commit e4b5ccd ("drm/v3d: Ensure job pointer is set to
NULL after job completion"), ensure the job pointer is set to `NULL` when
a job's fence has an error. Failing to do so can trigger kernel warnings
in specific scenarios, such as:

1. v3d_csd_job_run() assigns `v3d->csd_job = job`
2. CSD job exceeds hang limit, causing a timeout → v3d_gpu_reset_for_timeout()
3. GPU reset
4. drm_sched_resubmit_jobs() sets the job's fence to `-ECANCELED`.
5. v3d_csd_job_run() detects the fence error and returns NULL, not
   submitting the job to the GPU
6. User-space runs `modprobe -r v3d`
7. v3d_gem_destroy()

v3d_gem_destroy() triggers a warning indicating that the CSD job never
ended, as we didn't set `v3d->csd_job` to NULL after the timeout. The same
can also happen to BIN, RENDER, and TFU jobs.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-v3d-gpu-reset-fixes-v4-2-c1e780d8e096@igalia.com
  • Loading branch information
Maíra Canal committed Mar 13, 2025
1 parent 80cbee8 commit c3e4a25
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions drivers/gpu/drm/v3d/v3d_sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,12 @@ static struct dma_fence *v3d_bin_job_run(struct drm_sched_job *sched_job)
struct dma_fence *fence;
unsigned long irqflags;

if (unlikely(job->base.base.s_fence->finished.error))
if (unlikely(job->base.base.s_fence->finished.error)) {
spin_lock_irqsave(&v3d->job_lock, irqflags);
v3d->bin_job = NULL;
spin_unlock_irqrestore(&v3d->job_lock, irqflags);
return NULL;
}

/* Lock required around bin_job update vs
* v3d_overflow_mem_work().
Expand Down Expand Up @@ -281,8 +285,10 @@ static struct dma_fence *v3d_render_job_run(struct drm_sched_job *sched_job)
struct drm_device *dev = &v3d->drm;
struct dma_fence *fence;

if (unlikely(job->base.base.s_fence->finished.error))
if (unlikely(job->base.base.s_fence->finished.error)) {
v3d->render_job = NULL;
return NULL;
}

v3d->render_job = job;

Expand Down Expand Up @@ -327,8 +333,10 @@ v3d_tfu_job_run(struct drm_sched_job *sched_job)
struct drm_device *dev = &v3d->drm;
struct dma_fence *fence;

if (unlikely(job->base.base.s_fence->finished.error))
if (unlikely(job->base.base.s_fence->finished.error)) {
v3d->tfu_job = NULL;
return NULL;
}

v3d->tfu_job = job;

Expand Down Expand Up @@ -373,8 +381,10 @@ v3d_csd_job_run(struct drm_sched_job *sched_job)
struct dma_fence *fence;
int i, csd_cfg0_reg;

if (unlikely(job->base.base.s_fence->finished.error))
if (unlikely(job->base.base.s_fence->finished.error)) {
v3d->csd_job = NULL;
return NULL;
}

v3d->csd_job = job;

Expand Down

0 comments on commit c3e4a25

Please sign in to comment.