* [PATCH 1/5] iio: accel: adxl372: Add timestamp to FIFO data
2026-05-10 8:25 [PATCH 0/5] iio: accel: adxl3xx: Add timestamps to FIFO data Md Shofiqul Islam
@ 2026-05-10 8:25 ` Md Shofiqul Islam
2026-05-16 18:55 ` David Lechner
2026-05-10 8:25 ` [PATCH 2/5] iio: accel: adxl380: " Md Shofiqul Islam
` (5 subsequent siblings)
6 siblings, 1 reply; 12+ messages in thread
From: Md Shofiqul Islam @ 2026-05-10 8:25 UTC (permalink / raw)
To: jic23
Cc: lars, Michael.Hennerich, dlechner, nuno.sa, andy, linux-iio,
linux-kernel, Md Shofiqul Islam
The driver pushes FIFO samples using iio_push_to_buffers() which does
not attach a hardware timestamp to the data. Add a scan buffer struct
with an aligned_s64 timestamp field to the driver state, capture a
single timestamp per IRQ with iio_get_time_ns(), and switch the FIFO
push loop to iio_push_to_buffers_with_timestamp(). The same timestamp
is reused for the event push call in the same handler, replacing the
duplicate iio_get_time_ns() invocation there.
Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
---
drivers/iio/accel/adxl372.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c
index 545a21e5a3..521e8313b1 100644
--- a/drivers/iio/accel/adxl372.c
+++ b/drivers/iio/accel/adxl372.c
@@ -367,6 +367,10 @@ struct adxl372_state {
u16 watermark;
__be16 fifo_buf[ADXL372_FIFO_SIZE];
bool peak_fifo_mode_en;
+ struct {
+ __be16 channels[3];
+ aligned_s64 ts;
+ } scan;
struct mutex threshold_m; /* lock for threshold */
};
@@ -703,13 +707,15 @@ static irqreturn_t adxl372_trigger_handler(int irq, void *p)
struct adxl372_state *st = iio_priv(indio_dev);
u8 status1, status2;
u16 fifo_entries;
+ s64 ts;
int i, ret;
ret = adxl372_get_status(st, &status1, &status2, &fifo_entries);
if (ret < 0)
goto err;
- adxl372_push_event(indio_dev, iio_get_time_ns(indio_dev), status2);
+ ts = iio_get_time_ns(indio_dev);
+ adxl372_push_event(indio_dev, ts, status2);
if (st->fifo_mode != ADXL372_FIFO_BYPASSED &&
ADXL372_STATUS_1_FIFO_FULL(status1)) {
@@ -733,7 +739,10 @@ static irqreturn_t adxl372_trigger_handler(int irq, void *p)
/* filter peak detection data */
if (st->peak_fifo_mode_en)
adxl372_arrange_axis_data(st, &st->fifo_buf[i]);
- iio_push_to_buffers(indio_dev, &st->fifo_buf[i]);
+ memcpy(st->scan.channels, &st->fifo_buf[i],
+ st->fifo_set_size * sizeof(__be16));
+ iio_push_to_buffers_with_timestamp(indio_dev,
+ &st->scan, ts);
}
}
err:
--
2.54.0.windows.1
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 1/5] iio: accel: adxl372: Add timestamp to FIFO data
2026-05-10 8:25 ` [PATCH 1/5] iio: accel: adxl372: Add timestamp " Md Shofiqul Islam
@ 2026-05-16 18:55 ` David Lechner
2026-05-17 11:30 ` Jonathan Cameron
0 siblings, 1 reply; 12+ messages in thread
From: David Lechner @ 2026-05-16 18:55 UTC (permalink / raw)
To: Md Shofiqul Islam, jic23
Cc: lars, Michael.Hennerich, nuno.sa, andy, linux-iio, linux-kernel
On 5/10/26 3:25 AM, Md Shofiqul Islam wrote:
> The driver pushes FIFO samples using iio_push_to_buffers() which does
> not attach a hardware timestamp to the data. Add a scan buffer struct
> with an aligned_s64 timestamp field to the driver state, capture a
> single timestamp per IRQ with iio_get_time_ns(), and switch the FIFO
> push loop to iio_push_to_buffers_with_timestamp(). The same timestamp
> is reused for the event push call in the same handler, replacing the
> duplicate iio_get_time_ns() invocation there.
>
> Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
> ---
> drivers/iio/accel/adxl372.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c
> index 545a21e5a3..521e8313b1 100644
> --- a/drivers/iio/accel/adxl372.c
> +++ b/drivers/iio/accel/adxl372.c
> @@ -367,6 +367,10 @@ struct adxl372_state {
> u16 watermark;
> __be16 fifo_buf[ADXL372_FIFO_SIZE];
I would just change this line to:
IIO_DECLARE_BUFFER_WITH_TS(__be16, fifo_buf, ADXL372_FIFO_SIZE);
> bool peak_fifo_mode_en;
> + struct {
> + __be16 channels[3];
> + aligned_s64 ts;
> + } scan;
Then we don't need the extra struct and memcpy().
If we really do need the memcpy() for some reason, this struct
can be declared on the stack instead of here.
> struct mutex threshold_m; /* lock for threshold */
> };
>
> @@ -703,13 +707,15 @@ static irqreturn_t adxl372_trigger_handler(int irq, void *p)
> struct adxl372_state *st = iio_priv(indio_dev);
> u8 status1, status2;
> u16 fifo_entries;
> + s64 ts;
> int i, ret;
>
> ret = adxl372_get_status(st, &status1, &status2, &fifo_entries);
> if (ret < 0)
> goto err;
>
> - adxl372_push_event(indio_dev, iio_get_time_ns(indio_dev), status2);
> + ts = iio_get_time_ns(indio_dev);
> + adxl372_push_event(indio_dev, ts, status2);
>
> if (st->fifo_mode != ADXL372_FIFO_BYPASSED &&
> ADXL372_STATUS_1_FIFO_FULL(status1)) {
> @@ -733,7 +739,10 @@ static irqreturn_t adxl372_trigger_handler(int irq, void *p)
> /* filter peak detection data */
> if (st->peak_fifo_mode_en)
> adxl372_arrange_axis_data(st, &st->fifo_buf[i]);
> - iio_push_to_buffers(indio_dev, &st->fifo_buf[i]);
> + memcpy(st->scan.channels, &st->fifo_buf[i],
> + st->fifo_set_size * sizeof(__be16));
> + iio_push_to_buffers_with_timestamp(indio_dev,
> + &st->scan, ts);
> }
> }
> err:
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 1/5] iio: accel: adxl372: Add timestamp to FIFO data
2026-05-16 18:55 ` David Lechner
@ 2026-05-17 11:30 ` Jonathan Cameron
2026-05-17 12:48 ` Md Shofiqul Islam
0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Cameron @ 2026-05-17 11:30 UTC (permalink / raw)
To: David Lechner
Cc: Md Shofiqul Islam, lars, Michael.Hennerich, nuno.sa, andy,
linux-iio, linux-kernel
On Sat, 16 May 2026 13:55:34 -0500
David Lechner <dlechner@baylibre.com> wrote:
> On 5/10/26 3:25 AM, Md Shofiqul Islam wrote:
> > The driver pushes FIFO samples using iio_push_to_buffers() which does
> > not attach a hardware timestamp to the data. Add a scan buffer struct
> > with an aligned_s64 timestamp field to the driver state, capture a
> > single timestamp per IRQ with iio_get_time_ns(), and switch the FIFO
> > push loop to iio_push_to_buffers_with_timestamp(). The same timestamp
> > is reused for the event push call in the same handler, replacing the
> > duplicate iio_get_time_ns() invocation there.
> >
> > Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
> > ---
> > drivers/iio/accel/adxl372.c | 13 +++++++++++--
> > 1 file changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c
> > index 545a21e5a3..521e8313b1 100644
> > --- a/drivers/iio/accel/adxl372.c
> > +++ b/drivers/iio/accel/adxl372.c
> > @@ -367,6 +367,10 @@ struct adxl372_state {
> > u16 watermark;
>
>
> > __be16 fifo_buf[ADXL372_FIFO_SIZE];
>
> I would just change this line to:
>
> IIO_DECLARE_BUFFER_WITH_TS(__be16, fifo_buf, ADXL372_FIFO_SIZE);
Doesn't work as timestamps are per sample and that's buffering the whole fifo.
Anyhow, fifo timestamps are hard to do and this is no where near
doing it right. Far as I'm concerned this series is dead because that complexity
isn't worth doing unless we have a user needing it and I don't think we do
yet.
Jonathan
>
> > bool peak_fifo_mode_en;
> > + struct {
> > + __be16 channels[3];
> > + aligned_s64 ts;
> > + } scan;
>
> Then we don't need the extra struct and memcpy().
>
> If we really do need the memcpy() for some reason, this struct
> can be declared on the stack instead of here.
Stack might indeed work..
>
> > struct mutex threshold_m; /* lock for threshold */
> > };
> >
> > @@ -703,13 +707,15 @@ static irqreturn_t adxl372_trigger_handler(int irq, void *p)
> > struct adxl372_state *st = iio_priv(indio_dev);
> > u8 status1, status2;
> > u16 fifo_entries;
> > + s64 ts;
> > int i, ret;
> >
> > ret = adxl372_get_status(st, &status1, &status2, &fifo_entries);
> > if (ret < 0)
> > goto err;
> >
> > - adxl372_push_event(indio_dev, iio_get_time_ns(indio_dev), status2);
> > + ts = iio_get_time_ns(indio_dev);
> > + adxl372_push_event(indio_dev, ts, status2);
> >
> > if (st->fifo_mode != ADXL372_FIFO_BYPASSED &&
> > ADXL372_STATUS_1_FIFO_FULL(status1)) {
> > @@ -733,7 +739,10 @@ static irqreturn_t adxl372_trigger_handler(int irq, void *p)
> > /* filter peak detection data */
> > if (st->peak_fifo_mode_en)
> > adxl372_arrange_axis_data(st, &st->fifo_buf[i]);
> > - iio_push_to_buffers(indio_dev, &st->fifo_buf[i]);
> > + memcpy(st->scan.channels, &st->fifo_buf[i],
> > + st->fifo_set_size * sizeof(__be16));
> > + iio_push_to_buffers_with_timestamp(indio_dev,
> > + &st->scan, ts);
> > }
> > }
> > err:
>
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 1/5] iio: accel: adxl372: Add timestamp to FIFO data
2026-05-17 11:30 ` Jonathan Cameron
@ 2026-05-17 12:48 ` Md Shofiqul Islam
0 siblings, 0 replies; 12+ messages in thread
From: Md Shofiqul Islam @ 2026-05-17 12:48 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Md Shofiqul Islam, David Lechner, lars, Michael.Hennerich,
nuno.sa, andy, linux-iio, linux-kernel
Thanks for the review Jonathan, David.
Understood — I'll drop this series. The single-timestamp-per-IRQ
approach is not correct for per-sample FIFO timing, and the complexity
of doing it right isn't justified without a concrete user need.
Will revisit if that changes.
Regards,
Md Shofiqul Islam
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/5] iio: accel: adxl380: Add timestamp to FIFO data
2026-05-10 8:25 [PATCH 0/5] iio: accel: adxl3xx: Add timestamps to FIFO data Md Shofiqul Islam
2026-05-10 8:25 ` [PATCH 1/5] iio: accel: adxl372: Add timestamp " Md Shofiqul Islam
@ 2026-05-10 8:25 ` Md Shofiqul Islam
2026-05-10 8:25 ` [PATCH 3/5] iio: accel: adxl367: " Md Shofiqul Islam
` (4 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Md Shofiqul Islam @ 2026-05-10 8:25 UTC (permalink / raw)
To: jic23
Cc: lars, Michael.Hennerich, dlechner, nuno.sa, andy, linux-iio,
linux-kernel, Md Shofiqul Islam
The driver pushes FIFO samples using iio_push_to_buffers() which does
not attach a hardware timestamp to the data. Add a scan buffer struct
with an aligned_s64 timestamp field to the driver state, capture a
single timestamp per IRQ with iio_get_time_ns(), and switch the FIFO
push loop to iio_push_to_buffers_with_timestamp(). The same timestamp
is reused for the event push call in the same handler, replacing the
duplicate iio_get_time_ns() invocation there.
Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
---
drivers/iio/accel/adxl380.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/accel/adxl380.c b/drivers/iio/accel/adxl380.c
index e7bb32fbc4..b8d0d15b00 100644
--- a/drivers/iio/accel/adxl380.c
+++ b/drivers/iio/accel/adxl380.c
@@ -224,6 +224,10 @@ struct adxl380_state {
int hpf_tbl[7][2];
__be16 fifo_buf[ADXL380_FIFO_SAMPLES] __aligned(IIO_DMA_MINALIGN);
+ struct {
+ __be16 channels[4];
+ aligned_s64 ts;
+ } scan;
};
bool adxl380_readable_noinc_reg(struct device *dev, unsigned int reg)
@@ -948,6 +952,7 @@ static irqreturn_t adxl380_irq_handler(int irq, void *p)
struct adxl380_state *st = iio_priv(indio_dev);
u8 status0, status1;
u16 fifo_entries;
+ s64 ts;
int i;
int ret;
@@ -957,7 +962,8 @@ static irqreturn_t adxl380_irq_handler(int irq, void *p)
if (ret)
return IRQ_HANDLED;
- adxl380_push_event(indio_dev, iio_get_time_ns(indio_dev), status1);
+ ts = iio_get_time_ns(indio_dev);
+ adxl380_push_event(indio_dev, ts, status1);
if (!FIELD_GET(ADXL380_STATUS_0_FIFO_WM_MSK, status0))
return IRQ_HANDLED;
@@ -971,8 +977,11 @@ static irqreturn_t adxl380_irq_handler(int irq, void *p)
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]);
+ for (i = 0; i < fifo_entries; i += st->fifo_set_size) {
+ memcpy(st->scan.channels, &st->fifo_buf[i],
+ st->fifo_set_size * sizeof(__be16));
+ iio_push_to_buffers_with_timestamp(indio_dev, &st->scan, ts);
+ }
return IRQ_HANDLED;
}
--
2.54.0.windows.1
^ permalink raw reply [flat|nested] 12+ messages in thread* [PATCH 3/5] iio: accel: adxl367: Add timestamp to FIFO data
2026-05-10 8:25 [PATCH 0/5] iio: accel: adxl3xx: Add timestamps to FIFO data Md Shofiqul Islam
2026-05-10 8:25 ` [PATCH 1/5] iio: accel: adxl372: Add timestamp " Md Shofiqul Islam
2026-05-10 8:25 ` [PATCH 2/5] iio: accel: adxl380: " Md Shofiqul Islam
@ 2026-05-10 8:25 ` Md Shofiqul Islam
2026-05-10 8:25 ` [PATCH 4/5] iio: accel: adxl313: " Md Shofiqul Islam
` (3 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Md Shofiqul Islam @ 2026-05-10 8:25 UTC (permalink / raw)
To: jic23
Cc: lars, Michael.Hennerich, dlechner, nuno.sa, andy, linux-iio,
linux-kernel, Md Shofiqul Islam
The driver pushes FIFO samples using iio_push_to_buffers() which does
not attach a hardware timestamp to the data. Add a scan buffer struct
with an aligned_s64 timestamp field to the driver state, capture a
single timestamp per IRQ with iio_get_time_ns() in the IRQ handler, and
pass it into adxl367_push_fifo_data() (whose signature gains a s64 ts
parameter) to switch the FIFO push loop to
iio_push_to_buffers_with_timestamp().
Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
---
drivers/iio/accel/adxl367.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/accel/adxl367.c b/drivers/iio/accel/adxl367.c
index 0c04b2bb7e..2852f2fdfa 100644
--- a/drivers/iio/accel/adxl367.c
+++ b/drivers/iio/accel/adxl367.c
@@ -179,6 +179,10 @@ struct adxl367_state {
__be16 fifo_buf[ADXL367_FIFO_SIZE] __aligned(IIO_DMA_MINALIGN);
__be16 sample_buf;
+ struct {
+ __be16 channels[4];
+ aligned_s64 ts;
+ } scan;
u8 act_threshold_buf[2];
u8 inact_time_buf[2];
u8 status_buf[3];
@@ -779,7 +783,7 @@ static bool adxl367_push_event(struct iio_dev *indio_dev, u8 status)
}
static bool adxl367_push_fifo_data(struct iio_dev *indio_dev, u8 status,
- u16 fifo_entries)
+ u16 fifo_entries, s64 ts)
{
struct adxl367_state *st = iio_priv(indio_dev);
int ret;
@@ -796,8 +800,11 @@ static bool adxl367_push_fifo_data(struct iio_dev *indio_dev, u8 status,
return true;
}
- for (i = 0; i < fifo_entries; i += st->fifo_set_size)
- iio_push_to_buffers(indio_dev, &st->fifo_buf[i]);
+ for (i = 0; i < fifo_entries; i += st->fifo_set_size) {
+ memcpy(st->scan.channels, &st->fifo_buf[i],
+ st->fifo_set_size * sizeof(__be16));
+ iio_push_to_buffers_with_timestamp(indio_dev, &st->scan, ts);
+ }
return true;
}
@@ -809,14 +816,16 @@ static irqreturn_t adxl367_irq_handler(int irq, void *private)
u16 fifo_entries;
bool handled;
u8 status;
+ s64 ts;
int ret;
ret = adxl367_get_status(st, &status, &fifo_entries);
if (ret)
return IRQ_NONE;
+ ts = iio_get_time_ns(indio_dev);
handled = adxl367_push_event(indio_dev, status);
- handled |= adxl367_push_fifo_data(indio_dev, status, fifo_entries);
+ handled |= adxl367_push_fifo_data(indio_dev, status, fifo_entries, ts);
return handled ? IRQ_HANDLED : IRQ_NONE;
}
--
2.54.0.windows.1
^ permalink raw reply [flat|nested] 12+ messages in thread* [PATCH 4/5] iio: accel: adxl313: Add timestamp to FIFO data
2026-05-10 8:25 [PATCH 0/5] iio: accel: adxl3xx: Add timestamps to FIFO data Md Shofiqul Islam
` (2 preceding siblings ...)
2026-05-10 8:25 ` [PATCH 3/5] iio: accel: adxl367: " Md Shofiqul Islam
@ 2026-05-10 8:25 ` Md Shofiqul Islam
2026-05-10 8:25 ` [PATCH 5/5] iio: accel: adxl345: " Md Shofiqul Islam
` (2 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Md Shofiqul Islam @ 2026-05-10 8:25 UTC (permalink / raw)
To: jic23
Cc: lars, Michael.Hennerich, dlechner, nuno.sa, andy, linux-iio,
linux-kernel, Md Shofiqul Islam
The driver pushes FIFO samples using iio_push_to_buffers() which does
not attach a hardware timestamp to the data. Add a scan buffer struct
with an aligned_s64 timestamp field to struct adxl313_data (in
adxl313.h), capture a timestamp with iio_get_time_ns() at the start of
adxl313_fifo_push(), and switch the push loop to
iio_push_to_buffers_with_timestamp(). The ADXL313 always scans all
three axes together so the scan buffer layout is fixed.
Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
---
drivers/iio/accel/adxl313.h | 4 ++++
drivers/iio/accel/adxl313_core.c | 8 ++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/accel/adxl313.h b/drivers/iio/accel/adxl313.h
index 75ef54b60f..ea5792fae2 100644
--- a/drivers/iio/accel/adxl313.h
+++ b/drivers/iio/accel/adxl313.h
@@ -94,6 +94,10 @@ struct adxl313_data {
u8 watermark;
__le16 transf_buf __aligned(IIO_DMA_MINALIGN);
__le16 fifo_buf[ADXL313_NUM_AXIS * ADXL313_FIFO_SIZE + 1];
+ struct {
+ __le16 channels[ADXL313_NUM_AXIS];
+ aligned_s64 ts;
+ } scan;
};
struct adxl313_chip_info {
diff --git a/drivers/iio/accel/adxl313_core.c b/drivers/iio/accel/adxl313_core.c
index bcc11dabdf..bd45b90c42 100644
--- a/drivers/iio/accel/adxl313_core.c
+++ b/drivers/iio/accel/adxl313_core.c
@@ -1013,6 +1013,7 @@ static const struct iio_buffer_setup_ops adxl313_buffer_ops = {
static int adxl313_fifo_push(struct iio_dev *indio_dev, int samples)
{
struct adxl313_data *data = iio_priv(indio_dev);
+ s64 ts = iio_get_time_ns(indio_dev);
unsigned int i;
int ret;
@@ -1020,8 +1021,11 @@ static int adxl313_fifo_push(struct iio_dev *indio_dev, int samples)
if (ret)
return ret;
- for (i = 0; i < ADXL313_NUM_AXIS * samples; i += ADXL313_NUM_AXIS)
- iio_push_to_buffers(indio_dev, &data->fifo_buf[i]);
+ for (i = 0; i < ADXL313_NUM_AXIS * samples; i += ADXL313_NUM_AXIS) {
+ memcpy(data->scan.channels, &data->fifo_buf[i],
+ sizeof(data->scan.channels));
+ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, ts);
+ }
return 0;
}
--
2.54.0.windows.1
^ permalink raw reply [flat|nested] 12+ messages in thread* [PATCH 5/5] iio: accel: adxl345: Add timestamp to FIFO data
2026-05-10 8:25 [PATCH 0/5] iio: accel: adxl3xx: Add timestamps to FIFO data Md Shofiqul Islam
` (3 preceding siblings ...)
2026-05-10 8:25 ` [PATCH 4/5] iio: accel: adxl313: " Md Shofiqul Islam
@ 2026-05-10 8:25 ` Md Shofiqul Islam
2026-05-10 12:58 ` [PATCH 0/5] iio: accel: adxl3xx: Add timestamps " Andy Shevchenko
2026-05-14 18:35 ` Md Shofiqul Islam
6 siblings, 0 replies; 12+ messages in thread
From: Md Shofiqul Islam @ 2026-05-10 8:25 UTC (permalink / raw)
To: jic23
Cc: lars, Michael.Hennerich, dlechner, nuno.sa, andy, linux-iio,
linux-kernel, Md Shofiqul Islam
The driver pushes FIFO samples using iio_push_to_buffers() which does
not attach a hardware timestamp to the data. Add a scan buffer struct
with an aligned_s64 timestamp field to struct adxl345_state, capture a
timestamp with iio_get_time_ns() at the start of adxl345_fifo_push(),
and switch the push loop to iio_push_to_buffers_with_timestamp(). The
ADXL345 always scans all three axes together so the scan buffer layout
is fixed.
Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
---
drivers/iio/accel/adxl345_core.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
index 6c9080d88c..2b121bed89 100644
--- a/drivers/iio/accel/adxl345_core.c
+++ b/drivers/iio/accel/adxl345_core.c
@@ -204,6 +204,10 @@ struct adxl345_state {
u32 tap_window_us;
__le16 fifo_buf[ADXL345_DIRS * ADXL345_FIFO_SIZE + 1] __aligned(IIO_DMA_MINALIGN);
+ struct {
+ __le16 channels[ADXL345_DIRS];
+ aligned_s64 ts;
+ } scan;
};
static const struct iio_event_spec adxl345_events[] = {
@@ -1657,6 +1661,7 @@ static int adxl345_fifo_push(struct iio_dev *indio_dev,
int samples)
{
struct adxl345_state *st = iio_priv(indio_dev);
+ s64 ts = iio_get_time_ns(indio_dev);
int i, ret;
if (samples <= 0)
@@ -1666,8 +1671,11 @@ static int adxl345_fifo_push(struct iio_dev *indio_dev,
if (ret)
return ret;
- for (i = 0; i < ADXL345_DIRS * samples; i += ADXL345_DIRS)
- iio_push_to_buffers(indio_dev, &st->fifo_buf[i]);
+ for (i = 0; i < ADXL345_DIRS * samples; i += ADXL345_DIRS) {
+ memcpy(st->scan.channels, &st->fifo_buf[i],
+ sizeof(st->scan.channels));
+ iio_push_to_buffers_with_timestamp(indio_dev, &st->scan, ts);
+ }
return 0;
}
--
2.54.0.windows.1
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 0/5] iio: accel: adxl3xx: Add timestamps to FIFO data
2026-05-10 8:25 [PATCH 0/5] iio: accel: adxl3xx: Add timestamps to FIFO data Md Shofiqul Islam
` (4 preceding siblings ...)
2026-05-10 8:25 ` [PATCH 5/5] iio: accel: adxl345: " Md Shofiqul Islam
@ 2026-05-10 12:58 ` Andy Shevchenko
[not found] ` <CAOTCDVsUF1qaYgSGa4hcDYOqmMpkK2G+HYeQ=ShQ1oEbM8nGJQ@mail.gmail.com>
2026-05-14 18:35 ` Md Shofiqul Islam
6 siblings, 1 reply; 12+ messages in thread
From: Andy Shevchenko @ 2026-05-10 12:58 UTC (permalink / raw)
To: Md Shofiqul Islam
Cc: jic23, lars, Michael.Hennerich, dlechner, nuno.sa, andy,
linux-iio, linux-kernel
On Sun, May 10, 2026 at 11:25:51AM +0300, Md Shofiqul Islam wrote:
> Five ADXL-family accelerometer drivers (ADXL313, ADXL345, ADXL367,
> ADXL372, ADXL380) push buffered samples using iio_push_to_buffers(),
> which does not attach a hardware timestamp to the scan data.
> Userspace consumers therefore receive samples with no timing
> information.
>
> This series adds timestamp support uniformly across the family:
>
> - A scan buffer struct with an aligned_s64 ts field is added to each
> driver's state struct. The struct layout ensures the timestamp
> field sits at an 8-byte aligned offset as required by
> iio_push_to_buffers_with_timestamp().
>
> - In the FIFO push loop, FIFO data is copied into scan.channels via
> memcpy(), then iio_push_to_buffers_with_timestamp() is called with
> a single timestamp captured once per interrupt with
> iio_get_time_ns(). Using one timestamp per IRQ is consistent with
> the existing approach in the same handlers for event timestamps.
>
> - For ADXL367, the helper adxl367_push_fifo_data() gains a s64 ts
> parameter so the timestamp captured in the IRQ handler is passed
> through instead of calling iio_get_time_ns() a second time.
>
> - For ADXL372 and ADXL380, where the IRQ handler already called
> iio_get_time_ns() for the event push, the same captured timestamp
> is now also passed to the FIFO push, removing the duplicate call.
>
> The ADXL313 and ADXL345 drivers always scan all three axes together
> (available_scan_masks contains only the full X|Y|Z mask), so their
> scan buffer layout is fixed. The ADXL367, ADXL372, and ADXL380
> drivers support variable scan masks; fifo_set_size tracks the number
> of enabled channels per sample set and is used as the memcpy length.
This is sensitive change. Do we have any confirmation that this
- does work as expected on real HW and platforms that use these devices
- does not break any ABI
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 0/5] iio: accel: adxl3xx: Add timestamps to FIFO data
2026-05-10 8:25 [PATCH 0/5] iio: accel: adxl3xx: Add timestamps to FIFO data Md Shofiqul Islam
` (5 preceding siblings ...)
2026-05-10 12:58 ` [PATCH 0/5] iio: accel: adxl3xx: Add timestamps " Andy Shevchenko
@ 2026-05-14 18:35 ` Md Shofiqul Islam
6 siblings, 0 replies; 12+ messages in thread
From: Md Shofiqul Islam @ 2026-05-14 18:35 UTC (permalink / raw)
To: jic23
Cc: andy, lars, Michael.Hennerich, dlechner, nuno.sa, linux-iio,
linux-kernel
On Mon, 11 May 2026, Jonathan Cameron wrote:
> It is possible to approximate the correct timestamps but it's complex.
> You definitely don't want to try getting timestamps working for a fifo
> equipped part without real hardware so you can plot them over time and
> verify there are no inconsistencies or bugs in your timestamp
> approximation algorithm.
Understood -- thank you for the detailed explanation. I'll drop this
series. I don't have access to any of the ADXL hardware so I cannot
validate a per-sample timestamp approximation algorithm. I'll leave
this for someone with real devices to pick up when they are ready to
implement it properly, with the correct per-sample backfilling from
the FIFO watermark timestamp.
Thanks,
Shofiq
^ permalink raw reply [flat|nested] 12+ messages in thread