summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaíra Canal <mcanal@igalia.com>2026-11-18 18:47:31 -0300
committerMaíra Canal <mcanal@igalia.com>2026-11-19 10:40:54 -0300
commitaf1cf92e8617a7f7aa24b415596cbf64b76a12e7 (patch)
tree6115442d60224852cb50282f556a4a271fa9e999
parentc0e1ed41ad86cf5230d64dc5f2c6d2e3aeb59937 (diff)
drm/vc4: Clear the slice caches before resetting a stalled GPU
Starting shader code at varying offsets makes the GFXH-16 icache livelock unlikely, but not impossible. When the livelock happens, the QPUs make no progress and the hangcheck resets the GPU, losing the job. When the hangcheck finds no progress, clear the slice instruction and uniforms caches and check again before resetting. If the stall is a livelock, clearing the caches can break it and let the job continue. Drop round_jiffies_up() from the hangcheck timer, so checks run every 100 ms instead of at the next whole second. This shortens the screen freeze before the caches are cleared. Long jobs are unaffected: while the control lists advance, the hangcheck won't clear the caches or reset the GPU. Cc: stable@vger.kernel.org Fixes: d5b1a78a772f ("drm/vc4: Add support for drawing 3D frames.") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/16652 Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-4-5b8adc2c84fe@igalia.com Signed-off-by: Maíra Canal <mcanal@igalia.com>
-rw-r--r--drivers/gpu/drm/vc4/vc4_drv.h5
-rw-r--r--drivers/gpu/drm/vc4/vc4_gem.c20
2 files changed, 23 insertions, 2 deletions
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
index 62ce83322d1b..dae325a3854d 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -218,6 +218,11 @@ struct vc4_dev {
struct {
struct timer_list timer;
struct work_struct reset_work;
+
+ /* The instruction and uniforms caches were cleared at the
+ * last check that found no progress.
+ */
+ bool caches_cleared;
} hangcheck;
struct drm_modeset_lock ctm_state_lock;
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
index 956be198f8a7..9898eb1ef077 100644
--- a/drivers/gpu/drm/vc4/vc4_gem.c
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
@@ -43,8 +43,7 @@ vc4_queue_hangcheck(struct drm_device *dev)
{
struct vc4_dev *vc4 = to_vc4_dev(dev);
- mod_timer(&vc4->hangcheck.timer,
- round_jiffies_up(jiffies + msecs_to_jiffies(100)));
+ mod_timer(&vc4->hangcheck.timer, jiffies + msecs_to_jiffies(100));
}
struct vc4_hang_state {
@@ -355,6 +354,7 @@ vc4_hangcheck_elapsed(struct timer_list *t)
/* If idle, we can stop watching for hangs. */
if (!bin_exec && !render_exec) {
+ vc4->hangcheck.caches_cleared = false;
spin_unlock_irqrestore(&vc4->job_lock, irqflags);
return;
}
@@ -371,11 +371,27 @@ vc4_hangcheck_elapsed(struct timer_list *t)
bin_exec->last_ct0ca = ct0ca;
if (render_exec)
render_exec->last_ct1ca = ct1ca;
+
+ vc4->hangcheck.caches_cleared = false;
+
spin_unlock_irqrestore(&vc4->job_lock, irqflags);
vc4_queue_hangcheck(dev);
return;
}
+ /* Clear the slice caches to workaround GFXH-16 */
+ if (!vc4->hangcheck.caches_cleared) {
+ V3D_WRITE(V3D_SLCACTL, VC4_SET_FIELD(0xf, V3D_SLCACTL_ICC) |
+ VC4_SET_FIELD(0xf, V3D_SLCACTL_UCC));
+
+ vc4->hangcheck.caches_cleared = true;
+ spin_unlock_irqrestore(&vc4->job_lock, irqflags);
+ vc4_queue_hangcheck(dev);
+ return;
+ }
+
+ vc4->hangcheck.caches_cleared = false;
+
spin_unlock_irqrestore(&vc4->job_lock, irqflags);
/* We've gone too long with no progress, reset. This has to