1 From 5258ca4ad089548a72657522443b9c3e46fd125b Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Ma=C3=ADra=20Canal?= <mcanal@igalia.com>
3 Date: Sat, 22 Feb 2025 14:40:21 -0300
4 Subject: [PATCH] drm/v3d: Don't run jobs that have errors flagged in its fence
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 The V3D driver still relies on `drm_sched_increase_karma()` and
10 `drm_sched_resubmit_jobs()` for resubmissions when a timeout occurs.
11 The function `drm_sched_increase_karma()` marks the job as guilty, while
12 `drm_sched_resubmit_jobs()` sets an error (-ECANCELED) in the DMA fence of
15 Because of this, we must check whether the job’s DMA fence has been
16 flagged with an error before executing the job. Otherwise, the same guilty
17 job may be resubmitted indefinitely, causing repeated GPU resets.
19 This patch adds a check for an error on the job's fence to prevent running
20 a guilty job that was previously flagged when the GPU timed out.
22 Note that the CPU and CACHE_CLEAN queues do not require this check, as
23 their jobs are executed synchronously once the DRM scheduler starts them.
25 Cc: stable@vger.kernel.org
26 Fixes: d223f98f0209 ("drm/v3d: Add support for compute shader dispatch.")
27 Fixes: 1584f16ca96e ("drm/v3d: Add support for submitting jobs to the TFU.")
28 Signed-off-by: Maíra Canal <mcanal@igalia.com>
30 drivers/gpu/drm/v3d/v3d_sched.c | 9 ++++++++-
31 1 file changed, 8 insertions(+), 1 deletion(-)
33 --- a/drivers/gpu/drm/v3d/v3d_sched.c
34 +++ b/drivers/gpu/drm/v3d/v3d_sched.c
35 @@ -292,11 +292,15 @@ v3d_tfu_job_run(struct drm_sched_job *sc
36 struct drm_device *dev = &v3d->drm;
37 struct dma_fence *fence;
39 + if (unlikely(job->base.base.s_fence->finished.error))
44 fence = v3d_fence_create(v3d, V3D_TFU);
49 if (job->base.irq_fence)
50 dma_fence_put(job->base.irq_fence);
51 job->base.irq_fence = dma_fence_get(fence);
52 @@ -333,6 +337,9 @@ v3d_csd_job_run(struct drm_sched_job *sc
53 struct dma_fence *fence;
54 int i, csd_cfg0_reg, csd_cfg_reg_count;
56 + if (unlikely(job->base.base.s_fence->finished.error))
61 v3d_invalidate_caches(v3d);