From: Joshua Crofts <joshua.crofts1@gmail.com>
To: Esben Haabendal <esben@geanix.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Martin Kepplinger" <martink@posteo.de>,
"Sean Nyekjaer" <sean@geanix.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Martin Kepplinger" <martin.kepplinger@theobroma-systems.com>,
"Christoph Muellner" <christoph.muellner@theobroma-systems.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 7/9] iio: accel: mma8452: Drop unneeded lock acquire on read
Date: Tue, 25 Aug 2026 12:17:04 +0200 [thread overview]
Message-ID: <20260825121704.00004ed3@gmail.com> (raw)
In-Reply-To: <20260825-mma8452-open-drain-v6-7-9b252804ee80@geanix.com>
On Tue, 25 Aug 2026 10:27:45 +0200
Esben Haabendal <esben@geanix.com> wrote:
> There is no need to acquire data->lock when calling mma8452_read(), and
> dropping that makes it less likely to end up in an AB-BA deadlock
> situation.
>
> Signed-off-by: Esben Haabendal <esben@geanix.com>
> ---
> drivers/iio/accel/mma8452.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
> index 7ef1a9a91c31..9ae2c3e60576 100644
> --- a/drivers/iio/accel/mma8452.c
> +++ b/drivers/iio/accel/mma8452.c
> @@ -504,9 +504,7 @@ static int mma8452_read_raw(struct iio_dev *indio_dev,
> if (!iio_device_claim_direct(indio_dev))
> return -EBUSY;
>
> - mutex_lock(&data->lock);
> ret = mma8452_read(data, buffer);
> - mutex_unlock(&data->lock);
> iio_device_release_direct(indio_dev);
> if (ret < 0)
> return ret;
>
Sashiko has something to say and I tend to agree at the moment:
Could removing this lock expose mma8452_read() to race conditions with PM
auto-suspend and event configuration?
mma8452_read() can be interrupted by the PM auto-suspend worker, which puts
the device in STANDBY and disables regulators while mma8452_drdy() is actively
polling over I2C. This can lead to I/O timeouts or errors.
Additionally, concurrent sysfs writes to event configurations invoke
mma8452_change_config(), which puts the hardware into STANDBY to modify
registers. The Standby transition flushes the hardware FIFO. If this occurs
between the mma8452_drdy() check and the i2c_smbus_read_i2c_block_data() in
mma8452_read(), the block read will fetch flushed or stale data.
--
Kind regards,
Joshua Crofts
next prev parent reply other threads:[~2026-08-25 10:17 UTC|newest]
Thread overview: 19+ 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:27 ` [PATCH v6 3/9] iio: accel: mma8452: Only apply trigger type when not set by firmware Esben Haabendal
2026-08-25 8:27 ` [PATCH v6 4/9] iio: accel: mma8452: Support interrupt sharing 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:27 ` [PATCH v6 6/9] iio: accel: mma8452: Reuse existing dev pointer in mma8452_probe() Esben Haabendal
2026-08-26 7:27 ` Andy Shevchenko
2026-08-28 6:20 ` Esben Haabendal
2026-08-25 8:27 ` [PATCH v6 7/9] iio: accel: mma8452: Drop unneeded lock acquire on read Esben Haabendal
2026-08-25 10:17 ` Joshua Crofts [this message]
2026-08-25 13:35 ` Esben Haabendal
2026-08-25 13:44 ` Joshua Crofts
2026-08-25 14:06 ` Esben Haabendal
2026-08-28 6:29 ` 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:27 ` [PATCH v6 9/9] iio: accel: mma8452: Use proper error code when missing device model Esben Haabendal
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=20260825121704.00004ed3@gmail.com \
--to=joshua.crofts1@gmail.com \
--cc=andy@kernel.org \
--cc=christoph.muellner@theobroma-systems.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=esben@geanix.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.kepplinger@theobroma-systems.com \
--cc=martink@posteo.de \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
--cc=sean@geanix.com \
/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®