Skip to content

Commit 8844ed0

Browse files
jmaneyrol-invnjic23
authored andcommitted
iio: imu: inv_mpu6050: stabilized timestamping in interrupt
Use IRQ ONESHOT flag to ensure the timestamp is not updated in the hard handler during the thread handler. And use a fixed value of 1 sample that correspond to this first timestamp. This way we can ensure the timestamp is always corresponding to the value used by the timestamping mechanism. Otherwise, it is possible that between FIFO count read and FIFO processing the timestamp is overwritten in the hard handler. Fixes: 111e1ab ("iio: imu: inv_mpu6050: use the common inv_sensors timestamp module") Cc: stable@vger.kernel.org Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Link: https://lore.kernel.org/r/20240527150117.608792-1-inv.git-commit@tdk.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 182bc49 commit 8844ed0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
100100
goto end_session;
101101
/* Each FIFO data contains all sensors, so same number for FIFO and sensor data */
102102
fifo_period = NSEC_PER_SEC / INV_MPU6050_DIVIDER_TO_FIFO_RATE(st->chip_config.divider);
103-
inv_sensors_timestamp_interrupt(&st->timestamp, nb, pf->timestamp);
104-
inv_sensors_timestamp_apply_odr(&st->timestamp, fifo_period, nb, 0);
103+
inv_sensors_timestamp_interrupt(&st->timestamp, 1, pf->timestamp);
104+
inv_sensors_timestamp_apply_odr(&st->timestamp, fifo_period, 1, 0);
105105

106106
/* clear internal data buffer for avoiding kernel data leak */
107107
memset(data, 0, sizeof(data));

drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev, int irq_type)
300300
if (!st->trig)
301301
return -ENOMEM;
302302

303+
irq_type |= IRQF_ONESHOT;
303304
ret = devm_request_threaded_irq(&indio_dev->dev, st->irq,
304305
&inv_mpu6050_interrupt_timestamp,
305306
&inv_mpu6050_interrupt_handle,

0 commit comments

Comments
 (0)