From: Jonathan Cameron <jic23@kernel.org>
To: Radu Sabau via B4 Relay <devnull+radu.sabau.analog.com@kernel.org>
Cc: radu.sabau@analog.com, "Nuno Sá" <nuno.sa@analog.com>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"David Lechner" <dlechner@baylibre.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Ramona Gradinariu" <ramona.bolboaca13@gmail.com>,
linux-iio@vger.kernel.org, linux@analog.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/7] iio: imu: adis16607: Add FIFO-based buffered capture
Date: Sat, 28 Nov 2026 22:00:10 +0000 [thread overview]
Message-ID: <20261128220010.5d1235fe@jic23-hlaptop> (raw)
In-Reply-To: <20261123-adis-fifo-v1-6-f6ad9e493e19@analog.com>
On Mon, 23 Nov 2026 15:25:30 +0200
Radu Sabau via B4 Relay <devnull+radu.sabau.analog.com@kernel.org> wrote:
> From: Radu Sabau <radu.sabau@analog.com>
>
> Add buffered capture via the device's hardware FIFO, the only capture
> mode this driver supports. Popping the FIFO uses a dedicated command and
> payload format (FIFO_DATA_CMD, 52 bytes, no checksum). The channels are
> described as big endian words with the value in their upper bits, as the
> device sends them, so the samples are copied to the buffer unchanged.
>
> The samples go to a kfifo buffer set up with the adislib kfifo helper,
> filled from a threaded interrupt: the device raises one interrupt per
> watermark, not per sample, so there is nothing to trigger on. The
> watermark-met condition is signaled via DEV_NOK on the device's one
> interrupt pin, which stays asserted until DIAG_STAT is read and cleared.
> The interrupt is therefore level-triggered and oneshot, and it is enabled
> only while the buffer is. DEV_NOK fires on any DIAG_STAT flag, not just
> FIFO_THRESH_MET, so the handler checks that specific bit before popping
> anything and leaves interrupts it did not raise to the core. DR_GPIO_MASK
> stays enabled unconditionally: DR pulses drive the FIFO controller's
> internal sample enqueue, independent of pin routing.
>
> Watermark is configurable via the standard hwfifo_set_watermark callback
> and the usual hwfifo_* sysfs attributes. Changing the sampling frequency
> while the buffer is enabled returns -EBUSY, as the decimation can't change
> during capture.
Unless I read it wrong, this changes the driver from doing some useful
stuff without interrupts being wired, to nothing at all. That is not
a change we should make in an upstream driver (even if maybe this
lands in the same cycle).
Jonathan
>
> Signed-off-by: Radu Sabau <radu.sabau@analog.com>
> diff --git a/drivers/iio/imu/adis16607.c b/drivers/iio/imu/adis16607.c
> index 749ed7445f73..60433c97a855 100644
> --- a/drivers/iio/imu/adis16607.c
> +++ b/drivers/iio/imu/adis16607.c
> +static int adis16607_buffer_postenable(struct iio_dev *indio_dev)
> +{
> + struct adis16607 *st = iio_priv(indio_dev);
> + struct adis *adis = &st->adis;
> + u16 threshold;
> + int ret;
> +
> + adis_dev_auto_lock(adis);
> +
> + /* Flush FIFO to start clean */
> + ret = __adis_write_reg_16(adis, ADIS16607_REG_USER_FIFO_CFG,
> + ADIS16607_FIFO_FLUSH_MASK);
> + if (ret)
> + return ret;
> +
> + /* Enable FIFO with watermark threshold (in word count) */
> + threshold = st->fifo_watermark * ADIS16607_FIFO_WORDS_PER_SAMPLE;
> + ret = __adis_write_reg_16(adis, ADIS16607_REG_USER_FIFO_CFG,
> + threshold & ADIS16607_FIFO_THR_MASK);
> + if (ret)
> + return ret;
> +
> + /*
> + * The device cannot mask DEV_NOK for us: unrouting it leaves the pin
> + * on its weak pull-up, which reads as asserted. Mask it on the host.
> + */
Ah. This is the comment we need for the earlier patches. Is that generally
true for all the kfifo supported devices, or should we be using some sort
of flag to let the adis helper know if this is required?
> + enable_irq(adis->spi->irq);
> +
> + return 0;
> +}
>
> /*
> @@ -814,6 +1158,7 @@ static const struct adis_data adis16607_data = {
> .diag_stat_size = 2,
> .prod_id_reg = ADIS16607_REG_DEV_ID,
> .prod_id = 0x6000,
> + .has_fifo = true,
> .unmasked_drdy = true,
> .init = adis16607_init,
> .self_test = adis16607_self_test,
> @@ -972,7 +1317,19 @@ static int adis16607_probe(struct spi_device *spi)
> indio_dev->info = &adis16607_info;
> indio_dev->modes = INDIO_DIRECT_MODE;
>
> + if (!spi->irq)
> + return dev_err_probe(dev, -EINVAL, "interrupt is required\n");
The driver is upstream without that requirement. We should not add it now as
I assume it works to some degree without it? Just modify the reported channels
etc to have it support current functionality if no irq. That probably means
multiple iio_info, possibly channels etc.
> +
> + /* The core's default; the device watermark follows buffer/watermark */
> + st->fifo_watermark = 1;
> +
> st->adis.ops = &adis16607_ops;
> + /*
> + * DEV_NOK is the OR of the DIAG_STAT flags and stays high until
> + * DIAG_STAT is read. Use a level interrupt so a flag raised while it
> + * is already high is not lost.
> + */
> + st->adis.irq_flag = IRQF_TRIGGER_HIGH;
For a modern driver explain why we don't get this from the firmware.
Thanks,
Jonathan
>
next prev parent reply other threads:[~2026-11-28 22:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 13:25 [PATCH 0/7] iio: imu: adis: Use a kfifo buffer for the devices with a FIFO Radu Sabau via B4 Relay
2026-11-23 13:25 ` [PATCH 1/7] iio: imu: adis16475: Use the reset timeouts of the ADIS1657x Radu Sabau via B4 Relay
2026-11-26 13:34 ` Joshua Crofts
2026-11-28 21:49 ` Jonathan Cameron
2026-11-23 13:25 ` [PATCH 2/7] iio: imu: adis: Add a kfifo buffer setup helper for FIFO devices Radu Sabau via B4 Relay
2026-11-26 9:33 ` Sabau, Radu bogdan
2026-11-28 21:47 ` Jonathan Cameron
2026-11-23 13:25 ` [PATCH 3/7] iio: imu: adis16475: Pass the device and timestamp to the sample helpers Radu Sabau via B4 Relay
2026-11-23 13:25 ` [PATCH 4/7] iio: imu: adis16475: Use a kfifo buffer for the devices with a FIFO Radu Sabau via B4 Relay
2026-11-28 21:52 ` Jonathan Cameron
2026-11-23 13:25 ` [PATCH 5/7] iio: imu: adis: Drop the FIFO handling from the data ready trigger Radu Sabau via B4 Relay
2026-11-23 13:25 ` [PATCH 6/7] iio: imu: adis16607: Add FIFO-based buffered capture Radu Sabau via B4 Relay
2026-11-28 22:00 ` Jonathan Cameron [this message]
2026-11-23 13:25 ` [PATCH 7/7] iio: imu: adis16607: Report loss of external sync 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=20261128220010.5d1235fe@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=devnull+radu.sabau.analog.com@kernel.org \
--cc=dlechner@baylibre.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@analog.com \
--cc=nuno.sa@analog.com \
--cc=radu.sabau@analog.com \
--cc=ramona.bolboaca13@gmail.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
all inboxes | Powered by JetHome®