Re: [PATCH] iio: imu: st_lsm6dsx: fall back to 25 us/tick without a trim
From: Lorenzo Bianconi
Date: Mon Nov 16 2026 - 03:55:49 EST
On Nov 16, Phil Williams via B4 Relay wrote:
> From: Phil Williams <phil.williams@xxxxxxxxxxxxxx>
>
> Commit 8abbf45fcda0 ("iio: st_lsm6dsx: Fixed calibrated timestamp
> calculation") takes the FIFO timestamp scale from ts_sensitivity.
> That field is only filled in for parts that have freq_fine. The
> untagged-FIFO parts are left at zero:
>
> LSM6DS3
> LSM6DS3H
> LSM6DSL, LSM6DSM, ISM330DLC and LSM6DS3TR-C
>
> st_lsm6dsx_read_fifo() multiplies the raw counter by hw->ts_gain, so
> every sample is published with the timestamp taken when the buffer
> was enabled. The accelerometer and gyroscope values still update.
> Userspace that integrates attitude from the timestamp delta treats a
> stuck timestamp as dt = 0.
>
> These parts have no freq_fine register, so there is no trim to apply.
> Use the previous fixed scale of 25000 ns/tick when ts_sensitivity is
> unset. Entries that already set it are left alone.
>
> Fixes: 8abbf45fcda0 ("iio: st_lsm6dsx: Fixed calibrated timestamp calculation")
> Cc: stable@xxxxxxxxxxxxxxx
> Suggested-by: Jonathan Cameron <jic23@xxxxxxxxxx>
> Signed-off-by: Phil Williams <phil.williams@xxxxxxxxxxxxxx>
> ---
> Resending inline. The first copy went out as an attachment.
> No code changes.
> ---
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 823f8ac66..98db90a30 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -2525,8 +2525,14 @@ static int st_lsm6dsx_init_hw_timer(struct st_lsm6dsx_hw *hw)
> return err;
> }
>
> - /* calibrate timestamp sensitivity */
> + /*
> + * Parts with no freq_fine register have no trim and leave
> + * ts_sensitivity unset. Those parts used a fixed 25 us/tick.
> + * A zero gain publishes every FIFO sample with one timestamp.
> + */
> hw->ts_gain = ts_settings->ts_sensitivity;
> + if (!hw->ts_gain)
> + hw->ts_gain = 25000;
I guess the patch is fine but it seems a bit weird to set .ts_sensitivity to
25000 for ST_LSM6DSR_* family in st_lsm6dsx_sensor_settings array and keep this
chek here. Is it better to just add the missing info in
st_lsm6dsx_sensor_settings? (I do not have a strong opinion about it).
Regards,
Lorenzo
> if (ts_settings->freq_fine) {
> err = regmap_read(hw->regmap, ts_settings->freq_fine, &val);
> if (err < 0)
>
> ---
> base-commit: fa2933aac170dd19c6a7f0d7b81a8f537e40915c
> change-id: 20261116-st-lsm6dsx-ts-fallback-cd21f1d1e30e
>
> Best regards,
> --
> Phil Williams <phil.williams@xxxxxxxxxxxxxx>
>
>
Attachment:
signature.asc
Description: PGP signature