From: sashiko-bot@kernel.org
To: "Esben Haabendal" <esben@geanix.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v6 4/9] iio: accel: mma8452: Support interrupt sharing
Date: Tue, 25 Aug 2026 08:42:20 +0000 [thread overview]
Message-ID: <20260825084221.582281F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260825-mma8452-open-drain-v6-4-9b252804ee80@geanix.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] If regulator_disable() fails in mma8452_runtime_suspend(), the data->suspended flag is not rolled back, leading to a permanent IRQ storm on subsequent interrupts.
Pre-existing issues:
- [High] mma8452_remove() does not wake up the device before disabling runtime PM, leading to unbalanced regulator disables (underflow) and illegal I2C access while powered off.
- [High] Registers are not restored after runtime resume, causing the device to lose critical configuration.
--
--- Patch [4]: [PATCH v6 4/9] iio: accel: mma8452: Support interrupt sharing ---
commit 5bc641da9d60875f38db9937a3a1dae1afd9a94e
Author: Esben Haabendal <esben@geanix.com>
iio: accel: mma8452: Support interrupt sharing
This commit adds handling of runtime PM suspension in the interrupt handler
to allow sharing the interrupt with other devices. It introduces a suspended
flag and uses synchronize_irq() to protect against race conditions during
runtime suspend and device removal.
> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
> index 1fb43c5b0b72f..8eb97e6793d6f 100644
> --- a/drivers/iio/accel/mma8452.c
> +++ b/drivers/iio/accel/mma8452.c
[ ... ]
> @@ -1056,14 +1057,24 @@ static irqreturn_t mma8452_interrupt(int irq, void *p)
> struct iio_dev *indio_dev = p;
> struct mma8452_data *data = iio_priv(indio_dev);
> irqreturn_t ret = IRQ_NONE;
> + int pm_status;
> int src;
>
> + pm_status = pm_runtime_get_if_active(&data->client->dev);
> + if (pm_status == 0)
> + return IRQ_NONE; /* device is powered down */
> + if (READ_ONCE(data->suspended)) {
> + /* device is being removed */
> + ret = IRQ_NONE;
> + goto out_runtime_put;
> + }
[Severity: High]
Is the READ_ONCE(data->suspended) check reachable during normal suspend?
Since pm_runtime_get_if_active() returns 0 when the device state is
RPM_SUSPENDING, it seems the handler will return early before reaching
the data->suspended check.
[ ... ]
> @@ -1774,6 +1789,10 @@ static int mma8452_runtime_suspend(struct device *dev)
> return -EAGAIN;
> }
>
> + WRITE_ONCE(data->suspended, true);
> +
> + synchronize_irq(client->irq);
> +
> ret = regulator_disable(data->vddio_reg);
> if (ret) {
> dev_err(dev, "failed to disable VDDIO regulator\n");
> return ret;
> }
[Severity: High]
If regulator_disable() fails here, the function returns without resetting
data->suspended to false.
If this happens, the PM core leaves the device in RPM_ACTIVE. Would this
cause a permanent IRQ storm since the next interrupt will see pm_status > 0,
but data->suspended is true, causing it to continually return IRQ_NONE
without clearing the level-triggered interrupt?
[ ... ]
> @@ -1808,6 +1827,8 @@ static int mma8452_runtime_resume(struct device *dev)
> return ret;
> }
>
> + WRITE_ONCE(data->suspended, false);
> +
> ret = mma8452_active(data);
> if (ret < 0)
> goto runtime_resume_failed;
[Severity: High]
This is a pre-existing issue, but does mma8452_runtime_resume() need to
restore other device registers like MMA8452_CTRL_REG4 and MMA8452_DATA_CFG?
When the regulators are disabled during suspend, the device loses power and
these registers are reset. If they aren't restored here, will the device
lose its configuration and permanently disable hardware interrupts since
CTRL_REG4 defaults to 0?
[ ... ]
> @@ -1822,6 +1843,7 @@ static int mma8452_runtime_resume(struct device *dev)
> return 0;
>
> runtime_resume_failed:
> + WRITE_ONCE(data->suspended, true);
> regulator_disable(data->vddio_reg);
> regulator_disable(data->vdd_reg);
>
[Severity: High]
This is a pre-existing issue, but if the device is unbound via sysfs while
runtime-suspended, will mma8452_remove() run into issues?
drivers/iio/accel/mma8452.c:mma8452_remove() {
...
pm_runtime_disable(&client->dev);
pm_runtime_set_suspended(&client->dev);
...
mma8452_standby(iio_priv(indio_dev));
regulator_disable(data->vddio_reg);
regulator_disable(data->vdd_reg);
}
Since pm_runtime_disable() leaves the device suspended, won't
mma8452_standby() attempt an I2C write on an unpowered chip? Also, won't
calling regulator_disable() here cause an underflow since the regulators
were already disabled during runtime suspend? Does this need a
pm_runtime_get_sync() before teardown?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260825-mma8452-open-drain-v6-0-9b252804ee80@geanix.com?part=4
next prev parent reply other threads:[~2026-08-25 8:42 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 8:27 [PATCH v6 0/9] io: accel: mma8452: Allow open drain interrupt pin configuration Esben Haabendal
2026-08-25 8:27 ` [PATCH v6 1/9] dt-bindings: iio: accel: mma8452: Add drive-open-drain Esben Haabendal
2026-08-25 8:27 ` [PATCH v6 2/9] iio: accel: mma8452: Optimize struct mma8452_data member orders Esben Haabendal
2026-08-25 8:38 ` sashiko-bot
2026-08-25 8:27 ` [PATCH v6 3/9] iio: accel: mma8452: Only apply trigger type when not set by firmware Esben Haabendal
2026-08-25 8:43 ` sashiko-bot
2026-08-25 8:27 ` [PATCH v6 4/9] iio: accel: mma8452: Support interrupt sharing Esben Haabendal
2026-08-25 8:42 ` sashiko-bot [this message]
2026-08-25 11:39 ` Esben Haabendal
2026-08-25 8:27 ` [PATCH v6 5/9] iio: accel: mma8452: Allow open drain interrupt pin configuration Esben Haabendal
2026-08-25 8:42 ` sashiko-bot
2026-08-25 13:26 ` Esben Haabendal
2026-08-25 8:27 ` [PATCH v6 6/9] iio: accel: mma8452: Reuse existing dev pointer in mma8452_probe() Esben Haabendal
2026-08-25 8:38 ` sashiko-bot
2026-08-25 11:15 ` Esben Haabendal
2026-08-26 7:27 ` Andy Shevchenko
2026-08-25 8:27 ` [PATCH v6 7/9] iio: accel: mma8452: Drop unneeded lock acquire on read Esben Haabendal
2026-08-25 8:45 ` sashiko-bot
2026-08-25 10:17 ` Joshua Crofts
2026-08-25 13:35 ` Esben Haabendal
2026-08-25 13:44 ` Joshua Crofts
2026-08-25 14:06 ` Esben Haabendal
2026-08-25 8:27 ` [PATCH v6 8/9] iio: accel: mma8452: Fix use-after-free bug in error error path Esben Haabendal
2026-08-25 8:41 ` sashiko-bot
2026-08-25 8:27 ` [PATCH v6 9/9] iio: accel: mma8452: Use proper error code when missing device model Esben Haabendal
2026-08-25 8:40 ` sashiko-bot
2026-08-25 10:23 ` Joshua Crofts
2026-08-25 11:00 ` Esben Haabendal
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=20260825084221.582281F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=esben@geanix.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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