mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: shao.mingyin@zte.com.cn
Cc: linusw@kernel.org, brgl@kernel.org, linux-gpio@vger.kernel.org,
	 linux-kernel@vger.kernel.org, andrew@codeconstruct.com.au,
	wbg@kernel.org,  opendmb@gmail.com,
	florian.fainelli@broadcom.com,
	 bcm-kernel-feedback-list@broadcom.com, jelonek.jonas@gmail.com
Subject: Re: [PATCH 1/5] gpio: rcar: don't clobber INTMSK when disabling a single line
Date: Mon, 9 Nov 2026 15:40:36 +0100	[thread overview]
Message-ID: <CAMuHMdXHSU3QLanoVyAr3a5akukwDbCHWYoGiLT8HfuCGvHmog@mail.gmail.com> (raw)
In-Reply-To: <20261107161252647FthWsffiqzpLz7zrKd2ux@zte.com.cn>

Hi Shao,

On Sat, 7 Nov 2026 at 09:13, <shao.mingyin@zte.com.cn> 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@vger.kernel.org
> Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>

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@glider.be>

> --- 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@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

  reply	other threads:[~2026-11-09 14:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07  8:12 [PATCH 0/5] gpio: fix IRQ handling and probe error paths in five drivers shao.mingyin
2026-11-07  8:12 ` [PATCH 1/5] gpio: rcar: don't clobber INTMSK when disabling a single line shao.mingyin
2026-11-09 14:40   ` Geert Uytterhoeven [this message]
2026-11-09 14:57     ` shao.mingyin
2026-11-07  8:12 ` [PATCH 2/5] gpio: aspeed-sgpio: propagate IRQ setup error in probe shao.mingyin
2026-11-09  3:55   ` Andrew Jeffery
2026-11-07  8:12 ` [PATCH 3/5] gpio: 104-idi-48: fix max_register blocking the IRQ register shao.mingyin
2026-11-07 20:19   ` William Breathitt Gray
2026-11-07  8:12 ` [PATCH 4/5] gpio: brcmstb: don't turn platform_get_irq errors into -ENOENT shao.mingyin
2026-11-10  4:39   ` Florian Fainelli
2026-11-07  8:12 ` [PATCH 5/5] gpio: line-mux: fix unsigned truncation of property count error shao.mingyin
2026-11-09  8:29   ` Jonas Jelonek
2026-11-09 10:21     ` shao.mingyin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMuHMdXHSU3QLanoVyAr3a5akukwDbCHWYoGiLT8HfuCGvHmog@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=andrew@codeconstruct.com.au \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=brgl@kernel.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=jelonek.jonas@gmail.com \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=opendmb@gmail.com \
    --cc=shao.mingyin@zte.com.cn \
    --cc=wbg@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®