Re: [PATCH] gpio: mvebu: convert to noirq suspend/resume to prevent interrupt storm on resume

From: Rosen Penev

Date: Wed Jul 08 2026 - 15:19:43 EST


On Wed, Jul 8, 2026 at 5:11 AM Bartosz Golaszewski <brgl@xxxxxxxxxx> wrote:
>
> On Wed, 8 Jul 2026 01:35:11 +0200, Rosen Penev <rosenp@xxxxxxxxx> said:
> > The driver uses the legacy .suspend/.resume callbacks, but sets
> > IRQCHIP_MASK_ON_SUSPEND on the irq_chip. During resume, the PM core
> > runs dpm_resume_noirq() first, which calls irq_pm_resume() to unmask
> > interrupts, and only then runs dpm_resume() which invokes the driver's
> > .resume callback to restore GPIO registers (GPIO_IN_POL, GPIO_IO_CONF,
> > mask registers).
> >
> > This ordering means interrupts are unmasked while the hardware is still
> > in its reset state, potentially with incorrect polarities, causing
> > spurious level-triggered interrupts before local IRQs are re-enabled.
> >
> > Convert the driver from legacy .suspend/.resume callbacks to noirq
> > callbacks via dev_pm_ops. The noirq phase runs before resume_device_irqs()
> > on resume and after suspend_device_irqs() on suspend, ensuring GPIO
> > registers are restored before interrupts are unmasked.
> >
> > Assisted-by: opencode:big-pickle
> > Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
> > ---
> > drivers/gpio/gpio-mvebu.c | 15 +++++++++------
> > 1 file changed, 9 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
> > index a556fdb267a9..1df763e60726 100644
> > --- a/drivers/gpio/gpio-mvebu.c
> > +++ b/drivers/gpio/gpio-mvebu.c
> > @@ -979,9 +979,9 @@ static const struct of_device_id mvebu_gpio_of_match[] = {
> > },
> > };
> >
> > -static int mvebu_gpio_suspend(struct platform_device *pdev, pm_message_t state)
> > +static int mvebu_gpio_suspend(struct device *dev)
>
> Needs __maybe_unused for SET_NOIRQ_SYSTEM_SLEEP_PM_OPS().
I see __maybe_unused and #ifdef for code like this. Which is prefered?
>
> Bart