mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "Sabau, Radu bogdan" <radu.sabau@analog.com>
Cc: Radu Sabau via B4 Relay
	<devnull+radu.sabau.analog.com@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	"Hennerich, Michael" <Michael.Hennerich@analog.com>,
	"Sa, Nuno" <Nuno.Sa@analog.com>,
	David Lechner <dlechner@baylibre.com>,
	Andy Shevchenko <andy@kernel.org>,
	Alexandru Ardelean <alexandru.ardelean@analog.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	linux <linux@analog.com>
Subject: Re: [PATCH v4 6/8] iio: imu: adis16607: Add FIFO-based buffered/triggered capture
Date: Mon, 2 Nov 2026 00:04:06 +0000	[thread overview]
Message-ID: <20261102000406.342657af@jic23-hlaptop> (raw)
In-Reply-To: <20261101235010.79416e15@jic23-hlaptop>

On Sun, 1 Nov 2026 23:50:10 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> On Tue, 27 Oct 2026 09:36:47 +0000
> "Sabau, Radu bogdan" <radu.sabau@analog.com> wrote:
> 
> > > -----Original Message-----
> > > From: Jonathan Cameron <jic23@kernel.org>
> > > Sent: Monday, October 26, 2026 2:09 AM    
> > 
> > ...
> >   
> > > > +static void adis16607_fifo_push_sample(struct iio_dev *indio_dev,
> > > > +				       u8 *fifo_data, s64 timestamp)
> > > > +{
> > > > +	struct adis16607 *st = iio_priv(indio_dev);
> > > > +	u16 msw, lsw;
> > > > +	s32 val24;
> > > > +	int bit, offset = 0;
> > > > +
> > > > +	memset(st->data, 0, sizeof(st->data));
> > > > +
> > > > +	for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev-
> > > >masklength) {    
> > > iio_for_each_active_channel()
> > > 
> > > As sashiko notes, masklength is private.
> > > 
> > > There are a load of places we need to update to stop accessing these
> > > directly but please don't add another one.
> > > 
> > > It's on my list to throw some LLM tokens ago once I get out from
> > > under review backlog.
> > > 
> > > https://urldefense.com/v3/__https://sashiko.dev/*/patchset/20261023-
> > > adis16607-v4-0-
> > > a4d541ebfd13*40analog.com__;IyU!!A3Ni8CS0y2Y!9cguUuIwYMdnmBcoNR
> > > ye0_U99KUnJt04T6XlSnvS-9rxh5-8Y2fQXC39Mxsw3erc_JwvyFp3ssecZg$
> > > Check everything else reported.
> > > 
> > > FWIW there are also some nasty race conditions around active_scan_mask
> > > being available when the buffer is being torn down. You might
> > > want to close those off by claiming buffered mode to prevent
> > > such a transition.
> > >     
> > 
> > Agreed, I'll switch to iio_for_each_active_channel() and I'll go through the
> > rest of the Sashiko findings for v5.
> > 
> > On the active_scan_mask races, I'd like to check which path you mean.
> > In this driver the only reader of the mask is the trigger handler
> > (fifo_push_sample()), which runs as the pollfunc.
> > As far as I can tell, iio_trigger_detach_poll_func()'s free_irq() waits for it
> > to finish before iio_disable_buffers() frees the mask, so I couldn't find a
> > window where the handler sees a stale or NULL mask today.  
> 
> Ah. I may have failed to distinguish between cases with a trigger involved
> and those without.  The bug reports are probably on the ones without.
> Unfortunately I haven't found time to look at the overall issue
> in enough detail yet.
> 
> > Even so, I'd like to close this off for good, so that a later change to the
> > driver or to adislib can't introduce the race.
> > 
> > Claiming buffer mode inside the handler looks like it would deadlock
> > against iio_disable_buffers(), which holds mlock while waiting for the
> > handler in free_irq().  
> 
> We'd use a conditional claim in here - only the core code driving the state
> transitions should take a claim unconditionally (they can just grab the lock).
> If mlock is held it should fail and we just drop out of the handler having
> done nothing.  So either disable buffer wins and we drop through the handler
> quickly or it looses and the attempt to take mlock blocks in
> iio_disable_buffers()
> 
> Or am I missing something worse?

I'm indeed being dopey today.  Whilst it is a conditional claim we grab the lock
unconditionally as part of that.  Which makes sense because we want
multiple simple read the state calls to block behind each other.

> 
> > 
> > Would snapshotting the active-channel layout in update_scan_mode()
> > (called before the pollfunc is attached) and having the handler read
> > only that copy be an acceptable way to close it?  
> It would but that feels like we are just papering over a lifetime issue
> by creating another object rather than fixing it if necessary.
> 
> Anyhow, from your first comment this may all be irrelevant anyway.
> 
> Jonathan
> 
> >   
> 
> 


  reply	other threads:[~2026-11-02  0:04 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23  9:30 [PATCH v4 0/8] iio: imu: Add support for the ADI ADIS16607 Radu Sabau via B4 Relay
2026-10-23  9:30 ` [PATCH v4 1/8] iio: imu: adis: Add optional self_test callback Radu Sabau via B4 Relay
2026-10-30 14:06   ` Nuno Sá
2026-10-23  9:30 ` [PATCH v4 2/8] iio: imu: adis: Fix custom reset dispatch in adislib Radu Sabau via B4 Relay
2026-10-30 14:06   ` Nuno Sá
2026-10-23  9:30 ` [PATCH v4 3/8] iio: imu: adis: Add optional post_reset_setup callback Radu Sabau via B4 Relay
2026-10-25 23:52   ` Jonathan Cameron
2026-10-26  9:52     ` Sabau, Radu bogdan
2026-10-23  9:30 ` [PATCH v4 4/8] dt-bindings: iio: imu: Add bindings for ADI ADIS16607 Radu Sabau via B4 Relay
2026-10-25 23:54   ` Jonathan Cameron
2026-10-23  9:30 ` [PATCH v4 5/8] iio: imu: Add driver for the " Radu Sabau via B4 Relay
2026-10-23 10:26   ` Andy Shevchenko
2026-10-26 10:22     ` Sabau, Radu bogdan
2026-10-26 10:50       ` Andy Shevchenko
2026-10-30 14:06   ` Nuno Sá
2026-10-23  9:30 ` [PATCH v4 6/8] iio: imu: adis16607: Add FIFO-based buffered/triggered capture Radu Sabau via B4 Relay
2026-10-26  0:09   ` Jonathan Cameron
2026-10-27  9:36     ` Sabau, Radu bogdan
2026-11-01 23:50       ` Jonathan Cameron
2026-11-02  0:04         ` Jonathan Cameron [this message]
2026-10-30 14:06   ` Nuno Sá
2026-10-23  9:30 ` [PATCH v4 7/8] iio: imu: adis16607: Add external clock sync support Radu Sabau via B4 Relay
2026-10-26  0:11   ` Jonathan Cameron
2026-10-26 10:54     ` Sabau, Radu bogdan
2026-10-30 14:06   ` Nuno Sá
2026-10-23  9:30 ` [PATCH v4 8/8] iio: imu: adis16607: Add calibration bias support for gyro/accel Radu Sabau via B4 Relay
2026-10-26  0:15   ` Jonathan Cameron

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=20261102000406.342657af@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=Nuno.Sa@analog.com \
    --cc=alexandru.ardelean@analog.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=devnull+radu.sabau.analog.com@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@analog.com \
    --cc=radu.sabau@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®