From: Rosen Penev <rosenp@gmail.com>
To: linux-gpio@vger.kernel.org
Cc: Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v3] gpio: mvebu: convert to noirq suspend/resume to prevent interrupt storm on resume
Date: Mon, 28 Sep 2026 19:26:02 -0700 [thread overview]
Message-ID: <20260929022602.23306-1-rosenp@gmail.com> (raw)
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: LLM
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
v3: use NOIRQ_SYSTEM_SLEEP_PM_OPS instead.
v2: add __maybe_unused to fix compilation
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 267e6d5bacd0..27894acf8d34 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -994,9 +994,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)
{
- struct mvebu_gpio_chip *mvchip = platform_get_drvdata(pdev);
+ struct mvebu_gpio_chip *mvchip = dev_get_drvdata(dev);
int i;
regmap_read(mvchip->regs, GPIO_OUT_OFF + mvchip->offset,
@@ -1046,9 +1046,9 @@ static int mvebu_gpio_suspend(struct platform_device *pdev, pm_message_t state)
return 0;
}
-static int mvebu_gpio_resume(struct platform_device *pdev)
+static int mvebu_gpio_resume(struct device *dev)
{
- struct mvebu_gpio_chip *mvchip = platform_get_drvdata(pdev);
+ struct mvebu_gpio_chip *mvchip = dev_get_drvdata(dev);
u32 edge_cache = ~0U, level_cache = ~0U;
unsigned long flags;
int i;
@@ -1369,13 +1369,16 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
return 0;
}
+static const struct dev_pm_ops mvebu_gpio_pm_ops = {
+ NOIRQ_SYSTEM_SLEEP_PM_OPS(mvebu_gpio_suspend, mvebu_gpio_resume)
+};
+
static struct platform_driver mvebu_gpio_driver = {
.driver = {
.name = "mvebu-gpio",
.of_match_table = mvebu_gpio_of_match,
+ .pm = pm_sleep_ptr(&mvebu_gpio_pm_ops),
},
.probe = mvebu_gpio_probe,
- .suspend = mvebu_gpio_suspend,
- .resume = mvebu_gpio_resume,
};
builtin_platform_driver(mvebu_gpio_driver);
--
2.55.0
next reply other threads:[~2026-09-29 2:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 2:26 Rosen Penev [this message]
2026-09-29 13:06 ` Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260929022602.23306-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=brgl@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®