All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: imu: st_lsm6dsx: set 10ms as min shub slave timeout
@ 2020-10-21 21:53 Lorenzo Bianconi
  2020-11-01 15:43 ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Lorenzo Bianconi @ 2020-10-21 21:53 UTC (permalink / raw)
  To: jic23; +Cc: lorenzo.bianconi, linux-iio

Set 10ms as minimum i2c slave configuration timeout since at high ODRs
(e.g. 833Hz) the slave sensor may need more cycles than ~3ms
(2s/833Hz + 1) for the configuration

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 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] 3+ messages in thread

* Re: [PATCH] iio: imu: st_lsm6dsx: set 10ms as min shub slave timeout
  2020-10-21 21:53 [PATCH] iio: imu: st_lsm6dsx: set 10ms as min shub slave timeout Lorenzo Bianconi
@ 2020-11-01 15:43 ` Jonathan Cameron
  2020-11-01 15:53   ` Lorenzo Bianconi
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2020-11-01 15:43 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: lorenzo.bianconi, linux-iio

On Wed, 21 Oct 2020 23:53:54 +0200
Lorenzo Bianconi <lorenzo@kernel.org> wrote:

> Set 10ms as minimum i2c slave configuration timeout since at high ODRs
> (e.g. 833Hz) the slave sensor may need more cycles than ~3ms
> (2s/833Hz + 1) for the configuration
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

Hi Lorenzo,

This sounds like a fix to me.  Could you give a bit more detail on what
setup it fails for and a fixes tag so we can get this into appropriate
stable trees?

Thanks,

Jonathan

> ---
>  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] 3+ messages in thread

* Re: [PATCH] iio: imu: st_lsm6dsx: set 10ms as min shub slave timeout
  2020-11-01 15:43 ` Jonathan Cameron
@ 2020-11-01 15:53   ` Lorenzo Bianconi
  0 siblings, 0 replies; 3+ messages in thread
From: Lorenzo Bianconi @ 2020-11-01 15:53 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: Lorenzo Bianconi, linux-iio

[-- Attachment #1: Type: text/plain, Size: 1674 bytes --]

On Nov 01, Jonathan Cameron wrote:
> On Wed, 21 Oct 2020 23:53:54 +0200
> Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> 
> > Set 10ms as minimum i2c slave configuration timeout since at high ODRs
> > (e.g. 833Hz) the slave sensor may need more cycles than ~3ms
> > (2s/833Hz + 1) for the configuration
> > 
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> 
> Hi Lorenzo,
> 
> This sounds like a fix to me.  Could you give a bit more detail on what
> setup it fails for and a fixes tag so we can get this into appropriate
> stable trees?

ack, I will post v2 soon.

Regards,
Lorenzo

> 
> Thanks,
> 
> Jonathan
> 
> > ---
> >  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);
> >  }
> >  
> >  /*
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

end of thread, other threads:[~2020-11-01 15:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-21 21:53 [PATCH] iio: imu: st_lsm6dsx: set 10ms as min shub slave timeout Lorenzo Bianconi
2020-11-01 15:43 ` Jonathan Cameron
2020-11-01 15:53   ` Lorenzo Bianconi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.