From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796383715; b=ounpQM21RiMDfwgOyTHCR6ZHsUv+gNR19/I00OLtSKbg3dlGp++CT3IK8OFLurKxXmJM xRbIlW9mx2M3uEA8W0CqcMRTiDbCNkCZKWYazpzssbaQQXEFFv8VL1OOLOoMJgRPN4gG7 LmVmSuug8wNgGNk4f1+sB7//whq6WCxQ5dQE4I2TMBxhHNnnZdyfyjp/Y9BHZfGJCySDP V/jcvCDbIYGG/yX8zaKBdt7t/z7Lm2LSegYxaEXmdvtOS7915sNQGQDoS0GZuwB4In5Yh zEU2u8doXAU4kicYRu5LMAckLHre6XTaC5NmFXbz4E+fcr1pqq5/NQNbNaXrRI5DC+w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383715; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=x4pbryXU8j3eur+ALdZeMqVzadY7/gp2ijlGhZFS1o0=; b=f2FO77DU5J5L6igETHhaQvaq6+qqf/U5Py2oePUivkOaVNRT5uqhQVFBaxDSvSV8ah/p uNnM3RJGXu5AvYERPiUolk7wlbEqFG5R0mKA1G2S6CM07wXBw3lnMXxeIq0kJvh5isyU9 +uHQvVhXW8+bzGHsTBfAJQTYUb6YQahh1qYfc7gJXTp2FOZ07w93IDv0VY9qdWjqFTjFZ OnzaUMxGLjpDO4fGsVyJ0sK3x6h5mz3lon5ZyhoAyuqjQ0f0t4rxsgMR/m7tcLh0kw+3m 6A8FiaFHb2XZgceBhYXOzVfGjuB2q0rMa/g9vY3mRdvOqvO3tpbQytCH1WvDL94g8Og== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=dc5+QtOJ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4BAC9606A32D; Fri, 4 Dec 2026 11:28:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=dc5+QtOJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85E541F000CE; Fri, 4 Dec 2026 11:28:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383714; bh=x4pbryXU8j3eur+ALdZeMqVzadY7/gp2ijlGhZFS1o0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dc5+QtOJjaZOVYtjo97kIXyT2feyBoLM4mBSFrNKpT/ZsVmy2hgGBt+3NqGB/e2hI pahhQDpO5hEpy2VabaQ8awbVV99w0ctN7qcKq84awUpwEpHqW2IfgQlkAU9C6CqYyO ijX35qS1Vo3iMM+ZnEKcmgEkfaIW2447wLCLO/4Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Iago Toral Quiroga , =?UTF-8?q?Ma=C3=ADra=20Canal?= Subject: [PATCH 6.12 341/555] drm/vc4: Clear the slice caches before resetting a stalled GPU Date: Fri, 4 Dec 2026 19:06:24 +0900 Message-ID: <20261204100622.994350015@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maíra Canal commit af1cf92e8617a7f7aa24b415596cbf64b76a12e7 upstream. 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 Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-4-5b8adc2c84fe@igalia.com Signed-off-by: Maíra Canal Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/vc4/vc4_drv.h | 5 +++++ drivers/gpu/drm/vc4/vc4_gem.c | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) --- a/drivers/gpu/drm/vc4/vc4_drv.h +++ b/drivers/gpu/drm/vc4/vc4_drv.h @@ -225,6 +225,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; --- a/drivers/gpu/drm/vc4/vc4_gem.c +++ b/drivers/gpu/drm/vc4/vc4_gem.c @@ -41,8 +41,7 @@ vc4_queue_hangcheck(struct drm_device *d { 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 { @@ -341,6 +340,7 @@ vc4_hangcheck_elapsed(struct timer_list /* 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; } @@ -357,11 +357,27 @@ vc4_hangcheck_elapsed(struct timer_list 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