public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: imu: inv_mpu6050: fix interrupt status read for old buggy chips
@ 2024-08-14 14:37 inv.git-commit
  2024-08-14 15:50 ` Svyatoslav Ryhel
  0 siblings, 1 reply; 3+ messages in thread
From: inv.git-commit @ 2024-08-14 14:37 UTC (permalink / raw)
  To: jic23; +Cc: lars, linux-iio, stable, Jean-Baptiste Maneyrol

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

Interrupt status read seems to be broken on some old MPU-6050 like
chips. Fix by reverting to previous driver behavior bypassing interrupt
status read. This is working because these chips are not supporting
WoM and data ready is the only interrupt source.

Fixes: 5537f653d9be ("iio: imu: inv_mpu6050: add new interrupt handler for WoM events")
Cc: stable@vger.kernel.org
Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
---
 drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
index 84273660ca2e..3bfeabab0ec4 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
@@ -248,12 +248,20 @@ static irqreturn_t inv_mpu6050_interrupt_handle(int irq, void *p)
 	int result;

 	switch (st->chip_type) {
+	case INV_MPU6000:
 	case INV_MPU6050:
+	case INV_MPU9150:
+		/*
+		 * WoM is not supported and interrupt status read seems to be broken for
+		 * some chips. Since data ready is the only interrupt, bypass interrupt
+		 * status read and always assert data ready bit.
+		 */
+		wom_bits = 0;
+		int_status = INV_MPU6050_BIT_RAW_DATA_RDY_INT;
+		goto data_ready_interrupt;
 	case INV_MPU6500:
 	case INV_MPU6515:
 	case INV_MPU6880:
-	case INV_MPU6000:
-	case INV_MPU9150:
 	case INV_MPU9250:
 	case INV_MPU9255:
 		wom_bits = INV_MPU6500_BIT_WOM_INT;
@@ -279,6 +287,7 @@ static irqreturn_t inv_mpu6050_interrupt_handle(int irq, void *p)
 		}
 	}

+data_ready_interrupt:
 	/* handle raw data interrupt */
 	if (int_status & INV_MPU6050_BIT_RAW_DATA_RDY_INT) {
 		indio_dev->pollfunc->timestamp = st->it_timestamp;
--
2.34.1


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

* Re: [PATCH] iio: imu: inv_mpu6050: fix interrupt status read for old buggy chips
  2024-08-14 14:37 [PATCH] iio: imu: inv_mpu6050: fix interrupt status read for old buggy chips inv.git-commit
@ 2024-08-14 15:50 ` Svyatoslav Ryhel
  2024-08-17 14:32   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Svyatoslav Ryhel @ 2024-08-14 15:50 UTC (permalink / raw)
  To: inv.git-commit, jic23; +Cc: lars, linux-iio, stable, Jean-Baptiste Maneyrol

14.08.24 5:37 пп, inv.git-commit@tdk.com:
> From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
>
> Interrupt status read seems to be broken on some old MPU-6050 like
> chips. Fix by reverting to previous driver behavior bypassing interrupt
> status read. This is working because these chips are not supporting
> WoM and data ready is the only interrupt source.
>
> Fixes: 5537f653d9be ("iio: imu: inv_mpu6050: add new interrupt handler for WoM events")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # LG P880

Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895

