Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A842C606A31C for ; Sun, 29 Nov 2026 05:54:03 +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=eGor6LpK Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D1DC110E08C; Sun, 29 Nov 2026 05:53:57 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1EF0810E08C for ; Sun, 29 Nov 2026 05:53:51 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id B788A40A2D; Sun, 29 Nov 2026 05:53:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85E201F00897; Sun, 29 Nov 2026 05:53:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795931630; bh=kfcPT4HyTek18gae+ZQsWTeZTOTWA5CCPJRG3cGq5AQ=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=eGor6LpK932is2+SMwK1XUMV3n5H3OS8n8tU094LQOhpTOgz/KqdAptqc6FO0PpPE 4TB3ULxr6e3f5Bg1XkZFgQkbSiZKxM9h88RJkojTHIqUbUL4tmZs2PkvfTDRXZJ78b 46oOzqxWvwigtjyf9k9hslm9hINezlePG6drGiTzKcSUP/o3wPIPFX0KVsj5fmqwYW DmMFhMW41v/MeJ7U5xrOV6oNxLHwUZsT3YlmBrO5yTrp2FDKo9/oP32vRJiQXNfiaR sJxRB9aFBVQeCoEsgZFvh7BX+VESk0HU+ApuytE/RXaaYORwn3VmVpKve1IMF0xqkF e7tUqwLyxXMQw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] drm/nouveau/intr: do not unmask hardware interrupts while unarmed To: "Pufan Jin" Cc: dri-devel@lists.freedesktop.org In-Reply-To: <20261129053008.70733-1-cyan2254650260@gmail.com> References: <20261129053008.70733-1-cyan2254650260@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 05:53:50 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] drm/nouveau/intr: nvkm_intr() unarms hardware while suspended or in dtor - [High] drm/nouveau/intr: nvkm_intr() returns IRQ_HANDLED on unmaskable IRQ storm - [Low] drm/nouveau/intr: missing Fixes trailer for commit 3ebd64aa3c4f -- commit 62187ac46015642d1e6928c63dbc63c4dfdf4bdd Author: Pufan Jin > drm/nouveau/intr: do not unmask hardware interrupts while unarmed > > During device initialization in nvkm_device_init(), nvkm_intr_rearm() > iterates through all legacy subdevices and calls nvkm_intr_subdev_add(), > which in turn calls nvkm_inth_allow() -> nvkm_intr_allow_locked(). > > nvkm_intr_allow_locked() directly writes to the hardware interrupt > enable registers (e.g. PMC register 0x160 on GP100/GP10B) to unmask the > subdevice's interrupt, and nvkm_inth_allow() then restores local CPU > interrupts via spin_unlock_irqrestore(). > > However, at this point, device->intr.armed is still false because arming > is performed only at the end of nvkm_intr_rearm(). On platforms where > the GPU interrupt is level-triggered and directly wired to an interrupt > controller (such as Tegra GP10B using GIC SPI 70), any pending interrupt > assertion immediately triggers the top-level interrupt handler > nvkm_intr(). > > In nvkm_intr(), because device->intr.armed is false, the handler bails > out early and returns IRQ_NONE without reading, acknowledging, or > masking the interrupt source: > > spin_lock(&device->intr.lock); > if (!device->intr.armed) > goto done_unlock; > > Because the interrupt line remains continuously asserted, this causes an > immediate, tight interrupt storm (100,000 unhandled interrupts), leading > the kernel to disable the IRQ line with "nobody cared": > > irq 142: nobody cared (try booting with the "irqpoll" option) > CPU: 0 UID: 0 PID: 361 Comm: (udev-worker) > Hardware name: NVIDIA Jetson TX2 Developer Kit (DT) > Call trace: > ... > handle_fasteoi_irq+0xe0/0x180 > gic_handle_irq+0x3c/0xc0 > _raw_spin_unlock_irqrestore+0x18/0x40 (P) > nvkm_intr_subdev_add_dev+0x6c/0x88 [nouveau] > nvkm_intr_rearm+0x138/0x1f8 [nouveau] > nvkm_device_init+0x118/0x290 [nouveau] > handlers: > [<...>] nvkm_intr [nouveau] > Disabling IRQ #142 > > Fix this issue by: > 1. Only writing to the hardware allow/block registers in > nvkm_intr_allow_locked() and nvkm_intr_block_locked() when > device->intr.armed is true. While unarmed, only the software interest > mask (intr->mask) is updated, and nvkm_intr_rearm() will program the > accumulated mask under spin_lock_irq() when arming the device. > > 2. If an unexpected interrupt arrives while unarmed, explicitly calling > nvkm_intr_unarm_locked() in nvkm_intr() to silence top-level > interrupt generation immediately. > 3. Marking ret =3D IRQ_HANDLED when unhandled interrupts are blocked by t= he > IRQ storm mitigation logic in nvkm_intr(). > > Signed-off-by: Pufan Jin [Severity: Low] Should this bug fix include a Fixes: tag for the commit that introduced nvkm_intr_allow_locked() and the unhandled interrupt loop: Fixes: 3ebd64aa3c4f ("drm/nouveau/intr: support multiple trees, and expli= cit interfaces") > diff --git a/drivers/gpu/drm/nouveau/nvkm/core/intr.c b/drivers/gpu/drm/n= ouveau/nvkm/core/intr.c > index f31aca949e2c7..0397a630a1f8f 100644 > --- a/drivers/gpu/drm/nouveau/nvkm/core/intr.c > +++ b/drivers/gpu/drm/nouveau/nvkm/core/intr.c [ ... ] > @@ -172,8 +172,10 @@ nvkm_intr(int irq, void *arg) > =20 > /* Disable all top-level interrupt sources, and re-arm MSI interrupts. = */ > spin_lock(&device->intr.lock); > - if (!device->intr.armed) > + if (!device->intr.armed) { > + nvkm_intr_unarm_locked(device); > goto done_unlock; > + } [Severity: High] Can calling nvkm_intr_unarm_locked() when !device->intr.armed access BAR0 MMIO while the GPU is powered off in D3hot or D3cold? nvkm_intr_install() registers nvkm_intr() with IRQF_SHARED, and the IRQ remains installed across system and runtime suspend after nouveau_do_suspend() sets device->intr.armed =3D false and puts the PCI device into D3hot or D3cold. If a sibling device on the shared IRQ line fires while the GPU is suspended, nvkm_intr_unarm_locked() invokes intr->func->unarm() (such as nv04_mc_intr_unarm()), issuing BAR0 MMIO writes and a synchronous MMIO read to a powered-off device. In addition, nvkm_intr_dtor() removes entries from device->intr.intr without holding device->intr.lock before calling free_irq(), so a shared IRQ arriving while unarmed during teardown can traverse device->intr.intr concurrently with list_del(&intr->head): drivers/gpu/drm/nouveau/nvkm/core/intr.c:nvkm_intr_dtor() { list_for_each_entry_safe(intr, intt, &device->intr.intr, head) { list_del(&intr->head); kfree(intr->mask); kfree(intr->stat); } if (device->intr.alloc) free_irq(device->intr.irq, device); } > @@ -215,6 +217,7 @@ nvkm_intr(int irq, void *arg) > nvkm_debug(intr->subdev, "intr%d: %08x\n", > leaf, intr->stat[leaf]); > nvkm_intr_block_locked(intr, leaf, intr->stat[leaf]); > + ret =3D IRQ_HANDLED; > } > } > } [Severity: High] Will setting ret =3D IRQ_HANDLED here cause a hardirq livelock when nvkm_intr_block_locked() cannot mask the interrupt in hardware? On GPUs using nv04_mc_intr (NV04 through GT215), intr->func->block is NULL, so nvkm_intr_block_locked() only clears intr->mask[leaf] in software before the done label calls nvkm_intr_rearm_locked() and re-enables top-level interrupts. Returning IRQ_HANDLED defeats the kernel's note_interrupt() spurious IRQ storm detector, locking up the CPU instead of disabling the runaway IRQ line. Even on GPUs where intr->func->block is implemented, intr->func->pending() populates intr->stat[leaf] with raw unmasked status bits, so if a blocked status bit remains asserted in hardware, later shared interrupts will see intr->stat[leaf] !=3D 0 and falsely return IRQ_HANDLED. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129053008.7073= 3-1-cyan2254650260@gmail.com?part=3D1