From: Jonathan Cameron <jic23@kernel.org>
To: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Marcelo Schmitt <marcelo.schmitt@analog.com>,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 10/13] iio: adc: ad4134: Support SPI 4-wire mode
Date: Sat, 17 Oct 2026 19:31:17 +0100 [thread overview]
Message-ID: <20261017193117.04b71262@jic23-hlaptop> (raw)
In-Reply-To: <ar1lg7PMwP_RdzzO@debian-BULLSEYE-live-builder-AMD64>
> > > +static int ad4134_buffer_predisable(struct iio_dev *indio_dev)
> > > +{
> > > + struct ad4134_state *st = iio_priv(indio_dev);
> > > + int ret;
> > > +
> > > + ret = ad4134_release_sample_access(st);
> > > +
> > > + mutex_unlock(&st->access_lock);
> >
> > [Severity: High]
> > Is it intentional to hold st->access_lock across system calls here? Returning
> > to user space with the mutex held violates lock ownership semantics and can
> > trigger lockdep splats. Furthermore, could this deadlock any subsequent sysfs
> > regmap accesses while the buffer is enabled?
>
> I'm not sure about this one. The intent is to prevent sysfs regmap access while
> the buffer is enabled. IIO direct/buffer mode locking should provide that, no?
> The rationale for the two mutexes is for access_lock to avoid concurrent updates
> to the external multiplexer and for sync_lock to protect read/modify/write
> sequences. Maybe IIO direct/buffer mode locking + sync_lock is enough?
Technically claiming mode would be enough and if the locking is only coupled
to "in buffered mode or not in buffered mode" I'm fine with that.
However, if you need to serialize for other reasons we probably need to
grow a more complex solution with a lock and a flag (similar to what the
IIO mode stuff is doing) so as to avoid holding a lock across syscalls
as this points out.
>
> >
> > > +
> > > + return ret;
> > > +}
> > [ ... ]
> > > @@ -588,15 +768,69 @@ static int ad4134_probe(struct spi_device *spi)
> > > if (ret)
> > > return ret;
> > >
> > > + ret = devm_mutex_init(dev, &st->access_lock);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + ad4134_regmap_config.lock_arg = st;
> > > st->regmap = devm_regmap_init(dev, NULL, st, &ad4134_regmap_config);
> >
> > [Severity: Medium]
> > Is it safe to modify the global ad4134_regmap_config structure during probe?
> > If multiple devices probe concurrently, could this cause a data race where one
> > device's lock_arg overwrites another's before devm_regmap_init() copies it?
> >
> Not sure. Should it lock on a mutex before editing the regmap_config. Maybe
> I get rid of access_lock and make regmap_config const again.
Good catch here.
You shouldn't be modifying the global. The mutex solution works because
devm_regmap_init() doesn't keep any references to the config anyway but
I'd just use a local copy instead. One on the stack should be fine.
Jonathan
next prev parent reply other threads:[~2026-10-17 18:31 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 22:41 [PATCH v3 00/13] iio: adc: ad4134: Enable greater sample rate data capture Marcelo Schmitt
2026-09-29 22:42 ` [PATCH v3 01/13] iio: adc: ad4134: Adjust register map range Marcelo Schmitt
2026-09-29 22:42 ` [PATCH v3 02/13] iio: adc: ad4134: Sign extend sample data Marcelo Schmitt
2026-09-30 8:50 ` Joshua Crofts
2026-09-29 22:42 ` [PATCH v3 03/13] iio: adc: ad4134: Update include list to comply with IWYU principles Marcelo Schmitt
2026-09-29 22:43 ` [PATCH v3 04/13] iio: adc: ad4134: Serialize single-read operations Marcelo Schmitt
2026-09-29 22:43 ` [PATCH v3 05/13] iio: adc: ad4134: Run shorter transfers when CRC is disabled Marcelo Schmitt
2026-09-29 22:43 ` [PATCH v3 06/13] iio: adc: ad4134: Add support for digital filter type selection Marcelo Schmitt
2026-09-29 22:44 ` [PATCH v3 07/13] iio: adc: ad4134: Support buffered data read Marcelo Schmitt
[not found] ` <20260929230528.8861C1F000FF@smtp.kernel.org>
2026-09-30 18:54 ` Marcelo Schmitt
2026-09-29 22:44 ` [PATCH v3 08/13] dt-bindings: iio: adc: adi,ad4134: Document SPI connection mode Marcelo Schmitt
2026-09-30 11:51 ` Rob Herring (Arm)
2026-09-30 12:15 ` Rob Herring
[not found] ` <20260929230226.DDDAE1F00898@smtp.kernel.org>
2026-09-30 18:23 ` Marcelo Schmitt
2026-09-30 22:29 ` Conor Dooley
2026-09-29 22:44 ` [PATCH v3 09/13] dt-bindings: iio: adc: adi,ad4134: Document external multiplexer usage Marcelo Schmitt
2026-09-30 12:16 ` Rob Herring (Arm)
2026-09-29 22:45 ` [PATCH v3 10/13] iio: adc: ad4134: Support SPI 4-wire mode Marcelo Schmitt
[not found] ` <20260929230830.A8F3A1F000FF@smtp.kernel.org>
2026-09-30 19:39 ` Marcelo Schmitt
2026-10-17 18:31 ` Jonathan Cameron [this message]
2026-09-29 22:45 ` [PATCH v3 11/13] dt-bindings: iio: adc: adi,ad4134: Document PWM usage Marcelo Schmitt
2026-09-29 22:45 ` [PATCH v3 12/13] iio: adc: ad4134: Support high-speed data capture Marcelo Schmitt
2026-09-30 9:42 ` Andy Shevchenko
[not found] ` <20260929231610.BA7C31F000FF@smtp.kernel.org>
2026-09-30 19:59 ` Marcelo Schmitt
2026-09-29 22:46 ` [PATCH v3 13/13] Docs: iio: Add AD4134 Marcelo Schmitt
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=20261017193117.04b71262@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.schmitt1@gmail.com \
--cc=marcelo.schmitt@analog.com \
--cc=robh@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®