[ISSUE + PATCH] Interrupts were enabled early by spinlock guard

Geert Uytterhoeven geert at linux-m68k.org
Thu Aug 14 07:39:58 PDT 2025


Hi Edgar,

CC loongson

On Thu, 14 Aug 2025 at 15:00, Edgar Bonet <bonet at grenoble.cnrs.fr> wrote:
> Subject: [PATCH] irqchip/atmel-aic5: Fix incorrect lock guard conversion
>
> Commit b00bee8afaca ("irqchip: Convert generic irqchip locking to guards")
> replaced calls to irq_gc_lock_irq{save,restore}() with
> guard(raw_spinlock_irq). However, in irq-atmel-aic5.c, one such guard is
> created early in the boot process, before interrupts are initially enabled.
> As its destructor enables interrupts, this results in the following warning
> on a SAMA5D31-based system:
>
>     ------------[ cut here ]------------
>     WARNING: CPU: 0 PID: 0 at init/main.c:1024 start_kernel+0x4d0/0x5dc
>     Interrupts were enabled early
>     CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.16.0 #1 NONE
>     Hardware name: Atmel SAMA5
>     Call trace:
>      unwind_backtrace from show_stack+0x10/0x14
>      show_stack from dump_stack_lvl+0x38/0x48
>      dump_stack_lvl from __warn+0x78/0xd4
>      __warn from warn_slowpath_fmt+0x98/0xc8
>      warn_slowpath_fmt from start_kernel+0x4d0/0x5dc
>      start_kernel from 0x0
>     ---[ end trace 0000000000000000 ]---
>
> Fix this by using guard(raw_spinlock_irqsave) instead.
>
> Fixes: b00bee8afaca ("irqchip: Convert generic irqchip locking to guards")
> Signed-off-by: Edgar Bonet <bonet at grenoble.cnrs.fr>

Reviewed-by: Geert Uytterhoeven <geert+renesas at glider.be>

> --- a/drivers/irqchip/irq-atmel-aic5.c
> +++ b/drivers/irqchip/irq-atmel-aic5.c
> @@ -279,7 +279,7 @@ static int aic5_irq_domain_xlate(struct irq_domain *d,
>         if (ret)
>                 return ret;
>
> -       guard(raw_spinlock_irq)(&bgc->lock);
> +       guard(raw_spinlock_irqsave)(&bgc->lock);
>         irq_reg_writel(bgc, *out_hwirq, AT91_AIC5_SSR);
>         smr = irq_reg_readl(bgc, AT91_AIC5_SMR);
>         aic_common_set_priority(intspec[2], &smr);

I think the conversions in
drivers/irqchip/irq-atmel-aic.c:aic_irq_domain_xlate() and
drivers/irqchip/irq-loongson-liointc.c:liointc_set_type()
are also wrong, and need a similar change.
Unfortunately I have no hardware to verify.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds



More information about the linux-arm-kernel mailing list