lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdXqRpuy8gsz+0a0xTp6VWfMD0=WWdS84jWvF31O9i4MZw@mail.gmail.com>
Date: Mon, 12 May 2025 11:17:48 +0200
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Francesco Dolcini <francesco@...cini.it>
Cc: Linus Walleij <linus.walleij@...aro.org>, Bartosz Golaszewski <brgl@...ev.pl>, 
	Emanuele Ghidoli <emanuele.ghidoli@...adex.com>, linux-gpio@...r.kernel.org, 
	linux-kernel@...r.kernel.org, Andy Shevchenko <andriy.shevchenko@...el.com>, 
	Marek Vasut <marek.vasut@...il.com>, stable@...r.kernel.org, 
	Francesco Dolcini <francesco.dolcini@...adex.com>
Subject: Re: [PATCH v2] gpio: pca953x: fix IRQ storm on system wake up

Hi Francesco,

On Fri, 9 May 2025 at 16:18, Francesco Dolcini <francesco@...cini.it> wrote:
> From: Emanuele Ghidoli <emanuele.ghidoli@...adex.com>
>
> 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: b76574300504 ("gpio: pca953x: Restore registers after suspend/resume cycle")
> Cc: stable@...r.kernel.org
> Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@...adex.com>
> Signed-off-by: Francesco Dolcini <francesco.dolcini@...adex.com>
> ---
> v1 -> v2
>  - Instead of calling PM ops with disabled interrupts, just disable the
>    irq while going in suspend and re-enable it after restoring the
>    context in resume function.

Thanks for the update!

> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -1226,6 +1226,8 @@ static int pca953x_restore_context(struct pca953x_chip *chip)
>
>         guard(mutex)(&chip->i2c_lock);
>
> +       if (chip->client->irq > 0)
> +               enable_irq(chip->client->irq);
>         regcache_cache_only(chip->regmap, false);
>         regcache_mark_dirty(chip->regmap);
>         ret = pca953x_regcache_sync(chip);
> @@ -1238,6 +1240,10 @@ static int pca953x_restore_context(struct pca953x_chip *chip)
>  static void pca953x_save_context(struct pca953x_chip *chip)
>  {
>         guard(mutex)(&chip->i2c_lock);
> +
> +       /* Disable IRQ to prevent early triggering while regmap "cache only" is on */
> +       if (chip->client->irq > 0)
> +               disable_irq(chip->client->irq);
>         regcache_cache_only(chip->regmap, true);
>  }

While this does not cause the regression seen on Salvator-XS with
the earlier approach[1], I expect this will break using a GPIO as a
wake-up source?

[1] https://lore.kernel.org/linux-gpio/CAMuHMdVnKX23yi7ir1LVxfXAMeeWMFzM+cdgSSTNjpn1OnC2xw@mail.gmail.com

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