[PATCH] gpio: pca953x: Preserve wakeup accounting on parent IRQ failure
From: Sahaj Chaudhari
Date: Sun Oct 18 2026 - 12:11:32 EST
pca953x_irq_set_wake() updates wakeup_path before asking the parent
IRQ controller to change its wake state. If irq_set_irq_wake() fails,
the IRQ core rolls back its wake state but the driver's counter remains
changed.
A failed enable can therefore leave the expander marked as part of the
wakeup path when no child IRQ has successfully enabled wakeup. A failed
disable can make the driver stop retaining power even though wakeup is
still enabled. The suspend and resume paths use this counter to decide
whether to disable or enable the regulator.
Update wakeup_path only after the parent operation succeeds, leaving it
unchanged on error.
Fixes: f70fbc15bae2 ("gpio: pca953x: Configure wake-up path when wake-up is enabled")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Sahaj Chaudhari <sahaj123.sc@xxxxxxxxx>
---
Testing:
- Built the ARM64 kernel with the TI SDK, CONFIG_GPIO_PCA953X_IRQ=y,
CONFIG_PM_SLEEP=y and CONFIG_SUSPEND=y, containing this fix alone.
- Signed the FIT through the existing development signing workflow.
U-Boot verified the required signature and RAM-booted the kernel on
AM642. Confirmed release 7.3.0-rc7-00012-g1b4d5b76f7e9 over SSH, both
expected expanders bound to pca953x, and an untainted kernel.
- Ran the isolated exact-function harness on an AM642 CPU: seven checks,
two failures before and none after. The same isolated checks passed
host ASan and UBSan. This harness simulates kernel and hardware APIs.
The boot test covers boot and probe, not the wake failure path. Neither
expander has IRQs configured in this board's device tree, so the parent
wake failures were exercised only in the simulated harness. The board
was returned to its original signed kernel after the smoke test.
drivers/gpio/gpio-pca953x.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index aac9ea7520b6..869ed4264d48 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -838,13 +838,18 @@ static int pca953x_irq_set_wake(struct irq_data *d, unsigned int on)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct pca953x_chip *chip = gpiochip_get_data(gc);
+ int ret;
+
+ ret = irq_set_irq_wake(chip->client->irq, on);
+ if (ret)
+ return ret;
if (on)
atomic_inc(&chip->wakeup_path);
else
atomic_dec(&chip->wakeup_path);
- return irq_set_irq_wake(chip->client->irq, on);
+ return 0;
}
static void pca953x_irq_bus_lock(struct irq_data *d)
base-commit: ac46dac1613a7c971e28e16d3a7a6ad4b1ae6c5a
--
2.43.0