From: Sergio Paracuellos <sergio.paracuellos@gmail.com>
To: linux-gpio@vger.kernel.org
Cc: linusw@kernel.org, brgl@kernel.org, vicencb@gmail.com,
linux-kernel@vger.kernel.org, Sashiko <sashiko-bot@kernel.org>
Subject: [PATCH 1/4] gpio: mt7621: avoid corruption of shared interrupt trigger state
Date: Sat, 20 Jun 2026 14:01:33 +0200 [thread overview]
Message-ID: <20260620120136.2482872-2-sergio.paracuellos@gmail.com> (raw)
In-Reply-To: <20260620120136.2482872-1-sergio.paracuellos@gmail.com>
The bank-shared fields like 'rising' and 'falling' are modified using
non-atomic read-modify-write operations. Since every gpio chip instance
represents an entire bank of 32 pins, if 'mediatek_gpio_irq_type()' is
called concurrently for different IRQs on the same bank a possible overwrite
of each other's configuration is possible. Thus, protect this state with
'gpio_generic_lock_irqsave' lock in the same way it is handled in irp_chip
'mediatek_gpio_irq_mask()' and 'mediatek_gpio_irq_unmask()' callbacks.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
drivers/gpio/gpio-mt7621.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c
index a814885ccd5d..ceb99641baee 100644
--- a/drivers/gpio/gpio-mt7621.c
+++ b/drivers/gpio/gpio-mt7621.c
@@ -187,6 +187,8 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int type)
struct mtk_gc *rg = gpiochip_get_data(gc);
u32 mask = BIT(mt7621_gpio_hwirq_to_offset(d->hwirq, rg));
+ guard(gpio_generic_lock_irqsave)(&rg->chip);
+
if (type == IRQ_TYPE_PROBE) {
if ((rg->rising | rg->falling |
rg->hlevel | rg->llevel) & mask)
--
2.43.0
next prev parent reply other threads:[~2026-06-20 12:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-20 12:01 [PATCH 0/4] gpio: mt7621: address Sashiko complains and other cleanups Sergio Paracuellos
2026-06-20 12:01 ` Sergio Paracuellos [this message]
2026-06-22 8:12 ` [PATCH 1/4] gpio: mt7621: avoid corruption of shared interrupt trigger state Bartosz Golaszewski
2026-06-20 12:01 ` [PATCH 2/4] gpio: mt7621: more robust management of IRQ domain teardown Sergio Paracuellos
2026-06-22 8:12 ` Bartosz Golaszewski
2026-06-26 6:02 ` Sergio Paracuellos
2026-06-20 12:01 ` [PATCH 3/4] gpio: mt7621: be sure IRQ domain is created before exposing GPIO chips Sergio Paracuellos
2026-06-20 12:01 ` [PATCH 4/4] gpio: mt7621: unify naming style in driver code Sergio Paracuellos
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=20260620120136.2482872-2-sergio.paracuellos@gmail.com \
--to=sergio.paracuellos@gmail.com \
--cc=brgl@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=vicencb@gmail.com \
/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