In order to minimize the time required for transferring FIFO data from the
sensor to the host machine, perform the read from the FIFO in a single call
to regmap_bulk_read().
This allows reading acceleration data for all 3 axes at 16 kHz
sampling frequency using a 1MHz I2C bus frequency.
Signed-off-by: Francesco Lavra <flavra@baylibre.com>
---
drivers/iio/accel/adxl380.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/accel/adxl380.c b/drivers/iio/accel/adxl380.c
index 650cdbffd4a7..e3e6b182eb3d 100644
--- a/drivers/iio/accel/adxl380.c
+++ b/drivers/iio/accel/adxl380.c
@@ -965,14 +965,12 @@ static irqreturn_t adxl380_irq_handler(int irq, void *p)
return IRQ_HANDLED;
fifo_entries = rounddown(fifo_entries, st->fifo_set_size);
- for (i = 0; i < fifo_entries; i += st->fifo_set_size) {
- ret = regmap_noinc_read(st->regmap, ADXL380_FIFO_DATA,
- &st->fifo_buf[i],
- 2 * st->fifo_set_size);
- if (ret)
- return IRQ_HANDLED;
+ ret = regmap_noinc_read(st->regmap, ADXL380_FIFO_DATA, &st->fifo_buf,
+ sizeof(*st->fifo_buf) * fifo_entries);
+ if (ret)
+ return IRQ_HANDLED;
+ for (i = 0; i < fifo_entries; i += st->fifo_set_size)
iio_push_to_buffers(indio_dev, &st->fifo_buf[i]);
- }
return IRQ_HANDLED;
}
--
2.39.5
On Mon, 19 Jan 2026 11:23:17 +0100
Francesco Lavra <flavra@baylibre.com> wrote:
> In order to minimize the time required for transferring FIFO data from the
> sensor to the host machine, perform the read from the FIFO in a single call
> to regmap_bulk_read().
It's a call to regmap_noinc_read() not regmap_bulk_read()
I'll fix it.
> This allows reading acceleration data for all 3 axes at 16 kHz
> sampling frequency using a 1MHz I2C bus frequency.
>
> Signed-off-by: Francesco Lavra <flavra@baylibre.com>
> ---
> drivers/iio/accel/adxl380.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/iio/accel/adxl380.c b/drivers/iio/accel/adxl380.c
> index 650cdbffd4a7..e3e6b182eb3d 100644
> --- a/drivers/iio/accel/adxl380.c
> +++ b/drivers/iio/accel/adxl380.c
> @@ -965,14 +965,12 @@ static irqreturn_t adxl380_irq_handler(int irq, void *p)
> return IRQ_HANDLED;
>
> fifo_entries = rounddown(fifo_entries, st->fifo_set_size);
> - for (i = 0; i < fifo_entries; i += st->fifo_set_size) {
> - ret = regmap_noinc_read(st->regmap, ADXL380_FIFO_DATA,
> - &st->fifo_buf[i],
> - 2 * st->fifo_set_size);
> - if (ret)
> - return IRQ_HANDLED;
> + ret = regmap_noinc_read(st->regmap, ADXL380_FIFO_DATA, &st->fifo_buf,
> + sizeof(*st->fifo_buf) * fifo_entries);
> + if (ret)
> + return IRQ_HANDLED;
> + for (i = 0; i < fifo_entries; i += st->fifo_set_size)
> iio_push_to_buffers(indio_dev, &st->fifo_buf[i]);
> - }
>
> return IRQ_HANDLED;
> }
On Thu, Jan 22, 2026 at 07:53:13PM +0000, Jonathan Cameron wrote: > On Mon, 19 Jan 2026 11:23:17 +0100 > Francesco Lavra <flavra@baylibre.com> wrote: > > > In order to minimize the time required for transferring FIFO data from the > > sensor to the host machine, perform the read from the FIFO in a single call > > to regmap_bulk_read(). > It's a call to regmap_noinc_read() not regmap_bulk_read() > I'll fix it. This is interesting, does it mean the patch was never tested on the real HW? Or maybe noninc is intentional? -- With Best Regards, Andy Shevchenko
On Fri, 23 Jan 2026 10:13:16 +0200 Andy Shevchenko <andriy.shevchenko@intel.com> wrote: > On Thu, Jan 22, 2026 at 07:53:13PM +0000, Jonathan Cameron wrote: > > On Mon, 19 Jan 2026 11:23:17 +0100 > > Francesco Lavra <flavra@baylibre.com> wrote: > > > > > In order to minimize the time required for transferring FIFO data from the > > > sensor to the host machine, perform the read from the FIFO in a single call > > > to regmap_bulk_read(). > > > It's a call to regmap_noinc_read() not regmap_bulk_read() > > I'll fix it. > > This is interesting, does it mean the patch was never tested on the real HW? > Or maybe noninc is intentional? > It's absolutely intentional. The device presents a single register address that has the fifo behind it (which is what we added noinc for years ago). So patch should definitely work. Goes from reading that register N times in each call within a loop of M to reading it N x M. If regcache is in use this makes a difference as avoids corrupting registers after this point as the address increment expected in the hardware for a bulk read doesn't happen. Without regcache it's just "documentation" as at least for protocols used here its the same as a bulk read on the bus. So patch is fine, it just mentioned the wrong call in the description I'd guess this is because someone is working with a tree that has the wrong call in it but might be wrong. Jonathan
On Fri, 2026-01-23 at 09:54 +0000, Jonathan Cameron wrote: > On Fri, 23 Jan 2026 10:13:16 +0200 > Andy Shevchenko <andriy.shevchenko@intel.com> wrote: > > > On Thu, Jan 22, 2026 at 07:53:13PM +0000, Jonathan Cameron wrote: > > > On Mon, 19 Jan 2026 11:23:17 +0100 > > > Francesco Lavra <flavra@baylibre.com> wrote: > > > > > > > In order to minimize the time required for transferring FIFO data > > > > from the > > > > sensor to the host machine, perform the read from the FIFO in a > > > > single call > > > > to regmap_bulk_read(). > > > > > It's a call to regmap_noinc_read() not regmap_bulk_read() > > > I'll fix it. > > > > This is interesting, does it mean the patch was never tested on the > > real HW? The driver has been tested (by me) on real hardware, both before and after this patch. > > Or maybe noninc is intentional? > > > It's absolutely intentional. The device presents a single register > address > that has the fifo behind it (which is what we added noinc for years ago). > So patch should definitely work. Goes from reading that register N times > in > each call within a loop of M to reading it N x M. > > If regcache is in use this makes a difference as avoids corrupting > registers > after this point as the address increment expected in the hardware for > a bulk read doesn't happen. Without regcache it's just "documentation" > as > at least for protocols used here its the same as a bulk read on the bus. > > So patch is fine, it just mentioned the wrong call in the description > I'd guess this is because someone is working with a tree that has the > wrong call in > it but might be wrong. I have this patch applied also to older kernel versions where regmap_noinc_read() doesn't exist, so this is just a copy-paste error in the commit message. Sorry about that.
On Fri, Jan 23, 2026 at 12:09:36PM +0100, Francesco Lavra wrote: > On Fri, 2026-01-23 at 09:54 +0000, Jonathan Cameron wrote: > > On Fri, 23 Jan 2026 10:13:16 +0200 > > Andy Shevchenko <andriy.shevchenko@intel.com> wrote: > > > On Thu, Jan 22, 2026 at 07:53:13PM +0000, Jonathan Cameron wrote: > > > > On Mon, 19 Jan 2026 11:23:17 +0100 > > > > Francesco Lavra <flavra@baylibre.com> wrote: > > > > > > > > > In order to minimize the time required for transferring FIFO data > > > > > from the > > > > > sensor to the host machine, perform the read from the FIFO in a > > > > > single call > > > > > to regmap_bulk_read(). > > > > > > > It's a call to regmap_noinc_read() not regmap_bulk_read() > > > > I'll fix it. > > > > > > This is interesting, does it mean the patch was never tested on the > > > real HW? > > The driver has been tested (by me) on real hardware, both before and after > this patch. > > > > Or maybe noninc is intentional? > > > > > It's absolutely intentional. The device presents a single register > > address > > that has the fifo behind it (which is what we added noinc for years ago). > > So patch should definitely work. Goes from reading that register N times > > in > > each call within a loop of M to reading it N x M. > > > > If regcache is in use this makes a difference as avoids corrupting > > registers > > after this point as the address increment expected in the hardware for > > a bulk read doesn't happen. Without regcache it's just "documentation" > > as > > at least for protocols used here its the same as a bulk read on the bus. > > > > So patch is fine, it just mentioned the wrong call in the description > > I'd guess this is because someone is working with a tree that has the > > wrong call in > > it but might be wrong. > > I have this patch applied also to older kernel versions where > regmap_noinc_read() doesn't exist, so this is just a copy-paste error in > the commit message. Sorry about that. Thanks for clarifying this! -- With Best Regards, Andy Shevchenko
© 2016 - 2026 Red Hat, Inc.