From: sashiko-bot@kernel.org
To: "Marcelo Schmitt" <marcelo.schmitt@analog.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v1 03/13] iio: adc: ad4134: Update include list to comply with IWYU principles
Date: Wed, 02 Sep 2026 17:40:29 +0000 [thread overview]
Message-ID: <20260902174029.E64A11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <22e82ed7b6d6c04f6347f8cdd0c675ea35fcc22f.1788368334.git.marcelo.schmitt@analog.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] tx_buf and rx_buf in ad4134_state share the same cacheline, leading to potential data corruption during concurrent DMA mappings.
- [High] The 24-bit ADC raw data is read as an unsigned integer but never sign-extended to 32 bits, causing negative voltages to be reported as large positive values.
--
commit 7ad0a307d46e16f77ecfa435dfba2e8a4ef0334d
Author: Marcelo Schmitt <marcelo.schmitt@analog.com>
iio: adc: ad4134: Update include list to comply with IWYU principles
This commit updates the AD4134 driver's include list to comply with
include-what-you-use principles. It adds necessary headers like bits.h and
time64.h, and removes redundant ones.
> diff --git a/drivers/iio/adc/ad4134.c b/drivers/iio/adc/ad4134.c
> index 70f80bf1825f8..7a3b05aacc744 100644
> --- a/drivers/iio/adc/ad4134.c
> +++ b/drivers/iio/adc/ad4134.c
[ ... ]
drivers/iio/adc/ad4134.c:ad4134_state()
> /*
> * DMA (thus cache coherency maintenance) requires the transfer buffers
> * to live in their own cache lines.
> */
> u8 rx_buf[AD4134_SPI_MAX_XFER_LEN] __aligned(IIO_DMA_MINALIGN);
> u8 tx_buf[AD4134_SPI_MAX_XFER_LEN];
> };
[Severity: High]
This isn't a bug introduced by this patch, but does tx_buf lack the necessary
IIO_DMA_MINALIGN attribute here in ad4134_state?
Since rx_buf is aligned to a cacheline boundary but only takes 3 bytes
(AD4134_SPI_MAX_XFER_LEN), tx_buf appears to be placed at offset 3 within the
exact same cacheline.
During SPI transfers (such as in ad4134_register_read), the SPI core
executes dma_map_single() for both tx_buf and rx_buf independently on the
same transfer. Can performing concurrent DMA cache maintenance on the same
cacheline (flushing tx_buf and invalidating rx_buf) cause data corruption
on non-coherent systems?
While later patches in this series move the alignment attribute to the
preceding scan buffer, it seems rx_buf and tx_buf still continue to share a
cacheline with each other in the final state.
drivers/iio/adc/ad4134.c:ad4134_data_read()
> /*
> * AD4134 has a built-in feature that flags when data transfers
> * don't run enough clock cycles to read the entire data frame.
> * Clock out data from all channels to avoid that.
> */
> if (i == AD4134_VREG_CH(reg))
> *val = get_unaligned_be24(st->rx_buf);
> }
>
> return 0;
> }
[Severity: High]
This is a pre-existing issue, but does this code fail to properly sign-extend
the 24-bit raw ADC data in ad4134_data_read()?
The ADC channels are defined with IIO_SCAN_FORMAT_SIGNED_INT, meaning the
hardware outputs 24-bit signed two's complement data. However, reading the
3 bytes with get_unaligned_be24() returns an unsigned 24-bit value.
Because this value is not sign-extended (e.g. using sign_extend32), could
negative ADC readings (like 0xFFFFFF) be incorrectly reported to userspace as
large positive integers (16777215) instead of negative values?
It appears this issue also remains unfixed in the final state of this series.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1788368334.git.marcelo.schmitt@analog.com?part=3
next prev parent reply other threads:[~2026-09-02 17:40 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 17:21 [PATCH v1 00/13] iio: adc: ad4134: Enable greater sample rate data capture Marcelo Schmitt
2026-09-02 17:21 ` [PATCH v1 01/13] iio: Fix typo in vendor name Marcelo Schmitt
2026-09-03 6:22 ` Andy Shevchenko
2026-09-02 17:21 ` [PATCH v1 02/13] iio: adc: ad4134: Drop import to empty name space Marcelo Schmitt
2026-09-02 17:22 ` [PATCH v1 03/13] iio: adc: ad4134: Update include list to comply with IWYU principles Marcelo Schmitt
2026-09-02 17:40 ` sashiko-bot [this message]
2026-09-03 6:26 ` Andy Shevchenko
2026-09-02 17:22 ` [PATCH v1 04/13] iio: adc: ad4134: Serialize single-read operations Marcelo Schmitt
2026-09-03 6:27 ` Andy Shevchenko
2026-09-02 17:23 ` [PATCH v1 05/13] iio: adc: ad4134: Run shorter transfers when CRC is disabled Marcelo Schmitt
2026-09-02 17:42 ` sashiko-bot
2026-09-02 17:23 ` [PATCH v1 06/13] iio: adc: ad4134: Add support for digital filter type selection Marcelo Schmitt
2026-09-03 6:31 ` Andy Shevchenko
2026-09-02 17:23 ` [PATCH v1 07/13] iio: adc: ad4134: Support buffered data read Marcelo Schmitt
2026-09-02 17:38 ` sashiko-bot
2026-09-02 17:24 ` [PATCH v1 08/13] dt-bindings: iio: adc: adi,ad4134: Document SPI connection mode Marcelo Schmitt
2026-09-02 17:46 ` sashiko-bot
2026-09-03 18:14 ` Conor Dooley
2026-09-02 17:24 ` [PATCH v1 09/13] iio: adc: ad4134: Support SPI 4-wire mode Marcelo Schmitt
2026-09-02 17:46 ` sashiko-bot
2026-09-03 6:39 ` Andy Shevchenko
2026-09-02 17:24 ` [PATCH v1 10/13] dt-bindings: iio: adc: adi,ad4134: Document PWM usage Marcelo Schmitt
2026-09-02 17:25 ` [PATCH v1 11/13] dt-bindings: iio: adc: adi,ad4134: Add high data throughput example Marcelo Schmitt
2026-09-02 17:39 ` sashiko-bot
2026-09-02 17:25 ` [PATCH v1 12/13] iio: adc: ad4134: Support high-speed data capture Marcelo Schmitt
2026-09-02 17:49 ` sashiko-bot
2026-09-03 7:00 ` Andy Shevchenko
2026-09-02 17:25 ` [PATCH v1 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=20260902174029.E64A11F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=marcelo.schmitt@analog.com \
--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