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=1796382336; b=pPD/KVu4duw87t0APAcexIsb8W76XNue+kpvmx8UMvqrnb233N+/n0v8O3eR+XKUrL78 xwCcrhbize4j1smSVe5bgWgciiMB1c7joAsYACI6GQUTM0YRUz81UScKxqO5Bgh58Mk7F 98sPqU2Vdl3hhLe4K3pgPJxPeS4biG61Xf6BTBYB6Nv56SdZm5vvopUEUpWZ6ywhWc8Ji ELYwvPAWlFr0S0sTlTQUSgRMFWZmYYJrWliyZGczwzyGUz0ZsPOuZEhf17a3ABybJ/HNP Fh/kht6TNLuuWbloYOLkjnE3KbgxAxJYGEdo3z7fNt3VgObxUJTbraC0di4HyOTeR4A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382336; 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=xyqEbZEiZAt0381pm6cnKHIGxYFp79bbT7KSmxGW9YM=; b=33PvuinayKQiBFDZnh/9ehmMX+abPzoRW1XkmCN4fbLMRby5Reu2UznjbwNzLdBj03tX BDw2ARiZYL32K3ETTEXT59JSU8W8QHV88rbVu0NpuZM+ONCMnmr4txPZmHkkQG2Ye4JH/ GuflSinhWGJcscgPID6YzQUk3KxAkSNIllL0B8g/1K6q7qY5dtaYa2DswZcNr5fP7I5KF brYEHfXq2cjnBwUONy5AwrvykBFBXrMrkQDaaq1quLUW0Jujqjs+wAMt5F+QRVSjknDmQ E+8jksMj6HhCcBb4UMdOeq4Vh5Dald5an5YnwSAv54+gID+wUyl4o1F6lT/Z5Zuwirg== 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=bEgBF4Te; 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 B1863606A682; Fri, 4 Dec 2026 11:05:36 +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=bEgBF4Te Received: by smtp.kernel.org (Postfix) with ESMTPSA id D80CF1F0092C; Fri, 4 Dec 2026 11:05:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382336; bh=xyqEbZEiZAt0381pm6cnKHIGxYFp79bbT7KSmxGW9YM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bEgBF4TeW7DVgAJh3Y3na8+aZ3dvq8SZCdCIieBcbRu9Vg9BbyrozseiBAKDr9d7X Dw+EzOGZnHEmCGnirqni69rOqGHm/wyNdb+fwi68iLVuCBoElUgI5KkEinxkiM+oYj uisNUYuJ1PTu3mtFzEVHXdFmx4vVDBz75ywpGAj8= 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.18 369/703] drm/vc4: Clear the slice caches before resetting a stalled GPU Date: Fri, 4 Dec 2026 19:04:28 +0900 Message-ID: <20261204100637.624925584@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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 @@ -223,6 +223,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 @@ -42,8 +42,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 { @@ -342,6 +341,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; } @@ -358,11 +358,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