Linux IIO development
 help / color / mirror / Atom feed
* [PATCH v2 0/4] inv_icm42600 driver enhancements
@ 2026-08-24 12:30 Jean-Baptiste Maneyrol via B4 Relay
  2026-08-24 12:30 ` [PATCH v2 1/4] iio: imu: inv_icm42600: sleep before enabling FIFO data Jean-Baptiste Maneyrol via B4 Relay
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Jean-Baptiste Maneyrol via B4 Relay @ 2026-08-24 12:30 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
  Cc: linux-iio, linux-kernel, Jean-Baptiste Maneyrol,
	Jean-Baptiste Maneyrol, Jonathan Cameron

This series add enhancements patches to inv_icm42600 driver.

It includes:
1. Move of MEMS stabilization sleep before FIFO configuration to avoid
   pushing incorrect data.
2. Use a fixed FIFO frame of 16 bits to avoid a bug of dynamic FIFO
   configuration changed triggered by the sleep move.
3. Simplify watermark computation using gcd.
4. Enhance support of high frequency streaming by avoiding read of FIFO
   count for watermark interrupt.

Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
---
Changes in v2:
- Add commentaries for easing understanding of changes.
- Reword commit messages with better explanations.
- Link to v1: https://patch.msgid.link/20260820-inv-icm42600-enhacements-v1-0-075a881db557@tdk.com

To: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
To: Jonathan Cameron <jic23@kernel.org>
To: David Lechner <dlechner@baylibre.com>
To: Nuno Sá <nuno.sa@analog.com>
To: Andy Shevchenko <andy@kernel.org>
Cc: linux-iio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

---
Jean-Baptiste Maneyrol (4):
      iio: imu: inv_icm42600: sleep before enabling FIFO data
      iio: imu: inv_icm42600: use 2 sensors fixed packet size of 16 bytes
      iio: imu: inv_icm42600: simplify watermark computation by using GCD
      iio: imu: inv_icm42600: do not read FIFO count for watermark it

 drivers/iio/imu/inv_icm42600/inv_icm42600.h        |   4 +-
 drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c  |  16 ++-
 drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c | 112 +++++++++------------
 drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c   |  16 ++-
 4 files changed, 73 insertions(+), 75 deletions(-)
---
base-commit: 53c022f51fbe540fffee2121ce9ed3e15266c9a4
change-id: 20260709-inv-icm42600-enhacements-1e0e18e6f868

Best regards,
--  
Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/4] iio: imu: inv_icm42600: sleep before enabling FIFO data
  2026-08-24 12:30 [PATCH v2 0/4] inv_icm42600 driver enhancements Jean-Baptiste Maneyrol via B4 Relay
@ 2026-08-24 12:30 ` Jean-Baptiste Maneyrol via B4 Relay
  2026-08-24 12:30 ` [PATCH v2 2/4] iio: imu: inv_icm42600: use 2 sensors fixed packet size of 16 bytes Jean-Baptiste Maneyrol via B4 Relay
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jean-Baptiste Maneyrol via B4 Relay @ 2026-08-24 12:30 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
  Cc: linux-iio, linux-kernel, Jean-Baptiste Maneyrol,
	Jean-Baptiste Maneyrol, Jonathan Cameron

From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

When turning accel or gyro on, a sleep is required for letting the
mechanical part stabilize before reporting correct data. Move the
sleep before enabling FIFO data to prevent push of incorrect data.

We need to unlock the driver mutex while sleeping to not block data
of the other sensor if it is running. There is no possible race here
because we are already under IIO mode mutex locked since it is a
IIO buffer callback.

Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
---
 drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 16 ++++++++++++----
 drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c  | 16 ++++++++++++----
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c
index 4b0e3cd8a506..3197081a808a 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c
@@ -254,15 +254,23 @@ static int inv_icm42600_accel_update_scan_mode(struct iio_dev *indio_dev,
 		fifo_en |= INV_ICM42600_SENSOR_ACCEL;
 	}
 
+	/*
+	 * Sleep maximum stabilization time before enabling data in FIFO.
+	 * We need to release the driver lock to not block gyro data processing.
+	 * There is no possible race here since we are under IIO mutex locked.
+	 */
+	sleep = max(sleep_accel, sleep_temp);
+	if (sleep) {
+		mutex_unlock(&st->lock);
+		msleep(sleep);
+		mutex_lock(&st->lock);
+	}
+
 	/* update data FIFO write */
 	ret = inv_icm42600_buffer_set_fifo_en(st, fifo_en | st->fifo.en);
 
 out_unlock:
 	mutex_unlock(&st->lock);
-	/* sleep maximum required time */
-	sleep = max(sleep_accel, sleep_temp);
-	if (sleep)
-		msleep(sleep);
 	return ret;
 }
 
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c
index 253bf571439d..9de5c383665f 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c
@@ -126,15 +126,23 @@ static int inv_icm42600_gyro_update_scan_mode(struct iio_dev *indio_dev,
 		fifo_en |= INV_ICM42600_SENSOR_GYRO;
 	}
 
+	/*
+	 * Sleep maximum stabilization time before enabling data in FIFO.
+	 * We need to release the driver lock to not block accel data processing.
+	 * There is no possible race here since we are under IIO mutex locked.
+	 */
+	sleep = max(sleep_gyro, sleep_temp);
+	if (sleep) {
+		mutex_unlock(&st->lock);
+		msleep(sleep);
+		mutex_lock(&st->lock);
+	}
+
 	/* update data FIFO write */
 	ret = inv_icm42600_buffer_set_fifo_en(st, fifo_en | st->fifo.en);
 
 out_unlock:
 	mutex_unlock(&st->lock);
-	/* sleep maximum required time */
-	sleep = max(sleep_gyro, sleep_temp);
-	if (sleep)
-		msleep(sleep);
 	return ret;
 }
 

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/4] iio: imu: inv_icm42600: use 2 sensors fixed packet size of 16 bytes
  2026-08-24 12:30 [PATCH v2 0/4] inv_icm42600 driver enhancements Jean-Baptiste Maneyrol via B4 Relay
  2026-08-24 12:30 ` [PATCH v2 1/4] iio: imu: inv_icm42600: sleep before enabling FIFO data Jean-Baptiste Maneyrol via B4 Relay
