Re: [PATCH v3 1/5] genirq: Synchronize in-flight handlers during NMI teardown

From: Thomas Gleixner

Date: Fri Sep 04 2026 - 05:17:56 EST


On Wed, Sep 02 2026 at 18:54, Mayank Rungta wrote:
> diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
> index 2fbff2618a1e..a9973b61163a 100644
> --- a/kernel/irq/manage.c
> +++ b/kernel/irq/manage.c
> @@ -1379,6 +1379,14 @@ static bool irq_supports_nmi(struct irq_desc *desc)
> if (d->chip->irq_bus_lock || d->chip->irq_bus_sync_unlock)
> return false;
>
> + /*
> + * NMIs cannot set IRQD_IRQ_INPROGRESS because they cannot acquire
> + * spinlocks. Synchronous disable and teardown require querying the
> + * hardware state via ->irq_get_irqchip_state().
> + */
> + if (!d->chip->irq_get_irqchip_state)
> + return false;
> +
> return d->chip->flags & IRQCHIP_SUPPORTS_NMI;
> }
>
> @@ -2034,11 +2042,20 @@ static const void *__cleanup_nmi(unsigned int irq, struct irq_desc *desc)
> struct irqaction *action = NULL;
> const char *devname = NULL;
>
> + guard(mutex)(&desc->request_mutex);
> +
> scoped_guard(raw_spinlock_irqsave, &desc->lock) {
> - irq_nmi_teardown(desc);
> + irq_settings_clr_disable_unlazy(desc);
> + irq_shutdown(desc);
> + }
>
> - desc->istate &= ~IRQS_NMI;
> + /*
> + * Ensure all in-flight NMI handlers on other CPUs complete before
> + * clearing desc->action or tearing down NMI state.
> + */
> + __synchronize_hardirq(desc, true);

NMIs are strictly per CPU interrupts. So how is this supposed to work
correctly when looking at irqchip_state(ACTIVE) ?

Marc?