Devicetree
 help / color / mirror / Atom feed
From: "Kurt Borja" <kuurtb@gmail.com>
To: "Jonathan Cameron" <jic23@kernel.org>, <sashiko-reviews@lists.linux.dev>
Cc: "Kurt Borja" <kuurtb@gmail.com>, <conor+dt@kernel.org>,
	<robh@kernel.org>, <devicetree@vger.kernel.org>
Subject: Re: [PATCH v4 03/10] iio: adc: add the ti-ads1262 driver
Date: Sun, 06 Sep 2026 17:16:54 -0300	[thread overview]
Message-ID: <DL8IDQUWAFJL.5RNMP0YKWW9@gmail.com> (raw)
In-Reply-To: <178805537532.2788519.12150005140246669583.b4-reply@b4>

On Sat Aug 29, 2026 at 11:02 PM -03, Jonathan Cameron wrote:
>> commit 6093db1ff45e9e897720bc6b278550ffbef67e85
>> Author: Kurt Borja <kuurtb@gmail.com>
>> 
>> iio: adc: add the ti-ads1262 driver
>> 
>> Add the ti-ads1262 driver with initial support for the primary ADC (ADC1).
>> Various features such as accurate timeout delays, per-channel reference
>> sources, scale, offset, and diagnostics are intentionally left out for
>> future support.
>
> One particularly interesting point from sashiko about regmap debugfs.
>
>> 
>> > diff --git a/drivers/iio/adc/ti-ads1262.c b/drivers/iio/adc/ti-ads1262.c
>> > new file mode 100644
>> > --- /dev/null
>> > +++ b/drivers/iio/adc/ti-ads1262.c
>> 
>
>> > +static int ads1262_channel_read(struct iio_dev *indio_dev,
>> > +				const struct iio_chan_spec *spec, __be32 *val)
>> > +{
>> > +	struct ads1262 *st = iio_priv(indio_dev);
>> > +	int ret;
>> > +
>> > +	IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim);
>> > +	if (IIO_DEV_ACQUIRE_FAILED(claim))
>> > +		return -EBUSY;
>> > +
>> > +	ret = ads1262_set_runmode(st, ADS1262_RUNMODE_PULSE);
>> > +	if (ret)
>> > +		return ret;
>> > +
>> > +	ret = ads1262_channel_enable(st, spec);
>> > +	if (ret)
>> > +		return ret;
>> > +
>> > +	reinit_completion(&st->drdy);
>> > +
>> > +	ret = ads1262_dev_start_one(st);
>> > +	if (ret)
>> > +		return ret;
>> > +
>> > +	ret = ads1262_wait_for_conversion(st);
>> > +	if (ret)
>> > +		return ret;
>> 
>> [Severity: Medium]
>> Does this error path leave the hardware running if the wait is interrupted?
>> 
>> If ads1262_wait_for_conversion() returns an error (like -ERESTARTSYS from
>> a signal), the driver exits immediately without stopping the hardware. If a
>> subsequent read calls reinit_completion(&st->drdy), but the abandoned
>> hardware conversion finishes and asserts the DRDY interrupt right after,
>> could the new read prematurely fetch stale data from the old conversion?
>> 
>> Should this path ensure the hardware is stopped and synchronized with the
>> interrupt handler on timeout or interrupt?
>
> For me this is obscure enough I'm not sure we care about stale data.

Interesting issue... Hmmm, yeah I say we leave it like that too. Stale
data would not be the end of the world here.

