[PATCH] gpio: davinci: Clear interrupt status in every bank on suspend

From: Sahaj Chaudhari

Date: Sun Oct 18 2026 - 13:06:44 EST


davinci_gpio_save_context() saves the registers of each 32-GPIO
register bank, but clears interrupt status only after the loop. At that
point g refers to the last bank, so pending status in all preceding
banks is left uncleared.

Move the interrupt-status write into the per-bank loop so that the
existing suspend-time clearing covers every register bank. Single-bank
controllers retain the same behavior.

Fixes: 0651a730924b ("gpio: davinci: Add support for system suspend/resume PM")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Sahaj Chaudhari <sahaj123.sc@xxxxxxxxx>
---
Testing:
- Built an ARM64 kernel with CONFIG_GPIO_DAVINCI=y,
CONFIG_PM_SLEEP=y and CONFIG_SUSPEND=y, containing this fix alone.
- Booted it on AM642 and confirmed all three DaVinci GPIO controllers
bound, with an untainted kernel.
- Validated the extracted save-context function in a standalone
userspace harness with simulated write-one-to-clear MMIO, using one
through five register banks. Verified that every bank is cleared
exactly once and GPIO register and bank-enable context is preserved.
The unpatched function fails clearing checks for two through five
banks; the patched function passes. Ran the harness natively on
AM642 and under host ASan/UBSan.

The suspend callback has not been exercised on the live GPIO hardware.
The regression results above use simulated MMIO, not real pending IRQs.

drivers/gpio/gpio-davinci.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index cccbaea1dec2..fc2b9bef7efc 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -611,10 +611,10 @@ static void davinci_gpio_save_context(struct davinci_gpio_controller *chips,
context->set_data = readl_relaxed(&g->set_data);
context->set_rising = readl_relaxed(&g->set_rising);
context->set_falling = readl_relaxed(&g->set_falling);
- }

- /* Clear all interrupt status registers */
- writel_relaxed(GENMASK(31, 0), &g->intstat);
+ /* Clear stale interrupt status for this bank. */
+ writel_relaxed(GENMASK(31, 0), &g->intstat);
+ }
}

static void davinci_gpio_restore_context(struct davinci_gpio_controller *chips,

base-commit: ac46dac1613a7c971e28e16d3a7a6ad4b1ae6c5a
--
2.43.0