Skip to contentSkip to conversation

iio: imu: st_lsm6dsx: Update enable mask when using sensor fusion

PATCH In review Francesco Lavra 3 participants 3 messages Jul 31 – Aug 2

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: imu: st_lsm6dsx: Update enable mask when using sensor fusion

The enable_mask struct member keeps track of which sensors are enabled in the IMU. When enabling and disabling the sensor fusion functionality, the driver does not properly update this struct member. This prevents a correct calculation of the number of samples that should be read from the hardware FIFO; as a result, reads from the FIFO can be unnecessarily split into multiple transactions, some of which can read past the FIFO length.

Fixes cd4e1141bff8 ("iio: imu: st_lsm6dsx: Add support for rotation sensor")
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_fusion.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_fusion.c +5 -0
index 2e72c7ba94dd..5321033daebc 100644
@@ -112,6 +112,11 @@ int st_lsm6dsx_fusion_set_enable(struct st_lsm6dsx_sensor *sensor, bool enable)
 		return err;
 	}
 
+	if (enable)
+		hw->enable_mask |= BIT(ST_LSM6DSX_ID_FUSION);
+	else
+		hw->enable_mask &= ~BIT(ST_LSM6DSX_ID_FUSION);
+
 	return st_lsm6dsx_fusion_page_disable(hw);
 }
 
Signature · 1 line
2.39.5
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines

The enable_mask struct member keeps track of which sensors are enabled in the IMU. When enabling and disabling the sensor fusion functionality, the driver does not properly update this struct member. This prevents a correct calculation of the number of samples that should be read from the hardware FIFO; as a result, reads from the FIFO can be unnecessarily split into multiple transactions, some of which can read past the FIFO length.

Quoted 26 lines
Fixes cd4e1141bff8 ("iio: imu: st_lsm6dsx: Add support for rotation sensor")
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_fusion.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_fusion.c +5 -0
index 2e72c7ba94dd..5321033daebc 100644
@@ -112,6 +112,11 @@ int st_lsm6dsx_fusion_set_enable(struct st_lsm6dsx_sensor *sensor, bool enable)
 		return err;
 	}
 
+	if (enable)
+		hw->enable_mask |= BIT(ST_LSM6DSX_ID_FUSION);
+	else
+		hw->enable_mask &= ~BIT(ST_LSM6DSX_ID_FUSION);
+
 	return st_lsm6dsx_fusion_page_disable(hw);
 }
 
Signature · 1 line
2.39.5
maintainer
#2 lore raw
Quoted 10 lines · On Fri, 31 Jul 2026 22:44:44 +0200 Lorenzo Bianconi <[email protected]> wrote:
Quoted 6 lines

The enable_mask struct member keeps track of which sensors are enabled in the IMU. When enabling and disabling the sensor fusion functionality, the driver does not properly update this struct member. This prevents a correct calculation of the number of samples that should be read from the hardware FIFO; as a result, reads from the FIFO can be unnecessarily split into multiple transactions, some of which can read past the FIFO length.

Quoted 1 line

Applied to the testing branch of iio.git and marked for stable.

Going the slow way because Linus has requested only breakage from current cycle or critical fixes take the fast path. So this will take a few weeks to make it into stable trees.

Thanks

Jonathan

Quoted 25 lines
Quoted 25 lines
Fixes cd4e1141bff8 ("iio: imu: st_lsm6dsx: Add support for rotation sensor")
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_fusion.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_fusion.c +5 -0
index 2e72c7ba94dd..5321033daebc 100644
@@ -112,6 +112,11 @@ int st_lsm6dsx_fusion_set_enable(struct st_lsm6dsx_sensor *sensor, bool enable)
 		return err;
 	}
 
+	if (enable)
+		hw->enable_mask |= BIT(ST_LSM6DSX_ID_FUSION);
+	else
+		hw->enable_mask &= ~BIT(ST_LSM6DSX_ID_FUSION);
+
 	return st_lsm6dsx_fusion_page_disable(hw);
 }
 
Signature · 1 line
2.39.5