* [PATCH v2] iio: imu: st_lsm6dsx: set 10ms as min shub slave timeout
@ 2020-11-01 16:21 Lorenzo Bianconi
2020-11-01 20:56 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Lorenzo Bianconi @ 2020-11-01 16:21 UTC (permalink / raw)
To: jic23; +Cc: lorenzo.bianconi, linux-iio
Set 10ms as minimum i2c slave configuration timeout since st_lsm6dsx
relies on accel ODR for i2c master clock and at high sample rates
(e.g. 833Hz or 416Hz) the slave sensor occasionally may need more cycles
than i2c master timeout (2s/833Hz + 1 ~ 3ms) to apply the configuration
resulting in an uncomplete slave configuration and a constant reading
from the i2c slave connected to st_lsm6dsx i2c master.
Fixes: 8f9a5249e3d9 ("iio: imu: st_lsm6dsx: enable 833Hz sample frequency for tagged sensors")
Fixes: c91c1c844ebd ("iio: imu: st_lsm6dsx: add i2c embedded controller support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
Changes since v1:
- improve commit log
- add missing Fixes tags
---
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
index 8c8d8870ca07..99562ba85ee4 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
@@ -156,11 +156,13 @@ static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = {
static void st_lsm6dsx_shub_wait_complete(struct st_lsm6dsx_hw *hw)
{
struct st_lsm6dsx_sensor *sensor;
- u32 odr;
+ u32 odr, timeout;
sensor = iio_priv(hw->iio_devs[ST_LSM6DSX_ID_ACC]);
odr = (hw->enable_mask & BIT(ST_LSM6DSX_ID_ACC)) ? sensor->odr : 12500;
- msleep((2000000U / odr) + 1);
+ /* set 10ms as minimum timeout for i2c slave configuration */
+ timeout = max_t(u32, 2000000U / odr + 1, 10);
+ msleep(timeout);
}
/*
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] iio: imu: st_lsm6dsx: set 10ms as min shub slave timeout
2020-11-01 16:21 [PATCH v2] iio: imu: st_lsm6dsx: set 10ms as min shub slave timeout Lorenzo Bianconi
@ 2020-11-01 20:56 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2020-11-01 20:56 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: lorenzo.bianconi, linux-iio
On Sun, 1 Nov 2020 17:21:18 +0100
Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> Set 10ms as minimum i2c slave configuration timeout since st_lsm6dsx
> relies on accel ODR for i2c master clock and at high sample rates
> (e.g. 833Hz or 416Hz) the slave sensor occasionally may need more cycles
> than i2c master timeout (2s/833Hz + 1 ~ 3ms) to apply the configuration
> resulting in an uncomplete slave configuration and a constant reading
> from the i2c slave connected to st_lsm6dsx i2c master.
>
> Fixes: 8f9a5249e3d9 ("iio: imu: st_lsm6dsx: enable 833Hz sample frequency for tagged sensors")
> Fixes: c91c1c844ebd ("iio: imu: st_lsm6dsx: add i2c embedded controller support")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Applied and marked for stable.
Thanks,
Jonathan
> ---
> Changes since v1:
> - improve commit log
> - add missing Fixes tags
> ---
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> index 8c8d8870ca07..99562ba85ee4 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> @@ -156,11 +156,13 @@ static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = {
> static void st_lsm6dsx_shub_wait_complete(struct st_lsm6dsx_hw *hw)
> {
> struct st_lsm6dsx_sensor *sensor;
> - u32 odr;
> + u32 odr, timeout;
>
> sensor = iio_priv(hw->iio_devs[ST_LSM6DSX_ID_ACC]);
> odr = (hw->enable_mask & BIT(ST_LSM6DSX_ID_ACC)) ? sensor->odr : 12500;
> - msleep((2000000U / odr) + 1);
> + /* set 10ms as minimum timeout for i2c slave configuration */
> + timeout = max_t(u32, 2000000U / odr + 1, 10);
> + msleep(timeout);
> }
>
> /*
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-01 20:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-01 16:21 [PATCH v2] iio: imu: st_lsm6dsx: set 10ms as min shub slave timeout Lorenzo Bianconi
2020-11-01 20:56 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).