>> > +static int ads1262_regmap_read(void *context, const void *reg_buf,
>> > +			       size_t reg_size, void *val_buf, size_t val_size)
>> > +{
>> > +	struct ads1262 *st = context;
>> > +	u8 tx[2];
>> > +
>> > +	lockdep_assert_held(&st->xfer_lock);
>> 
>> [Severity: Medium]
>> Will this lockdep assertion fail if the register is read via debugfs?
>> 
>> Because ads1262_regmap_config does not set disable_locking = true and does
>> not provide custom lock/unlock callbacks, regmap uses its own internal
>> mutex. When regmap's debugfs interface is read, the regmap core acquires
>> its internal mutex and calls the driver's ads1262_regmap_read() callback
>> without holding st->xfer_lock.
>> 
>> Could this bypass the xfer_lock, triggering the lockdep splat and allowing
>> debugfs SPI operations to interleave with driver-initiated SPI transactions?
>
> This is a corner I'd not thought about in adding lockdep markings to these
> functions.  Up to you how you want to fix it.

The way to fix this would be to either bring the xfer_lock back into the
regmap callbacks or allocate the regmap_config dynamically and give it
the xfer_lock so the core can deal with it.

For me I'd prefer to do the first but David raised a concern about the
xfer_lock being in the callback. Maybe David can give us his opinion
here?

-- 
Thanks,
 ~ Kurt

  reply	other threads:[~2026-09-06 20:16 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28  6:38 [PATCH v4 00/10] iio: adc: Add TI ADS126X ADC family support Kurt Borja
2026-08-28  6:38 ` [PATCH v4 01/10] dt-bindings: adc: add excitation-current-chopping property Kurt Borja
2026-08-28 16:33   ` Conor Dooley
2026-08-28  6:38 ` [PATCH v4 02/10] dt-bindings: iio: adc: support the TI ADS126x ADC family Kurt Borja
2026-08-28  6:45   ` sashiko-bot
2026-08-28 16:39   ` Conor Dooley
2026-08-30  1:57     ` Jonathan Cameron
2026-08-31 16:24       ` Conor Dooley
2026-09-01  3:01         ` Jonathan Cameron
2026-09-06 20:16     ` Kurt Borja
2026-08-30  1:53   ` Jonathan Cameron
2026-09-06 20:16     ` Kurt Borja
2026-08-31 19:44   ` David Lechner
2026-09-06 20:17     ` Kurt Borja
2026-08-28  6:38 ` [PATCH v4 03/10] iio: adc: add the ti-ads1262 driver Kurt Borja
2026-08-28  6:52   ` sashiko-bot
2026-08-30  2:02     ` Jonathan Cameron
2026-09-06 20:16       ` Kurt Borja [this message]
2026-08-28  8:09   ` Andy Shevchenko
2026-09-06 20:15     ` Kurt Borja
2026-09-08 10:01       ` Andy Shevchenko
2026-08-31 20:22   ` David Lechner
2026-09-01  3:07     ` Jonathan Cameron
2026-09-06 20:17     ` Kurt Borja
2026-09-10  2:43       ` Jonathan Cameron
2026-09-10 21:38       ` David Lechner
2026-08-28  6:38 ` [PATCH v4 04/10] iio: adc: ti-ads1262: support per-channel sampling frequency Kurt Borja
2026-08-28  7:03   ` sashiko-bot
2026-08-30  1:36   ` Jonathan Cameron
2026-09-06 20:16     ` Kurt Borja
2026-08-30  2:22   ` Jonathan Cameron
2026-09-06 20:17     ` Kurt Borja
2026-08-28  6:38 ` [PATCH v4 05/10] iio: adc: ti-ads1262: support per-channel reference and gain Kurt Borja
2026-08-28  6:38 ` [PATCH v4 06/10] iio: adc: ti-ads1262: support input chopping Kurt Borja
2026-08-28  6:38 ` [PATCH v4 07/10] iio: adc: ti-ads1262: support excitation currents Kurt Borja
2026-08-28  6:57   ` sashiko-bot
2026-08-28  6:38 ` [PATCH v4 08/10] iio: adc: ti-ads1262: support triggered buffer sampling Kurt Borja
2026-08-28  6:57   ` sashiko-bot
2026-08-28  6:38 ` [PATCH v4 09/10] iio: adc: ti-ads1262: support REFOUT and VBIAS regulators Kurt Borja
2026-08-28  6:53   ` sashiko-bot
2026-08-28  6:38 ` [PATCH v4 10/10] iio: adc: ti-ads1262: support common mode supplies Kurt Borja
2026-08-28  7:03   ` sashiko-bot

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=DL8IDQUWAFJL.5RNMP0YKWW9@gmail.com \
    --to=kuurtb@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --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