* [PATCH 5.10.y] gpio: dwapb: mask/unmask IRQ when disable/enale it
@ 2026-11-03 10:21 Miguel Gazquez (Schneider Electric)
2026-11-03 10:26 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Miguel Gazquez (Schneider Electric) @ 2026-11-03 10:21 UTC (permalink / raw)
To: stable, Hoan Tran, Serge Semin, Linus Walleij,
Bartosz Golaszewski, Sebastian Hesselbarth, Alan Tull, Jamie Iles
Cc: Benjamin Robin, Thomas Petazzoni, linux-gpio, linux-kernel,
Ralph Siemsen, xiongxin, stable, Riwen Lu, Andy Shevchenko,
Bartosz Golaszewski, Greg Kroah-Hartman,
Miguel Gazquez (Schneider Electric)
From: xiongxin <xiongxin@kylinos.cn>
commit 1cc3542c76acb5f59001e3e562eba672f1983355 upstream.
In the hardware implementation of the I2C HID driver based on DesignWare
GPIO IRQ chip, when the user continues to use the I2C HID device in the
suspend process, the I2C HID interrupt will be masked after the resume
process is finished.
This is because the disable_irq()/enable_irq() of the DesignWare GPIO
driver does not synchronize the IRQ mask register state. In normal use
of the I2C HID procedure, the GPIO IRQ irq_mask()/irq_unmask() functions
are called in pairs. In case of an exception, i2c_hid_core_suspend()
calls disable_irq() to disable the GPIO IRQ. With low probability, this
causes irq_unmask() to not be called, which causes the GPIO IRQ to be
masked and not unmasked in enable_irq(), raising an exception.
Add synchronization to the masked register state in the
dwapb_irq_enable()/dwapb_irq_disable() function. mask the GPIO IRQ
before disabling it. After enabling the GPIO IRQ, unmask the IRQ.
Fixes: 7779b3455697 ("gpio: add a driver for the Synopsys DesignWare APB GPIO block")
Cc: stable@kernel.org
Co-developed-by: Riwen Lu <luriwen@kylinos.cn>
Signed-off-by: Riwen Lu <luriwen@kylinos.cn>
Signed-off-by: xiongxin <xiongxin@kylinos.cn>
Acked-by: Serge Semin <fancer.lancer@gmail.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Miguel Gazquez (Schneider Electric) <miguel.gazquez@bootlin.com>
---
drivers/gpio/gpio-dwapb.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
index d6240ae0f87ca..c2c9b42a60865 100644
--- a/drivers/gpio/gpio-dwapb.c
+++ b/drivers/gpio/gpio-dwapb.c
@@ -282,13 +282,15 @@ static void dwapb_irq_enable(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct dwapb_gpio *gpio = to_dwapb_gpio(gc);
+ irq_hw_number_t hwirq = irqd_to_hwirq(d);
unsigned long flags;
u32 val;
spin_lock_irqsave(&gc->bgpio_lock, flags);
- val = dwapb_read(gpio, GPIO_INTEN);
- val |= BIT(irqd_to_hwirq(d));
+ val = dwapb_read(gpio, GPIO_INTEN) | BIT(hwirq)
dwapb_write(gpio, GPIO_INTEN, val);
+ val = dwapb_read(gpio, GPIO_INTMASK) & ~BIT(hwirq);
+ dwapb_write(gpio, GPIO_INTMASK, val);
spin_unlock_irqrestore(&gc->bgpio_lock, flags);
}
@@ -296,12 +298,14 @@ static void dwapb_irq_disable(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct dwapb_gpio *gpio = to_dwapb_gpio(gc);
+ irq_hw_number_t hwirq = irqd_to_hwirq(d);
unsigned long flags;
u32 val;
spin_lock_irqsave(&gc->bgpio_lock, flags);
- val = dwapb_read(gpio, GPIO_INTEN);
- val &= ~BIT(irqd_to_hwirq(d));
+ val = dwapb_read(gpio, GPIO_INTMASK) | BIT(hwirq);
+ dwapb_write(gpio, GPIO_INTMASK, val);
+ val = dwapb_read(gpio, GPIO_INTEN) & ~BIT(hwirq);
dwapb_write(gpio, GPIO_INTEN, val);
spin_unlock_irqrestore(&gc->bgpio_lock, flags);
}
---
base-commit: f23b568f7597f98a241454018a34361ce2523c05
change-id: 20261103-dwapb-fix-ab5776557f6c
Best regards,
--
Miguel Gazquez (Schneider Electric) <miguel.gazquez@bootlin.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 5.10.y] gpio: dwapb: mask/unmask IRQ when disable/enale it
2026-11-03 10:21 [PATCH 5.10.y] gpio: dwapb: mask/unmask IRQ when disable/enale it Miguel Gazquez (Schneider Electric)
@ 2026-11-03 10:26 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-03 10:26 UTC (permalink / raw)
To: Miguel Gazquez (Schneider Electric); +Cc: linux-gpio
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] gpio: dwapb: missing semicolon in dwapb_irq_enable() causes build failure
--
commit 8cbb31bc1b5314b8269d987acc47c5043fa04ab3
Author: xiongxin <xiongxin@kylinos.cn>
gpio: dwapb: mask/unmask IRQ when disable/enale it
This commit synchronizes the GPIO_INTMASK register state in
dwapb_irq_enable() and dwapb_irq_disable() so that interrupts are masked when
disabled and unmasked when enabled.
> diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
> index d6240ae0f87ca..c2c9b42a60865 100644
> --- a/drivers/gpio/gpio-dwapb.c
> +++ b/drivers/gpio/gpio-dwapb.c
> @@ -282,13 +282,15 @@ static void dwapb_irq_enable(struct irq_data *d)
> {
> struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> struct dwapb_gpio *gpio = to_dwapb_gpio(gc);
> + irq_hw_number_t hwirq = irqd_to_hwirq(d);
> unsigned long flags;
> u32 val;
>
> spin_lock_irqsave(&gc->bgpio_lock, flags);
> - val = dwapb_read(gpio, GPIO_INTEN);
> - val |= BIT(irqd_to_hwirq(d));
> + val = dwapb_read(gpio, GPIO_INTEN) | BIT(hwirq)
> dwapb_write(gpio, GPIO_INTEN, val);
[Severity: Low]
In dwapb_irq_enable() in drivers/gpio/gpio-dwapb.c, the assignment to val is
missing a trailing semicolon before the dwapb_write(gpio, GPIO_INTEN, val)
call. Does this break compilation when CONFIG_GPIO_DWAPB is enabled?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261103-dwapb-fix-v1-1-c93ef2f20695@bootlin.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-03 10:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-03 10:21 [PATCH 5.10.y] gpio: dwapb: mask/unmask IRQ when disable/enale it Miguel Gazquez (Schneider Electric)
2026-11-03 10:26 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.