Skip to content

Commit 3e38f94

Browse files
eghidoliBartosz Golaszewski
authored andcommitted
gpio: pca953x: fix IRQ storm on system wake up
If an input changes state during wake-up and is used as an interrupt source, the IRQ handler reads the volatile input register to clear the interrupt mask and deassert the IRQ line. However, the IRQ handler is triggered before access to the register is granted, causing the read operation to fail. As a result, the IRQ handler enters a loop, repeatedly printing the "failed reading register" message, until `pca953x_resume()` is eventually called, which restores the driver context and enables access to registers. Fix by disabling the IRQ line before entering suspend mode, and re-enabling it after the driver context is restored in `pca953x_resume()`. An IRQ can be disabled with disable_irq() and still wake the system as long as the IRQ has wake enabled, so the wake-up functionality is preserved. Fixes: b765743 ("gpio: pca953x: Restore registers after suspend/resume cycle") Cc: stable@vger.kernel.org Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@toradex.com> Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/20250512095441.31645-1-francesco@dolcini.it Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent 579cb52 commit 3e38f94

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/gpio/gpio-pca953x.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,8 @@ static int pca953x_restore_context(struct pca953x_chip *chip)
12041204

12051205
guard(mutex)(&chip->i2c_lock);
12061206

1207+
if (chip->client->irq > 0)
1208+
enable_irq(chip->client->irq);
12071209
regcache_cache_only(chip->regmap, false);
12081210
regcache_mark_dirty(chip->regmap);
12091211
ret = pca953x_regcache_sync(chip);
@@ -1216,6 +1218,10 @@ static int pca953x_restore_context(struct pca953x_chip *chip)
12161218
static void pca953x_save_context(struct pca953x_chip *chip)
12171219
{
12181220
guard(mutex)(&chip->i2c_lock);
1221+
1222+
/* Disable IRQ to prevent early triggering while regmap "cache only" is on */
1223+
if (chip->client->irq > 0)
1224+
disable_irq(chip->client->irq);
12191225
regcache_cache_only(chip->regmap, true);
12201226
}
12211227

0 commit comments

Comments
 (0)