mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] drm/nouveau/intr: do not unmask hardware interrupts while unarmed
@ 2026-12-04 11:33 Pufan Jin
  2026-12-04 21:09 ` Lyude Paul
  0 siblings, 1 reply; 2+ messages in thread
From: Pufan Jin @ 2026-12-04 11:33 UTC (permalink / raw)
  To: Lyude Paul, Lyude Paul, Danilo Krummrich, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: dri-devel, nouveau, linux-kernel

During device initialization in nvkm_device_init(), nvkm_intr_rearm()
iterates through legacy subdevices and calls nvkm_intr_subdev_add(),
which calls nvkm_inth_allow() -> nvkm_intr_allow_locked().

nvkm_intr_allow_locked() directly writes to the hardware interrupt
allow registers (e.g. PMC register 0x160 on GP100/GP10B) to unmask
the subdevice's interrupt in hardware, and nvkm_inth_allow() then
restores 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 or clearing the interrupt:

    spin_lock(&device->intr.lock);
    if (!device->intr.armed)
        goto done_unlock;

Because the level-triggered line remains continuously asserted, this
causes an immediate interrupt storm, leading the kernel to disable
the IRQ line with "nobody cared":

    irq 142: nobody cared (try booting with the "irqpoll" option)
    handlers:
    [<...>] nvkm_intr [nouveau]
    Disabling IRQ #142

Fix this by 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 later program
and unmask the accumulated mask under spin_lock_irq() when arming the
device.

Fixes: 3ebd64aa3c4f ("drm/nouveau/intr: support multiple trees, and explicit interfaces")
Signed-off-by: Pufan Jin <cyan2254650260@gmail.com>
---
Changes in v2:
- Drop the nvkm_intr_unarm_locked() call from the !device->intr.armed
  path in nvkm_intr() to avoid BAR0 MMIO accesses while suspended in
  D3 and racing with nvkm_intr_dtor().
- Drop setting ret = IRQ_HANDLED in the unhandled-interrupt storm
  mitigation path so spurious IRQ detection still works on GPUs
  without intr->func->block (such as nv04_mc_intr).
- Add Fixes tag for commit 3ebd64aa3c4f.

 drivers/gpu/drm/nouveau/nvkm/core/intr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/intr.c b/drivers/gpu/drm/nouveau/nvkm/core/intr.c
index f31aca949e..ff9f1c36f1 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/intr.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/intr.c
@@ -91,7 +91,7 @@ static void
 nvkm_intr_allow_locked(struct nvkm_intr *intr, int leaf, u32 mask)
 {
 	intr->mask[leaf] |= mask;
-	if (intr->func->allow) {
+	if (intr->subdev->device->intr.armed && intr->func->allow) {
 		if (intr->func->reset)
 			intr->func->reset(intr, leaf, mask);
 		intr->func->allow(intr, leaf, mask);
@@ -120,7 +120,7 @@ static void
 nvkm_intr_block_locked(struct nvkm_intr *intr, int leaf, u32 mask)
 {
 	intr->mask[leaf] &= ~mask;
-	if (intr->func->block)
+	if (intr->subdev->device->intr.armed && intr->func->block)
 		intr->func->block(intr, leaf, mask);
 }
 
-- 
2.56.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] drm/nouveau/intr: do not unmask hardware interrupts while unarmed
  2026-12-04 11:33 [PATCH v2] drm/nouveau/intr: do not unmask hardware interrupts while unarmed Pufan Jin
@ 2026-12-04 21:09 ` Lyude Paul
  0 siblings, 0 replies; 2+ messages in thread
From: Lyude Paul @ 2026-12-04 21:09 UTC (permalink / raw)
  To: Pufan Jin, Danilo Krummrich, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: dri-devel, nouveau, linux-kernel

Reviewed-by: Lyude Paul <lyude.paul@maintainer.cc>

Thanks for sending out a V2 with the additional fixes, I reverted the
V1 from the drm-misc-fixes branch and will push this one in a moment.

On Fri, 2026-12-04 at 19:33 +0800, Pufan Jin wrote:
> During device initialization in nvkm_device_init(), nvkm_intr_rearm()
> iterates through legacy subdevices and calls nvkm_intr_subdev_add(),
> which calls nvkm_inth_allow() -> nvkm_intr_allow_locked().
> 
> nvkm_intr_allow_locked() directly writes to the hardware interrupt
> allow registers (e.g. PMC register 0x160 on GP100/GP10B) to unmask
> the subdevice's interrupt in hardware, and nvkm_inth_allow() then
> restores 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 or clearing the
> interrupt:
> 
>     spin_lock(&device->intr.lock);
>     if (!device->intr.armed)
>         goto done_unlock;
> 
> Because the level-triggered line remains continuously asserted, this
> causes an immediate interrupt storm, leading the kernel to disable
> the IRQ line with "nobody cared":
> 
>     irq 142: nobody cared (try booting with the "irqpoll" option)
>     handlers:
>     [<...>] nvkm_intr [nouveau]
>     Disabling IRQ #142
> 
> Fix this by 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 later
> program
> and unmask the accumulated mask under spin_lock_irq() when arming the
> device.
> 
> Fixes: 3ebd64aa3c4f ("drm/nouveau/intr: support multiple trees, and
> explicit interfaces")
> Signed-off-by: Pufan Jin <cyan2254650260@gmail.com>
> ---
> Changes in v2:
> - Drop the nvkm_intr_unarm_locked() call from the !device->intr.armed
>   path in nvkm_intr() to avoid BAR0 MMIO accesses while suspended in
>   D3 and racing with nvkm_intr_dtor().
> - Drop setting ret = IRQ_HANDLED in the unhandled-interrupt storm
>   mitigation path so spurious IRQ detection still works on GPUs
>   without intr->func->block (such as nv04_mc_intr).
> - Add Fixes tag for commit 3ebd64aa3c4f.
> 
>  drivers/gpu/drm/nouveau/nvkm/core/intr.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nvkm/core/intr.c
> b/drivers/gpu/drm/nouveau/nvkm/core/intr.c
> index f31aca949e..ff9f1c36f1 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/core/intr.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/core/intr.c
> @@ -91,7 +91,7 @@ static void
>  nvkm_intr_allow_locked(struct nvkm_intr *intr, int leaf, u32 mask)
>  {
>  	intr->mask[leaf] |= mask;
> -	if (intr->func->allow) {
> +	if (intr->subdev->device->intr.armed && intr->func->allow) {
>  		if (intr->func->reset)
>  			intr->func->reset(intr, leaf, mask);
>  		intr->func->allow(intr, leaf, mask);
> @@ -120,7 +120,7 @@ static void
>  nvkm_intr_block_locked(struct nvkm_intr *intr, int leaf, u32 mask)
>  {
>  	intr->mask[leaf] &= ~mask;
> -	if (intr->func->block)
> +	if (intr->subdev->device->intr.armed && intr->func->block)
>  		intr->func->block(intr, leaf, mask);
>  }
>  

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-04 21:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-04 11:33 [PATCH v2] drm/nouveau/intr: do not unmask hardware interrupts while unarmed Pufan Jin
2026-12-04 21:09 ` Lyude Paul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®