Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Marcelo Schmitt" <marcelo.schmitt@analog.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v4 12/13] iio: adc: ad4134: Support high-speed data capture
Date: Tue, 06 Oct 2026 18:35:45 +0000	[thread overview]
Message-ID: <sashiko-outbox-162356@kernel.org> (raw)
In-Reply-To: <14b9c627f24e8f2456a918d02f43a7aea382ccb5.1791309733.git.marcelo.schmitt@analog.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] ad4134: ODR PWM is left running on probe failure and device unbind
- [High] iio: adc: ad4134: debugfs_reg_access corrupts active SPI offload capture
- [Low] ad4134: Incorrect macro HZ_PER_GHZ used for nanosecond time math
--

commit 646edf6c83770fad0c88592b752978f3561b3e9e
Author: Marcelo Schmitt <marcelo.schmitt@analog.com>
Subject: iio: adc: ad4134: Support high-speed data capture

This commit implements SPI transfer offloading for the AD4134 ADC. It
enables faster data acquisition at sample rates up to 1.496 MSPS.

> diff --git a/drivers/iio/adc/ad4134.c b/drivers/iio/adc/ad4134.c
> index debc2ff027051..aa8abe5715c4b 100644
> --- a/drivers/iio/adc/ad4134.c
> +++ b/drivers/iio/adc/ad4134.c
[ ... ]
> @@ -517,6 +522,92 @@ ...
> +static int ad4134_update_conversion_rate(struct ad4134_state *st,
> +					 unsigned int freq_Hz)
> +{
[ ... ]
> +	/*
> +	 * Configure SPI offload PWM trigger.
> +	 * For gated DCLK, the minimum required time between ODR rising edge
[ ... ]
> +	 */
> +	offload_period_ns = odr_wf.period_length_ns;
> +	config.periodic.frequency_hz = DIV_ROUND_UP_ULL(HZ_PER_GHZ, offload_period_ns);

[Severity: Low]
This isn't a bug, but should this use NSEC_PER_SEC instead of HZ_PER_GHZ?

While both macros are numerically identical, the calculation here is dividing
by a period in nanoseconds to get a frequency in Hertz, so NSEC_PER_SEC
seems to be the semantically correct unit scaling factor to use here.

[ ... ]
> @@ -606,6 +787,166 @@ ...
> +static const struct iio_info ad4134_offload_info = {
> +	.read_raw = ad4134_read_raw,
> +	.read_avail = ad4134_read_avail,
> +	.write_raw = ad4134_write_raw,
> +	.debugfs_reg_access = ad4134_debugfs_reg_access,

[Severity: High]
Can this corrupt an ongoing SPI offload capture?

It looks like ad4134_debugfs_reg_access() issues regmap_read() and
regmap_write() operations without calling iio_device_claim_direct_mode().
If a privileged user accesses direct_reg_access via debugfs while an
offload engine is actively streaming data, this could dynamically alter
the SPI controller mode to SPI_MODE_0 and shift the pin mux.

Since ad4134_release_reg_access() does not restore the SPI mode to
SPI_MODE_1, would this permanently corrupt the capture stream until it
is restarted?

> +};
[ ... ]
> +static int ad4134_offload_setup(struct iio_dev *indio_dev, struct ad4134_state *st)
> +{
> +	struct device *dev = &st->spi->dev;
> +	int ret;
> +
> +	ret = ad4134_pwm_get(st);
> +	if (ret)
> +		return ret;
> +
> +	ret = ad4134_offload_buffer_setup(indio_dev, st->spi);
> +	if (ret)
> +		return ret;
> +
> +	/*
> +	 * Start with a sampling rate slower than 374 kSPS because that is the
> +	 * maximum rate supported with wideband filter (default on power up).
> +	 */
> +	st->odr_hz = 250 * HZ_PER_KHZ;
> +	ret = ad4134_update_conversion_rate(st, st->odr_hz);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to set sampling freq\n");

[Severity: High]
Will the ODR PWM be left running if probe fails later or the device is
unbound?

The call to ad4134_update_conversion_rate() actively starts the PWM
generation by calling pwm_set_waveform_might_sleep(). The PWM is acquired
via devm_pwm_get() earlier in ad4134_offload_setup(), so devres will call
pwm_put() during cleanup. However, pwm_put() only frees the software
resource and does not stop the physical PWM output.

Should there be a devm_add_action_or_reset() handler registered to
explicitly disable the PWM or set the duty cycle to zero on teardown?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791309733.git.marcelo.schmitt@analog.com?part=12

  reply	other threads:[~2026-10-06 18:35 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06 18:15 [PATCH v4 00/13] iio: adc: ad4134: Enable greater sample rate data capture Marcelo Schmitt
2026-10-06 18:16 ` [PATCH v4 01/13] iio: adc: ad4134: Adjust register map range Marcelo Schmitt
2026-10-06 18:16 ` [PATCH v4 02/13] iio: adc: ad4134: Sign extend sample data Marcelo Schmitt
2026-10-06 18:32   ` sashiko-bot
2026-10-06 18:16 ` [PATCH v4 03/13] iio: adc: ad4134: Update include list to comply with IWYU principles Marcelo Schmitt
2026-10-06 18:17 ` [PATCH v4 04/13] iio: adc: ad4134: Serialize single-read operations Marcelo Schmitt
2026-10-06 18:17 ` [PATCH v4 05/13] iio: adc: ad4134: Run shorter transfers when CRC is disabled Marcelo Schmitt
2026-10-06 18:32   ` sashiko-bot
2026-10-06 18:17 ` [PATCH v4 06/13] iio: adc: ad4134: Add support for digital filter type selection Marcelo Schmitt
2026-10-06 18:17 ` [PATCH v4 07/13] iio: adc: ad4134: Support buffered data read Marcelo Schmitt
2026-10-06 18:36   ` sashiko-bot
2026-10-06 18:18 ` [PATCH v4 08/13] dt-bindings: iio: adc: adi,ad4134: Document SPI connection mode Marcelo Schmitt
2026-10-06 18:29   ` sashiko-bot
2026-10-07 10:14   ` Conor Dooley
2026-10-06 18:18 ` [PATCH v4 09/13] dt-bindings: iio: adc: adi,ad4134: Document external multiplexer usage Marcelo Schmitt
2026-10-06 18:32   ` sashiko-bot
2026-10-06 18:19 ` [PATCH v4 10/13] iio: adc: ad4134: Support SPI 4-wire mode Marcelo Schmitt
2026-10-06 18:35   ` sashiko-bot
2026-10-06 18:19 ` [PATCH v4 11/13] dt-bindings: iio: adc: adi,ad4134: Document PWM usage Marcelo Schmitt
2026-10-06 18:27   ` sashiko-bot
2026-10-06 18:19 ` [PATCH v4 12/13] iio: adc: ad4134: Support high-speed data capture Marcelo Schmitt
2026-10-06 18:35   ` sashiko-bot [this message]
2026-10-06 18:19 ` [PATCH v4 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=sashiko-outbox-162356@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