Re: [PATCH 1/5] gpio: rcar: don't clobber INTMSK when disabling a single line
From: Geert Uytterhoeven
Date: Mon Nov 09 2026 - 09:41:04 EST
Hi Shao,
On Sat, 7 Nov 2026 at 09:13, <shao.mingyin@xxxxxxxxxx> wrote:
> gpio_rcar_irq_disable() writes ~BIT(hwirq) to the whole INTMSK register,
> which clears the bit of the line being disabled but sets every other bit
> in the bank to 1. Since a set bit in INTMSK means "interrupt enabled"
> (gpio_rcar_irq_handler() only handles lines whose INTMSK bit is set),
> this disables one GPIO interrupt while collateral-enabling all the
> other GPIO interrupts of the bank, which can cause a storm of spurious
> cascaded interrupts on level-triggered lines.
>
> Do a read-modify-write to clear only the line being disabled.
>
> Fixes: 119f5e448d32 ("gpio: Renesas R-Car GPIO driver V3")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
Thanks for your patch!
The GPIO interrupt masking operation procedure is indeed a bit uncommon:
- Interrupts are disabled (masked) by writing 0 to bits in INTMSK,
- Interrupts are enabled (unmasked) by writing 1 to bits in INTMSKCLR.
Section 10.2.7 ("Interrupt Mask Register n (INTMSK0 to INTMSKn)")
in the main PDF file in [1] states:
"Only writing 0 to this register is effective."
Section 10.2.8 ("Interrupt Mask Clear Register n (MSKCLR0 to MSKCLRn)"):
"Only writing 1 to MSKCLR is effective".
Hence setting extra bits in the INTMSK register does not enable all
other GPIO interrupts.
NAKed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> --- a/drivers/gpio/gpio-rcar.c
> +++ b/drivers/gpio/gpio-rcar.c
> @@ -129,7 +129,7 @@
> struct gpio_rcar_priv *p = gpiochip_get_data(gc);
> irq_hw_number_t hwirq = irqd_to_hwirq(d);
>
> - gpio_rcar_write(p, INTMSK, ~BIT(hwirq));
> + gpio_rcar_write(p, INTMSK, gpio_rcar_read(p, INTMSK) & ~BIT(hwirq));
> gpiochip_disable_irq(gc, hwirq);
> }
[1] https://www.renesas.com/en/document/mah/rzg-series-2nd-generation-users-manual-hardware?r=1054546
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
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