@ 2026-08-24 12:30 ` Jean-Baptiste Maneyrol via B4 Relay
  2026-08-24 12:30 ` [PATCH v2 3/4] iio: imu: inv_icm42600: simplify watermark computation by using GCD Jean-Baptiste Maneyrol via B4 Relay
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jean-Baptiste Maneyrol via B4 Relay @ 2026-08-24 12:30 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
  Cc: linux-iio, linux-kernel, Jean-Baptiste Maneyrol,
	Jean-Baptiste Maneyrol, Jonathan Cameron

From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

Sometimes dynamic switch between 1 sensor frame to 2 sensors frame is
not working when there are too much frames already in the FIFO. By
moving accel/gyro on sleep before turning FIFO on, we are storing many
FIFO frames before updating the frame format hitting the bug everytime.

Fix that by always using the 2 sensors frame of 16 bytes. Also update
the hwfifo max watermark reported.

Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
---
 drivers/iio/imu/inv_icm42600/inv_icm42600.h        |  4 +--
 drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c | 34 ++++++++--------------
 2 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600.h b/drivers/iio/imu/inv_icm42600/inv_icm42600.h
index b55d993f0264..f6c7c84c7e45 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600.h
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600.h
@@ -356,8 +356,8 @@ struct inv_icm42600_sensor_state {
 		cpu_to_le16((_wm) & GENMASK(11, 0))
 /* FIFO is 2048 bytes, let 12 samples for reading latency */
 #define INV_ICM42600_FIFO_WATERMARK_MAX			(2048 - 12 * 16)
-/* INV_ICM42600_FIFO_WATERMARK_MAX / 8 = 232 */
-#define INV_ICM42600_FIFO_WATERMARK_MAX_SAMPLES		232
+/* INV_ICM42600_FIFO_WATERMARK_MAX / 16 = 116 */
+#define INV_ICM42600_FIFO_WATERMARK_MAX_SAMPLES		116
 
 #define INV_ICM42600_REG_INT_CONFIG1			0x0064
 #define INV_ICM42600_INT_CONFIG1_TPULSE_DURATION	BIT(6)
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
index 998d312f7bde..5421122057ee 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
@@ -131,13 +131,16 @@ int inv_icm42600_buffer_set_fifo_en(struct inv_icm42600_state *st,
 		INV_ICM42600_FIFO_CONFIG1_GYRO_EN |
 		INV_ICM42600_FIFO_CONFIG1_ACCEL_EN;
 
-	val = 0;
-	if (fifo_en & INV_ICM42600_SENSOR_GYRO)
-		val |= INV_ICM42600_FIFO_CONFIG1_GYRO_EN;
-	if (fifo_en & INV_ICM42600_SENSOR_ACCEL)
-		val |= INV_ICM42600_FIFO_CONFIG1_ACCEL_EN;
-	if (fifo_en & INV_ICM42600_SENSOR_TEMP)
-		val |= INV_ICM42600_FIFO_CONFIG1_TEMP_EN;
+	/*
+	 * Always enable/disable all bits to ensure we can flawlessly add
+	 * accel/gyro data in the FIFO while it is running.
+	 */
+	if (fifo_en)
+		val = INV_ICM42600_FIFO_CONFIG1_TEMP_EN |
+		      INV_ICM42600_FIFO_CONFIG1_GYRO_EN |
+		      INV_ICM42600_FIFO_CONFIG1_ACCEL_EN;
+	else
+		val = 0;
 
 	ret = regmap_update_bits(st->map, INV_ICM42600_REG_FIFO_CONFIG1, mask, val);
 	if (ret)
@@ -149,19 +152,6 @@ int inv_icm42600_buffer_set_fifo_en(struct inv_icm42600_state *st,
 	return 0;
 }
 
-static size_t inv_icm42600_get_packet_size(unsigned int fifo_en)
-{
-	size_t packet_size;
-
-	if ((fifo_en & INV_ICM42600_SENSOR_GYRO) &&
-	    (fifo_en & INV_ICM42600_SENSOR_ACCEL))
-		packet_size = INV_ICM42600_FIFO_2SENSORS_PACKET_SIZE;
-	else
-		packet_size = INV_ICM42600_FIFO_1SENSOR_PACKET_SIZE;
-
-	return packet_size;
-}
-
 static unsigned int inv_icm42600_wm_truncate(unsigned int watermark,
 					     size_t packet_size)
 {
@@ -209,7 +199,7 @@ int inv_icm42600_buffer_update_watermark(struct inv_icm42600_state *st)
 	__le16 raw_wm;
 	int ret;
 
-	packet_size = inv_icm42600_get_packet_size(st->fifo.en);
+	packet_size = INV_ICM42600_FIFO_2SENSORS_PACKET_SIZE;
 
 	/* compute sensors latency, depending on sensor watermark and odr */
 	wm_gyro = inv_icm42600_wm_truncate(st->fifo.watermark.gyro, packet_size);
@@ -495,7 +485,7 @@ int inv_icm42600_buffer_fifo_read(struct inv_icm42600_state *st,
 	/* compute maximum FIFO read size (watermark for max = 0 interrupt case) */
 	if (max == 0)
 		max = st->fifo.watermark.value;
-	max_count = max * inv_icm42600_get_packet_size(st->fifo.en);
+	max_count = max * INV_ICM42600_FIFO_2SENSORS_PACKET_SIZE;
 
 	/* read FIFO count value */
 	raw_fifo_count = (__be16 *)st->buffer;

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/4] iio: imu: inv_icm42600: simplify watermark computation by using GCD
  2026-08-24 12:30 [PATCH v2 0/4] inv_icm42600 driver enhancements Jean-Baptiste Maneyrol via B4 Relay
  2026-08-24 12:30 ` [PATCH v2 1/4] iio: imu: inv_icm42600: sleep before enabling FIFO data Jean-Baptiste Maneyrol via B4 Relay
  2026-08-24 12:30 ` [PATCH v2 2/4] iio: imu: inv_icm42600: use 2 sensors fixed packet size of 16 bytes Jean-Baptiste Maneyrol via B4 Relay
@ 2026-08-24 12:30 ` Jean-Baptiste Maneyrol via B4 Relay
  2026-08-24 12:30 ` [PATCH v2 4/4] iio: imu: inv_icm42600: do not read FIFO count for watermark it Jean-Baptiste Maneyrol via B4 Relay
  2026-08-31  1:27 ` [PATCH v2 0/4] inv_icm42600 driver enhancements Jonathan Cameron
  4 siblings, 0 replies; 6+ messages in thread
From: Jean-Baptiste Maneyrol via B4 Relay @ 2026-08-24 12:30 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
  Cc: linux-iio, linux-kernel, Jean-Baptiste Maneyrol,
	Jean-Baptiste Maneyrol, Jonathan Cameron

From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

The watermark computation was in fact resulting in computing the GCD
of the latencies when both sensors are on. GCD is required because
of the IIO buffer watermark.

Move to use gcd() and update documentation accordingly.

Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
---
 drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c | 47 ++++++++++------------
 1 file changed, 21 insertions(+), 26 deletions(-)

diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
index 5421122057ee..b1a43ca610c4 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
@@ -5,6 +5,7 @@
 
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/gcd.h>
 #include <linux/kernel.h>
 #include <linux/minmax.h>
 #include <linux/mutex.h>
@@ -175,15 +176,14 @@ static unsigned int inv_icm42600_wm_truncate(unsigned int watermark,
  *
  * FIFO watermark threshold is computed based on the required watermark values
  * set for gyro and accel sensors. Since watermark is all about acceptable data
- * latency, use the smallest setting between the 2. It means choosing the
- * smallest latency but this is not as simple as choosing the smallest watermark
- * value. Latency depends on watermark and ODR. It requires several steps:
- * 1) compute gyro and accel latencies and choose the smallest value.
- * 2) adapt the chosen latency so that it is a multiple of both gyro and accel
- *    ones. Otherwise it is possible that you don't meet a requirement. (for
- *    example with gyro @100Hz wm 4 and accel @100Hz with wm 6, choosing the
- *    value of 4 will not meet accel latency requirement because 6 is not a
- *    multiple of 4. You need to use the value 2.)
+ * latency, we should need to use the smallest latency value. But it is not as
+ * simple as choosing the smallest watermark value. Latency depends on watermark
+ * and ODR and IIO buffer watermark adds another requirement. The required steps:
+ * 1) compute gyro and accel periods and latencies
+ * 2) Use the smallest period and the GCD of the latencies. GCD is required
+ *    because of the IIO buffer watermark that will prevent send of data if not
+ *    crossed. Thus accel and gyro watermarks must be a multiple of the watermark
+ *    value. Computing the GCD gives us the biggest value that meets this criteria.
  * 3) Since all periods are multiple of each others, watermark is computed by
  *    dividing this computed latency by the smallest period, which corresponds
  *    to the FIFO frequency. Beware that this is only true because we are not
@@ -193,7 +193,7 @@ int inv_icm42600_buffer_update_watermark(struct inv_icm42600_state *st)
 {
 	size_t packet_size, wm_size;
 	unsigned int wm_gyro, wm_accel, watermark;
-	u32 period_gyro, period_accel;
+	u32 period_gyro, period_accel, period;
 	u32 latency_gyro, latency_accel, latency;
 	bool restore;
 	__le16 raw_wm;
@@ -221,22 +221,17 @@ int inv_icm42600_buffer_update_watermark(struct inv_icm42600_state *st)
 		watermark = wm_gyro;
 		st->fifo.watermark.eff_gyro = wm_gyro;
 	} else {
-		/* compute the smallest latency that is a multiple of both */
-		if (latency_gyro <= latency_accel)
-			latency = latency_gyro - (latency_accel % latency_gyro);
-		else
-			latency = latency_accel - (latency_gyro % latency_accel);
-		/* all this works because periods are multiple of each others */
-		watermark = latency / min(period_gyro, period_accel);
-		if (watermark < 1)
-			watermark = 1;
-		/* update effective watermark */
-		st->fifo.watermark.eff_gyro = latency / period_gyro;
-		if (st->fifo.watermark.eff_gyro < 1)
-			st->fifo.watermark.eff_gyro = 1;
-		st->fifo.watermark.eff_accel = latency / period_accel;
-		if (st->fifo.watermark.eff_accel < 1)
-			st->fifo.watermark.eff_accel = 1;
+		/*
+		 * In case of both accel and gyro enabled, we need to use the
+		 * shortest period and the gcd of the latencies. Gcd is required
+		 * because of the IIO buffer watermark that will prevent data
+		 * sending if we are not crossing the watermark level.
+		 */
+		period = min(period_gyro, period_accel);
+		latency = gcd(latency_gyro, latency_accel);
+		watermark = max(latency / period, 1);
+		st->fifo.watermark.eff_gyro = max(latency / period_gyro, 1);
+		st->fifo.watermark.eff_accel = max(latency / period_accel, 1);
 	}
 
 	/* compute watermark value in bytes */

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 4/4] iio: imu: inv_icm42600: do not read FIFO count for watermark it
  2026-08-24 12:30 [PATCH v2 0/4] inv_icm42600 driver enhancements Jean-Baptiste Maneyrol via B4 Relay
                   ` (2 preceding siblings ...)
  2026-08-24 12:30 ` [PATCH v2 3/4] iio: imu: inv_icm42600: simplify watermark computation by using GCD Jean-Baptiste Maneyrol via B4 Relay
@ 2026-08-24 12:30 ` Jean-Baptiste Maneyrol via B4 Relay
  2026-08-31  1:27 ` [PATCH v2 0/4] inv_icm42600 driver enhancements Jonathan Cameron
  4 siblings, 0 replies; 6+ messages in thread
From: Jean-Baptiste Maneyrol via B4 Relay @ 2026-08-24 12:30 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
  Cc: linux-iio, linux-kernel, Jean-Baptiste Maneyrol,
	Jean-Baptiste Maneyrol, Jonathan Cameron

From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

Optimize data reading for high frequencies by not reading FIFO
count in case of watermark interrupt.

We cannot already read more than watermark samples because of the
timestamping mechanism. It is required to not perturb the timing
between the watermark interrupts. Since we also know there is at
least watermark samples in the FIFO, let's just read these watermark
FIFO samples directly without reading FIFO count in this case.

Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
---
 drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c | 33 ++++++++++------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
index b1a43ca610c4..ded45dfe46a2 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
@@ -477,24 +477,21 @@ 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 (watermark for max = 0 interrupt case) */
-	if (max == 0)
-		max = st->fifo.watermark.value;
-	max_count = max * INV_ICM42600_FIFO_2SENSORS_PACKET_SIZE;
-
-	/* read FIFO count value */
-	raw_fifo_count = (__be16 *)st->buffer;
-	ret = regmap_bulk_read(st->map, INV_ICM42600_REG_FIFO_COUNT,
-			       raw_fifo_count, sizeof(*raw_fifo_count));
-	if (ret)
-		return ret;
-	st->fifo.count = be16_to_cpup(raw_fifo_count);
-
-	/* check and clamp FIFO count value */
-	if (st->fifo.count == 0)
-		return 0;
-	if (st->fifo.count > max_count)
-		st->fifo.count = max_count;
+	/* read watermark samples for interrupt case (max = 0) or read FIFO count */
+	if (max == 0) {
+		st->fifo.count = st->fifo.watermark.value *
+				 INV_ICM42600_FIFO_2SENSORS_PACKET_SIZE;
+	} else {
+		raw_fifo_count = (__be16 *)st->buffer;
+		ret = regmap_bulk_read(st->map, INV_ICM42600_REG_FIFO_COUNT,
+					raw_fifo_count, sizeof(*raw_fifo_count));
+		if (ret)
+			return ret;
+		max_count = max * INV_ICM42600_FIFO_2SENSORS_PACKET_SIZE;
+		st->fifo.count = min(be16_to_cpup(raw_fifo_count), max_count);
+		if (st->fifo.count == 0)
+			return 0;
+	}
 
 	/* read all FIFO data in internal buffer */
 	ret = regmap_noinc_read(st->map, INV_ICM42600_REG_FIFO_DATA,

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/4] inv_icm42600 driver enhancements
  2026-08-24 12:30 [PATCH v2 0/4] inv_icm42600 driver enhancements Jean-Baptiste Maneyrol via B4 Relay
                   ` (3 preceding siblings ...)
  2026-08-24 12:30 ` [PATCH v2 4/4] iio: imu: inv_icm42600: do not read FIFO count for watermark it Jean-Baptiste Maneyrol via B4 Relay
@ 2026-08-31  1:27 ` Jonathan Cameron
  4 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2026-08-31  1:27 UTC (permalink / raw)
  To: Jean-Baptiste Maneyrol via B4 Relay
  Cc: jean-baptiste.maneyrol, David Lechner, Nuno Sá,
	Andy Shevchenko, linux-iio, linux-kernel, Jean-Baptiste Maneyrol

On Mon, 24 Aug 2026 14:30:06 +0200
Jean-Baptiste Maneyrol via B4 Relay <devnull+jean-baptiste.maneyrol.tdk.com@kernel.org> wrote:

> This series add enhancements patches to inv_icm42600 driver.
> 
> It includes:
> 1. Move of MEMS stabilization sleep before FIFO configuration to avoid
>    pushing incorrect data.
> 2. Use a fixed FIFO frame of 16 bits to avoid a bug of dynamic FIFO
>    configuration changed triggered by the sleep move.
> 3. Simplify watermark computation using gcd.
> 4. Enhance support of high frequency streaming by avoiding read of FIFO
>    count for watermark interrupt.
> 
> Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Whilst sashiko did have quite a lot to say I 'think' they are all fine.
However, please do take a look and if you disagree then shout.

https://sashiko.dev/#/patchset/20260824-inv-icm42600-enhacements-v2-0-0040837fde12%40tdk.com

It may well be there are things in there that should be patches on top anyway.
I think all but 1 were things it even thought were preexisting issues.

Anyhow applied to the testing branch of iio.git which i just rebased
on rc1.

Thanks,

Jonathan


> ---
> Changes in v2:
> - Add commentaries for easing understanding of changes.
> - Reword commit messages with better explanations.
> - Link to v1: https://patch.msgid.link/20260820-inv-icm42600-enhacements-v1-0-075a881db557@tdk.com
> 
> To: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
> To: Jonathan Cameron <jic23@kernel.org>
> To: David Lechner <dlechner@baylibre.com>
> To: Nuno Sá <nuno.sa@analog.com>
> To: Andy Shevchenko <andy@kernel.org>
> Cc: linux-iio@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> 
> ---
> Jean-Baptiste Maneyrol (4):
>       iio: imu: inv_icm42600: sleep before enabling FIFO data
>       iio: imu: inv_icm42600: use 2 sensors fixed packet size of 16 bytes
>       iio: imu: inv_icm42600: simplify watermark computation by using GCD
>       iio: imu: inv_icm42600: do not read FIFO count for watermark it
> 
>  drivers/iio/imu/inv_icm42600/inv_icm42600.h        |   4 +-
>  drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c  |  16 ++-
>  drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c | 112 +++++++++------------
>  drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c   |  16 ++-
>  4 files changed, 73 insertions(+), 75 deletions(-)
> ---
> base-commit: 53c022f51fbe540fffee2121ce9ed3e15266c9a4
> change-id: 20260709-inv-icm42600-enhacements-1e0e18e6f868
> 
> Best regards,
> --  
> Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
> 
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-08-31  1:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-24 12:30 [PATCH v2 0/4] inv_icm42600 driver enhancements Jean-Baptiste Maneyrol via B4 Relay
2026-08-24 12:30 ` [PATCH v2 1/4] iio: imu: inv_icm42600: sleep before enabling FIFO data Jean-Baptiste Maneyrol via B4 Relay
2026-08-24 12:30 ` [PATCH v2 2/4] iio: imu: inv_icm42600: use 2 sensors fixed packet size of 16 bytes Jean-Baptiste Maneyrol via B4 Relay
2026-08-24 12:30 ` [PATCH v2 3/4] iio: imu: inv_icm42600: simplify watermark computation by using GCD Jean-Baptiste Maneyrol via B4 Relay
2026-08-24 12:30 ` [PATCH v2 4/4] iio: imu: inv_icm42600: do not read FIFO count for watermark it Jean-Baptiste Maneyrol via B4 Relay
2026-08-31  1:27 ` [PATCH v2 0/4] inv_icm42600 driver enhancements Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox