From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
linux-iio@vger.kernel.org,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Shen Jianping" <Jianping.Shen@de.bosch.com>
Subject: Re: [PATCH RFT] iio: Fix core buffer demux failure to account for unwanted channels at tail
Date: Mon, 4 Aug 2025 11:48:19 +0100 [thread overview]
Message-ID: <20250804114819.0000795a@huawei.com> (raw)
In-Reply-To: <CAHp75VfuLcV5Bv1WG3hbRr3P1-kxusN1Gf2dge1mC68cYGfxvw@mail.gmail.com>
On Sun, 3 Aug 2025 21:46:50 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> On Sat, Aug 2, 2025 at 7:15 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > The IIO channel demultiplexer code is there to deal with a mismatch between
> > the channels captured and those requested by user space either due to
> > driver supporting only particular channel combinations
> > (available_scan_masks) or due to multiple concurrent consumers (e.g.
> > userspace IIO buffered interfaces and an inkernel consumer such as a
> > touch screen).
> >
> > Whilst this code is exercised by many drivers, a corner case has been
> > hiding there all along.
> >
> > Consider an input of (postfix is the channel size)
>
> size in bits
>
> > a_32, b_32, c_32, d_32, ts_64
> >
> > and desired output of
> >
> > a32, b_32, ts_64
>
> You missed underscore here and below.
>
> > the current code ends up with
> >
> > a32, b_32, c_32, d_32
> >
> > because of a failure to iterate over the tail of unwanted channels
> > (here c_32 and d_32).
> >
> > Fix this by adding the code to walk the channels in the gap.
> >
> > Reported-by: Jianping Shen <Jianping.Shen@de.bosch.com>
> > Closes: https://lore.kernel.org/all/AM8PR10MB4721FB1A78F25B204BE3A26ACD5FA@AM8PR10MB4721.EURPRD10.PROD.OUTLOOK.COM/
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> Fixes?
>
> ...
>
> > Whilst this is being tested I'll try to figure out a Fixes tag.
> > There is some code movement so needs more digging that I have time for
> > today.
>
> Ah, okay.
>
>
> > + /* Walk remaining bits of active_scan_mask */
> > + in_ind = find_next_bit(indio_dev->active_scan_mask, masklength,
> > + in_ind + 1);
> > + while (in_ind != masklength) {
>
> for_each_set_bit_from() ?
Would work but then takes the style away from the code above that this
effectively duplicates. I'd need to have a closer look to see if we
can potentially convert that as well. I don't want two very different
looking bits of code effectively doing the same thing under subtly
different constraints.
Jonathan
>
> > + ret = iio_storage_bytes_for_si(indio_dev, in_ind);
> > + if (ret < 0)
> > + goto error_clear_mux_table;
> > +
> > + length = ret;
> > + /* Make sure we are aligned */
> > + in_loc = roundup(in_loc, length) + length;
> > + in_ind = find_next_bit(indio_dev->active_scan_mask,
> > + masklength, in_ind + 1);
> > + }
>
>
next prev parent reply other threads:[~2025-08-04 11:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-02 17:15 [PATCH RFT] iio: Fix core buffer demux failure to account for unwanted channels at tail Jonathan Cameron
2025-08-03 19:46 ` Andy Shevchenko
2025-08-04 10:48 ` Jonathan Cameron [this message]
2025-08-04 12:52 ` Andy Shevchenko
2025-08-06 15:40 ` Jonathan Cameron
2025-08-04 15:38 ` Nuno Sá
2025-08-04 16:02 ` Andy Shevchenko
2025-08-05 8:16 ` Nuno Sá
2025-08-05 12:41 ` Andy Shevchenko
2025-08-06 15:36 ` Jonathan Cameron
2025-08-11 9:54 ` Nuno Sá
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=20250804114819.0000795a@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=Jianping.Shen@de.bosch.com \
--cc=andy.shevchenko@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=nuno.sa@analog.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