* [PATCH 5.10.y v2] gpio: dwapb: mask/unmask IRQ when disable/enale it
@ 2026-11-03 11:10 Miguel Gazquez (Schneider Electric)
2026-11-03 14:52 ` Sasha Levin
0 siblings, 1 reply; 2+ messages in thread
From: Miguel Gazquez (Schneider Electric) @ 2026-11-03 11:10 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>
---
Changes in v2:
- Fix typo
- Link to v1: https://patch.msgid.link/20261103-dwapb-fix-v1-1-c93ef2f20695@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..51bed3adafc1f 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 [flat|nested] 2+ messages in thread
* Re: [PATCH 5.10.y v2] gpio: dwapb: mask/unmask IRQ when disable/enale it
2026-11-03 11:10 [PATCH 5.10.y v2] gpio: dwapb: mask/unmask IRQ when disable/enale it Miguel Gazquez (Schneider Electric)
@ 2026-11-03 14:52 ` Sasha Levin
0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2026-11-03 14:52 UTC (permalink / raw)
To: stable, Hoan Tran, Serge Semin, Linus Walleij,
Bartosz Golaszewski, Sebastian Hesselbarth, Alan Tull,
Jamie Iles
Cc: Sasha Levin, 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.
Queued for 5.10, thanks.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-03 14:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 11:10 [PATCH 5.10.y v2] gpio: dwapb: mask/unmask IRQ when disable/enale it Miguel Gazquez (Schneider Electric)
2026-11-03 14:52 ` Sasha Levin
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®