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=1796349312; b=s2MAwlEg6Ve7zmS9EogCUjqROSX7cTmR3KYCZkef42yqk4I110tAfo6oOrqfuQmfY+V7 StZREwiHwoN+eqbRdp7cAYOHKANaV9n8JoP8N2vP8wKNrghjqqK1a7w8fk5f4K5v8hd2O W6p0xR+w/5+6sReW8ob5Xmus1madHGYn/H0IMpoxiGTPvFoibQIQdwqaPERo4C2qJAuxx rXaPbX+oN9JxzvLbB2iljZltFOwKv3mtVP6z6QoXqjXnDiWcXy3vyVWOuUVpoc/PDD3gU cnuMVHRq1e+KqalzNkX3DUIW0txF3f5/TQ34YrFKYvZzgBp5T0004A7bPOuV5B4EH9w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796349312; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=P4FxDFyed53RXP/gD6ch5lnFSKa0crtDzS2ECu9bpuk=; b=hXhAfRVryWMvwtI4NdoHUtv30ixgj6/7+MLyU1MQ32jfXrIDUaNpWNDrdT7U5bzQyCC5 reQp7TLxXUMF37RdE0CL0Mn6oe14fneJJfn/QrM8CT3U8sf9GonkmEL2AJVOAZXKJ7BZa Mq0sJYIJxfXJ+3MpuBvEiB1ofo3EaozrcUA00nhKxOwoBJ5hJrU9dtChEvMPbvDQd9bQk hm3RFPjieECp2YqRxwPbFdEPyfOHsE101au4WnUW9/8bb15L55BSCz61U1occFFpKSkka 1U84rf/v3WXF2iMMQ7KbHSOJ9FIP7NvYcXkAV2EWqxcde7zD1WDuI0v4hRtvm2+dVcw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fny9StK4; 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 AB703606A322 for ; Fri, 4 Dec 2026 01:55:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fny9StK4 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02D241F000C2; Fri, 4 Dec 2026 01:55:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796349312; bh=P4FxDFyed53RXP/gD6ch5lnFSKa0crtDzS2ECu9bpuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fny9StK4R/QgOagCllup8NJbd10Qt21jAboHlafdGzprm9jm8v20IGXLjB/FqKd/w 5yHigGZN7/t/mv43BinvHyF+9FFeRrCOpQN4X/p4r8zY/XnfJWvlEXEdkTl0b15gYj tROucbuJAVHJ6VKIxKV1MnUlNtu6ivTS9TlhzlUFeuZ+VrpiLaFWOS/5Ns2JBnhkMt oASqoZWL24UskXRhuAxgpUFp76O6EjUXP+4dJhC2ZiHS6UJrqR+OyT8i8Jj2Oe7f+u W7ItFewWFzP0NwGVnKrRfwvLFhaRQcBVTnWzJ3UGfKz+tsVOymT+gZe5GK9kF9Ey3f 2ml3+EDCnli4A== From: Sasha Levin To: stable@vger.kernel.org Cc: =?UTF-8?q?Ma=C3=ADra=20Canal?= , Iago Toral Quiroga , Sasha Levin Subject: [PATCH 6.18.y] drm/vc4: Rebuild the V3D interrupt mask on every power transition Date: Thu, 3 Dec 2026 20:55:10 -0500 Message-ID: <20261204015428.1740041-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120220-radish-stir-e585@gregkh> References: <2026120220-radish-stir-e585@gregkh> 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 From: Maíra Canal [ Upstream commit 83dd19480c105c8bf96c93fb18b2ea554b44445d ] The out-of-memory interrupt is armed once, by bin_bo_alloc(), when the binner BO is allocated. vc4_irq_disable() masks it on the way down, vc4_irq_enable() brings back only the render bits, and bin_bo_alloc() does not run again for a binner BO that is still referenced. An overflow after an autosuspend therefore raises nothing and the binner stalls, until the hangcheck resets the GPU and arms the interrupt again. Therefore, derive the out-of-memory bit in vc4_irq_enable() from whether a binner BO exists, which is the condition bin_bo_alloc() was standing in for. While here, clear the complement of the wanted mask while enabling. V3D_INTENA and V3D_INTDIS are set/clear registers and the driver only ever set bits, so a source left enabled will stay enabled and can reach vc4_irq(), which returns IRQ_NONE for anything outside the three bits it handles. Cc: stable@vger.kernel.org Fixes: 35c8b4b2c0fe ("drm/vc4: Allocate binner bo when starting to use the V3D") Reviewed-by: Iago Toral Quiroga Link: https://patch.msgid.link/20261111-vc4-irq-cleanup-v2-2-aa757bb742f2@igalia.com Signed-off-by: Maíra Canal [ sashal: Kept the existing V3D_DRIVER_IRQS define (upstream removes it) because vc4_irq_prepare() still uses it here, and context lines differ slightly due to older surrounding code. ] Signed-off-by: Sasha Levin --- drivers/gpu/drm/vc4/vc4_irq.c | 37 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_irq.c b/drivers/gpu/drm/vc4/vc4_irq.c index 7d783441ffe26..ac897393aab9f 100644 --- a/drivers/gpu/drm/vc4/vc4_irq.c +++ b/drivers/gpu/drm/vc4/vc4_irq.c @@ -266,6 +266,7 @@ void vc4_irq_enable(struct drm_device *dev) { struct vc4_dev *vc4 = to_vc4_dev(dev); + u32 mask = V3D_INT_FLDONE | V3D_INT_FRDONE; if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4)) return; @@ -273,10 +274,18 @@ vc4_irq_enable(struct drm_device *dev) if (!vc4->v3d) return; - /* Enable the render done interrupts. The out-of-memory interrupt is - * enabled as soon as we have a binner BO allocated. + /* Arming the OOM interrupt before there is a binner BO would raise an + * interrupt nothing can clear. */ - V3D_WRITE(V3D_INTENA, V3D_INT_FLDONE | V3D_INT_FRDONE); + if (vc4->bin_bo) + mask |= V3D_INT_OUTOMEM; + + /* Clear any pending interrupts someone might have left around for us. */ + V3D_WRITE(V3D_INTCTL, mask); + + /* Enable our set of interrupts, masking out any others. */ + V3D_WRITE(V3D_INTDIS, ~mask); + V3D_WRITE(V3D_INTENA, mask); } void @@ -291,14 +300,14 @@ vc4_irq_disable(struct drm_device *dev) return; /* Disable sending interrupts for our driver's IRQs. */ - V3D_WRITE(V3D_INTDIS, V3D_DRIVER_IRQS); - - /* Clear any pending interrupts we might have left. */ - V3D_WRITE(V3D_INTCTL, V3D_DRIVER_IRQS); + V3D_WRITE(V3D_INTDIS, ~0); /* Finish any interrupt handler still in flight. */ synchronize_irq(vc4->irq); + /* Clear any pending interrupts we might have left. */ + V3D_WRITE(V3D_INTCTL, ~0); + cancel_work_sync(&vc4->overflow_mem_work); } @@ -344,16 +353,12 @@ void vc4_irq_reset(struct drm_device *dev) if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4)) return; - /* Acknowledge any stale IRQs. */ - V3D_WRITE(V3D_INTCTL, V3D_DRIVER_IRQS); - - /* - * Turn all our interrupts on. Binner out of memory is the - * only one we expect to trigger at this point, since we've - * just come from poweron and haven't supplied any overflow - * memory yet. + /* bin_bo_alloc() may arm OUTOMEM between the bin_bo check and the + * INTDIS write in vc4_irq_enable(), which would then mask it again. */ - V3D_WRITE(V3D_INTENA, V3D_DRIVER_IRQS); + scoped_guard(mutex, &vc4->bin_bo_lock) { + vc4_irq_enable(dev); + } spin_lock_irqsave(&vc4->job_lock, irqflags); vc4_cancel_bin_job(dev); -- 2.53.0