mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-07-25 16:19:48 +02:00
iio: imu: inv_icm42600: fix timestamping by limiting FIFO reading
Timestamps are made by measuring the chip clock using the watermark
interrupts. If we read more than watermark samples as done today, we
are reducing the period between interrupts and distort the time
measurement. Fix that by reading only watermark samples in the
interrupt case.
Fixes: 7f85e42a6c ("iio: imu: inv_icm42600: add buffer support in iio devices")
Cc: stable@vger.kernel.org
Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
committed by
Jonathan Cameron
parent
aede83625f
commit
affe3f077d
@@ -248,6 +248,7 @@ int inv_icm42600_buffer_update_watermark(struct inv_icm42600_state *st)
|
||||
|
||||
/* compute watermark value in bytes */
|
||||
wm_size = watermark * packet_size;
|
||||
st->fifo.watermark.value = watermark;
|
||||
|
||||
/* changing FIFO watermark requires to turn off watermark interrupt */
|
||||
ret = regmap_update_bits_check(st->map, INV_ICM42600_REG_INT_SOURCE0,
|
||||
@@ -454,11 +455,10 @@ int inv_icm42600_buffer_fifo_read(struct inv_icm42600_state *st,
|
||||
st->fifo.nb.accel = 0;
|
||||
st->fifo.nb.total = 0;
|
||||
|
||||
/* compute maximum FIFO read size */
|
||||
/* compute maximum FIFO read size (watermark for max = 0 interrupt case) */
|
||||
if (max == 0)
|
||||
max_count = sizeof(st->fifo.data);
|
||||
else
|
||||
max_count = max * inv_icm42600_get_packet_size(st->fifo.en);
|
||||
max = st->fifo.watermark.value;
|
||||
max_count = max * inv_icm42600_get_packet_size(st->fifo.en);
|
||||
|
||||
/* read FIFO count value */
|
||||
raw_fifo_count = (__be16 *)st->buffer;
|
||||
@@ -574,6 +574,7 @@ int inv_icm42600_buffer_init(struct inv_icm42600_state *st)
|
||||
|
||||
st->fifo.watermark.eff_gyro = 1;
|
||||
st->fifo.watermark.eff_accel = 1;
|
||||
st->fifo.watermark.value = 1;
|
||||
|
||||
/*
|
||||
* Default FIFO configuration (bits 7 to 5)
|
||||
|
||||
@@ -34,6 +34,7 @@ struct inv_icm42600_fifo {
|
||||
unsigned int accel;
|
||||
unsigned int eff_gyro;
|
||||
unsigned int eff_accel;
|
||||
unsigned int value;
|
||||
} watermark;
|
||||
size_t count;
|
||||
struct {
|
||||
|
||||
Reference in New Issue
Block a user