* [PATCH 0/2] accel: adxl380: improve data reading from FIFO
@ 2026-01-06 19:36 Francesco Lavra
2026-01-06 19:36 ` [PATCH 1/2] iio: accel: adxl380: Avoid reading more entries than present in FIFO Francesco Lavra
2026-01-06 19:36 ` [PATCH 2/2] iio: accel: adxl380: Optimize reading of FIFO entries in interrupt handler Francesco Lavra
0 siblings, 2 replies; 4+ messages in thread
From: Francesco Lavra @ 2026-01-06 19:36 UTC (permalink / raw)
To: Ramona Gradinariu, Antoniu Miclaus, Lars-Peter Clausen,
Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
Patch 1 fixes a bug that might cause the adxl380 interrupt handler
to read from the sensor FIFO more entries than actually present.
Patch 2 optimizes transfer of FIFO data by minimizing transport protocol
overhead.
Francesco Lavra (2):
iio: accel: adxl380: Avoid reading more entries than present in FIFO
iio: accel: adxl380: Optimize reading of FIFO entries in interrupt
handler
drivers/iio/accel/adxl380.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
--
2.39.5
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 1/2] iio: accel: adxl380: Avoid reading more entries than present in FIFO 2026-01-06 19:36 [PATCH 0/2] accel: adxl380: improve data reading from FIFO Francesco Lavra @ 2026-01-06 19:36 ` Francesco Lavra 2026-01-06 19:36 ` [PATCH 2/2] iio: accel: adxl380: Optimize reading of FIFO entries in interrupt handler Francesco Lavra 1 sibling, 0 replies; 4+ messages in thread From: Francesco Lavra @ 2026-01-06 19:36 UTC (permalink / raw) To: Ramona Gradinariu, Antoniu Miclaus, Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel The interrupt handler reads FIFO entries in batches of N samples, where N is the number of scan elements that have been enabled. However, the sensor fills the FIFO one sample at a time, even when more than one channel is enabled. Therefore,the number of entries reported by the FIFO status registers may not be a multiple of N; if this number is not a multiple, the number of entries read from the FIFO may exceed the number of entries actually present. To fix the above issue, round down the number of FIFO entries read from the status registers so that it is always a multiple of N. Fixes: df36de13677a ("iio: accel: add ADXL380 driver") Signed-off-by: Francesco Lavra <flavra@baylibre.com> --- drivers/iio/accel/adxl380.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/accel/adxl380.c b/drivers/iio/accel/adxl380.c index aef5109c1ddd..9f6c0e02575a 100644 --- a/drivers/iio/accel/adxl380.c +++ b/drivers/iio/accel/adxl380.c @@ -949,6 +949,7 @@ static irqreturn_t adxl380_irq_handler(int irq, void *p) if (ret) 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.39.5 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] iio: accel: adxl380: Optimize reading of FIFO entries in interrupt handler 2026-01-06 19:36 [PATCH 0/2] accel: adxl380: improve data reading from FIFO Francesco Lavra 2026-01-06 19:36 ` [PATCH 1/2] iio: accel: adxl380: Avoid reading more entries than present in FIFO Francesco Lavra @ 2026-01-06 19:36 ` Francesco Lavra 2026-01-11 13:14 ` Jonathan Cameron 1 sibling, 1 reply; 4+ messages in thread From: Francesco Lavra @ 2026-01-06 19:36 UTC (permalink / raw) To: Ramona Gradinariu, Antoniu Miclaus, Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel 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 9f6c0e02575a..ce3643c5deb8 100644 --- a/drivers/iio/accel/adxl380.c +++ b/drivers/iio/accel/adxl380.c @@ -950,14 +950,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, 2 * 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] iio: accel: adxl380: Optimize reading of FIFO entries in interrupt handler 2026-01-06 19:36 ` [PATCH 2/2] iio: accel: adxl380: Optimize reading of FIFO entries in interrupt handler Francesco Lavra @ 2026-01-11 13:14 ` Jonathan Cameron 0 siblings, 0 replies; 4+ messages in thread From: Jonathan Cameron @ 2026-01-11 13:14 UTC (permalink / raw) To: Francesco Lavra Cc: Ramona Gradinariu, Antoniu Miclaus, Lars-Peter Clausen, Michael Hennerich, David Lechner, Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel On Tue, 6 Jan 2026 20:36:27 +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(). > 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 9f6c0e02575a..ce3643c5deb8 100644 > --- a/drivers/iio/accel/adxl380.c > +++ b/drivers/iio/accel/adxl380.c > @@ -950,14 +950,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, 2 * fifo_entries); Whilst we are here can we replace that 2 with sizeof(*st->fifo_buf)? Otherwise, Antoniu, can you take a look at these change. Seem reasonable to me. Given we are fairly late in the cycle I'll probably merge them both for the next merge window and we'll have to wait until after that for the fix to make it to stable. Jonathan > + 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; > } ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-11 13:14 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-01-06 19:36 [PATCH 0/2] accel: adxl380: improve data reading from FIFO Francesco Lavra 2026-01-06 19:36 ` [PATCH 1/2] iio: accel: adxl380: Avoid reading more entries than present in FIFO Francesco Lavra 2026-01-06 19:36 ` [PATCH 2/2] iio: accel: adxl380: Optimize reading of FIFO entries in interrupt handler Francesco Lavra 2026-01-11 13:14 ` Jonathan Cameron
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®