From: sashiko-bot@kernel.org
To: "Radu Sabau via B4 Relay" <devnull+radu.sabau.analog.com@kernel.org>
Cc: krzk+dt@kernel.org, robh@kernel.org, conor+dt@kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v10 4/6] iio: adc: ad4691: add SPI offload support
Date: Tue, 12 May 2026 08:12:35 +0000 [thread overview]
Message-ID: <20260512081235.C0DB5C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260511-ad4692-multichannel-sar-adc-driver-v10-4-e1fbb1744e38@analog.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The software-triggered buffer and SPI offload paths produce memory buffers with differing endianness, but they share the exact same IIO channel `scan_type`, corrupting data on Little-Endian hosts for one of the paths.
--
commit 7a6cc358e39a6b61c1d3018b7172b6303e1f28e5
Author: Radu Sabau <radu.sabau@analog.com>
iio: adc: ad4691: add SPI offload support
This commit adds SPI offload support to enable DMA-based, CPU-independent
data acquisition using the SPI Engine offload framework. It supports both
CNV Burst Mode and Manual Mode, sharing the channel scan_type between the
software-triggered and offload paths.
> diff --git a/drivers/iio/adc/ad4691.c b/drivers/iio/adc/ad4691.c
> --- a/drivers/iio/adc/ad4691.c
> +++ b/drivers/iio/adc/ad4691.c
[ ... ]
> @@ -847,6 +924,223 @@ static const struct iio_buffer_setup_ops ad4691_cnv_burst_buffer_setup_ops = {
[ ... ]
> +static int ad4691_cnv_burst_offload_buffer_postenable(struct iio_dev *indio_dev)
> +{
[ ... ]
> + iio_for_each_active_channel(indio_dev, bit) {
> + st->scan_tx[k] = 0x8000 | AD4691_AVG_IN(bit);
> +
> + /* TX: address phase, CS stays asserted into data phase */
> + st->scan_xfers[2 * k].tx_buf = &st->scan_tx[k];
> + st->scan_xfers[2 * k].len = sizeof(st->scan_tx[k]);
> + st->scan_xfers[2 * k].bits_per_word = bpw;
> +
> + /* RX: data phase, CS toggles after to delimit the next register op */
> + st->scan_xfers[2 * k + 1].len = sizeof(st->scan_tx[k]);
> + st->scan_xfers[2 * k + 1].bits_per_word = bpw;
> + st->scan_xfers[2 * k + 1].offload_flags = SPI_OFFLOAD_XFER_RX_STREAM;
> + st->scan_xfers[2 * k + 1].cs_change = 1;
> + k++;
> + }
Will this offload RX stream configuration result in different endianness
compared to the software-triggered path?
In the software-triggered path, the SPI RX uses the default bits_per_word
of 8, meaning the ADC's MSB-first 16-bit samples are stored byte-by-byte in
memory as Big-Endian.
However, here in the offload path, bits_per_word is set to 16. The SPI
engine will reconstruct the 16-bit frames, and the DMA controller will
write them to memory as native 16-bit words, which will be Little-Endian
on LE hosts.
Since both paths share the same IIO channel scan_type definition (which
lacks an explicit endianness and defaults to IIO_CPU), won't one of the
paths produce incorrectly decoded data for userspace on Little-Endian
systems?
It is understood that a subsequent commit ("iio: adc: ad4691: add
oversampling support") adds an endianness of IIO_BE to the channel
definitions to address the software path. Since the offload path still
shares these definitions, this would cause IIO to advertise the offload
data as Big-Endian even though it provides CPU-endian data.
It appears the driver might need separate channel arrays for the offload
path with endianness set to IIO_CPU, or it needs to byte-swap the software
buffer to CPU endianness before pushing it to IIO.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260511-ad4692-multichannel-sar-adc-driver-v10-0-e1fbb1744e38@analog.com?part=4
next prev parent reply other threads:[~2026-05-12 8:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 11:54 [PATCH v10 0/6] iio: adc: ad4691: add driver for AD4691 multichannel SAR ADC family Radu Sabau via B4 Relay
2026-05-11 11:54 ` [PATCH v10 1/6] dt-bindings: iio: adc: add AD4691 family Radu Sabau via B4 Relay
2026-05-12 2:32 ` sashiko-bot
2026-05-11 11:54 ` [PATCH v10 2/6] iio: adc: ad4691: add initial driver for " Radu Sabau via B4 Relay
2026-05-12 4:09 ` sashiko-bot
2026-05-12 15:25 ` Jonathan Cameron
2026-05-11 11:54 ` [PATCH v10 3/6] iio: adc: ad4691: add triggered buffer support Radu Sabau via B4 Relay
2026-05-12 6:03 ` sashiko-bot
2026-05-12 15:45 ` Jonathan Cameron
2026-05-11 11:54 ` [PATCH v10 4/6] iio: adc: ad4691: add SPI offload support Radu Sabau via B4 Relay
2026-05-12 8:12 ` sashiko-bot [this message]
2026-05-12 15:49 ` Jonathan Cameron
2026-05-11 11:54 ` [PATCH v10 5/6] iio: adc: ad4691: add oversampling support Radu Sabau via B4 Relay
2026-05-11 11:54 ` [PATCH v10 6/6] docs: iio: adc: ad4691: add driver documentation Radu Sabau via B4 Relay
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=20260512081235.C0DB5C2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=devnull+radu.sabau.analog.com@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=robh@kernel.org \
--cc=sashiko@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