> ---
>   drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 13 +++++++++++--
>   1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
> index 84273660ca2e..3bfeabab0ec4 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
> @@ -248,12 +248,20 @@ static irqreturn_t inv_mpu6050_interrupt_handle(int irq, void *p)
>   	int result;
>
>   	switch (st->chip_type) {
> +	case INV_MPU6000:
>   	case INV_MPU6050:
> +	case INV_MPU9150:
> +		/*
> +		 * WoM is not supported and interrupt status read seems to be broken for
> +		 * some chips. Since data ready is the only interrupt, bypass interrupt
> +		 * status read and always assert data ready bit.
> +		 */
> +		wom_bits = 0;
> +		int_status = INV_MPU6050_BIT_RAW_DATA_RDY_INT;
> +		goto data_ready_interrupt;
>   	case INV_MPU6500:
>   	case INV_MPU6515:
>   	case INV_MPU6880:
> -	case INV_MPU6000:
> -	case INV_MPU9150:
>   	case INV_MPU9250:
>   	case INV_MPU9255:
>   		wom_bits = INV_MPU6500_BIT_WOM_INT;
> @@ -279,6 +287,7 @@ static irqreturn_t inv_mpu6050_interrupt_handle(int irq, void *p)
>   		}
>   	}
>
> +data_ready_interrupt:
>   	/* handle raw data interrupt */
>   	if (int_status & INV_MPU6050_BIT_RAW_DATA_RDY_INT) {
>   		indio_dev->pollfunc->timestamp = st->it_timestamp;
> --
> 2.34.1
>

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

* Re: [PATCH] iio: imu: inv_mpu6050: fix interrupt status read for old buggy chips
  2024-08-14 15:50 ` Svyatoslav Ryhel
@ 2024-08-17 14:32   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2024-08-17 14:32 UTC (permalink / raw)
  To: Svyatoslav Ryhel
  Cc: inv.git-commit, lars, linux-iio, stable, Jean-Baptiste Maneyrol

On Wed, 14 Aug 2024 18:50:43 +0300
Svyatoslav Ryhel <clamor95@gmail.com> wrote:

> 14.08.24 5:37 пп, inv.git-commit@tdk.com:
> > From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
> >
> > Interrupt status read seems to be broken on some old MPU-6050 like
> > chips. Fix by reverting to previous driver behavior bypassing interrupt
> > status read. This is working because these chips are not supporting
> > WoM and data ready is the only interrupt source.
> >
> > Fixes: 5537f653d9be ("iio: imu: inv_mpu6050: add new interrupt handler for WoM events")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>  
> Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # LG P880
> 
> Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895
Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

> 
> > ---
> >   drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 13 +++++++++++--
> >   1 file changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
> > index 84273660ca2e..3bfeabab0ec4 100644
> > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
> > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
> > @@ -248,12 +248,20 @@ static irqreturn_t inv_mpu6050_interrupt_handle(int irq, void *p)
> >   	int result;
> >
> >   	switch (st->chip_type) {
> > +	case INV_MPU6000:
> >   	case INV_MPU6050:
> > +	case INV_MPU9150:
> > +		/*
> > +		 * WoM is not supported and interrupt status read seems to be broken for
> > +		 * some chips. Since data ready is the only interrupt, bypass interrupt
> > +		 * status read and always assert data ready bit.
> > +		 */
> > +		wom_bits = 0;
> > +		int_status = INV_MPU6050_BIT_RAW_DATA_RDY_INT;
> > +		goto data_ready_interrupt;
> >   	case INV_MPU6500:
> >   	case INV_MPU6515:
> >   	case INV_MPU6880:
> > -	case INV_MPU6000:
> > -	case INV_MPU9150:
> >   	case INV_MPU9250:
> >   	case INV_MPU9255:
> >   		wom_bits = INV_MPU6500_BIT_WOM_INT;
> > @@ -279,6 +287,7 @@ static irqreturn_t inv_mpu6050_interrupt_handle(int irq, void *p)
> >   		}
> >   	}
> >
> > +data_ready_interrupt:
> >   	/* handle raw data interrupt */
> >   	if (int_status & INV_MPU6050_BIT_RAW_DATA_RDY_INT) {
> >   		indio_dev->pollfunc->timestamp = st->it_timestamp;
> > --
> > 2.34.1
> >  


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

end of thread, other threads:[~2024-08-17 14:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-14 14:37 [PATCH] iio: imu: inv_mpu6050: fix interrupt status read for old buggy chips inv.git-commit
2024-08-14 15:50 ` Svyatoslav Ryhel
2024-08-17 14:32   ` Jonathan Cameron

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