Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: adc: ad7380: disable offload before using SPI bus
@ 2025-03-20 16:21 David Lechner
  2025-03-21  8:34 ` Nuno Sá
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: David Lechner @ 2025-03-20 16:21 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Michael Hennerich, Nuno Sá, Angelo Dureghello,
	Jonathan Cameron, linux-kernel, David Lechner

Move disabling of the SPI offload before attempting to use the SPI bus
to write a register in ad7380_offload_buffer_predisable().

This caused a crash in the spi_engine_irq() interrupt handler due to
being in an invalid state.

Fixes: bbeaec81a03e ("iio: ad7380: add support for SPI offload")
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
 drivers/iio/adc/ad7380.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c
index 4fcb49fdf56639784098f0147a9faef8dcb6b0f6..a2b41980c942e4cd1575bfe4f3846e297ad5d01d 100644
--- a/drivers/iio/adc/ad7380.c
+++ b/drivers/iio/adc/ad7380.c
@@ -1211,6 +1211,9 @@ static int ad7380_offload_buffer_predisable(struct iio_dev *indio_dev)
 	struct ad7380_state *st = iio_priv(indio_dev);
 	int ret;
 
+	spi_offload_trigger_disable(st->offload, st->offload_trigger);
+	spi_unoptimize_message(&st->offload_msg);
+
 	if (st->seq) {
 		ret = regmap_update_bits(st->regmap,
 					 AD7380_REG_ADDR_CONFIG1,
@@ -1222,10 +1225,6 @@ static int ad7380_offload_buffer_predisable(struct iio_dev *indio_dev)
 		st->seq = false;
 	}
 
-	spi_offload_trigger_disable(st->offload, st->offload_trigger);
-
-	spi_unoptimize_message(&st->offload_msg);
-
 	return 0;
 }
 

---
base-commit: 9f36acefb2621d980734a5bb7d74e0e24e0af166
change-id: 20250320-iio-adc-ad7380-fix-spi-offload-buffer-predisable-a801dcfb9c00

Best regards,
-- 
David Lechner <dlechner@baylibre.com>


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

* Re: [PATCH] iio: adc: ad7380: disable offload before using SPI bus
  2025-03-20 16:21 [PATCH] iio: adc: ad7380: disable offload before using SPI bus David Lechner
@ 2025-03-21  8:34 ` Nuno Sá
  2025-03-21 14:17 ` Angelo Dureghello
  2025-03-30 17:04 ` Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Nuno Sá @ 2025-03-21  8:34 UTC (permalink / raw)
  To: David Lechner, Jonathan Cameron, linux-iio
  Cc: Michael Hennerich, Nuno Sá, Angelo Dureghello,
	Jonathan Cameron, linux-kernel

On Thu, 2025-03-20 at 11:21 -0500, David Lechner wrote:
> Move disabling of the SPI offload before attempting to use the SPI bus
> to write a register in ad7380_offload_buffer_predisable().
> 
> This caused a crash in the spi_engine_irq() interrupt handler due to
> being in an invalid state.
> 
> Fixes: bbeaec81a03e ("iio: ad7380: add support for SPI offload")
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---

Reviewed-by: Nuno Sá <nuno.sa@analog.com>

>  drivers/iio/adc/ad7380.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c
> index
> 4fcb49fdf56639784098f0147a9faef8dcb6b0f6..a2b41980c942e4cd1575bfe4f3846e297ad5d01d
> 100644
> --- a/drivers/iio/adc/ad7380.c
> +++ b/drivers/iio/adc/ad7380.c
> @@ -1211,6 +1211,9 @@ static int ad7380_offload_buffer_predisable(struct iio_dev
> *indio_dev)
>  	struct ad7380_state *st = iio_priv(indio_dev);
>  	int ret;
>  
> +	spi_offload_trigger_disable(st->offload, st->offload_trigger);
> +	spi_unoptimize_message(&st->offload_msg);
> +
>  	if (st->seq) {
>  		ret = regmap_update_bits(st->regmap,
>  					 AD7380_REG_ADDR_CONFIG1,
> @@ -1222,10 +1225,6 @@ static int ad7380_offload_buffer_predisable(struct iio_dev
> *indio_dev)
>  		st->seq = false;
>  	}
>  
> -	spi_offload_trigger_disable(st->offload, st->offload_trigger);
> -
> -	spi_unoptimize_message(&st->offload_msg);
> -
>  	return 0;
>  }
>  
> 
> ---
> base-commit: 9f36acefb2621d980734a5bb7d74e0e24e0af166
> change-id: 20250320-iio-adc-ad7380-fix-spi-offload-buffer-predisable-a801dcfb9c00
> 
> Best regards,


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

* Re: [PATCH] iio: adc: ad7380: disable offload before using SPI bus
  2025-03-20 16:21 [PATCH] iio: adc: ad7380: disable offload before using SPI bus David Lechner
  2025-03-21  8:34 ` Nuno Sá
@ 2025-03-21 14:17 ` Angelo Dureghello
  2025-03-30 17:04 ` Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Angelo Dureghello @ 2025-03-21 14:17 UTC (permalink / raw)
  To: David Lechner
  Cc: Jonathan Cameron, linux-iio, Michael Hennerich, Nuno Sá,
	Jonathan Cameron, linux-kernel

On 20.03.2025 11:21, David Lechner wrote:
> Move disabling of the SPI offload before attempting to use the SPI bus
> to write a register in ad7380_offload_buffer_predisable().
> 
> This caused a crash in the spi_engine_irq() interrupt handler due to
> being in an invalid state.
> 
> Fixes: bbeaec81a03e ("iio: ad7380: add support for SPI offload")
> Signed-off-by: David Lechner <dlechner@baylibre.com>

Reviewed-by: Angelo Dureghello <adureghello@baylibre.com>

Thanks.

> ---
>  drivers/iio/adc/ad7380.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c
> index 4fcb49fdf56639784098f0147a9faef8dcb6b0f6..a2b41980c942e4cd1575bfe4f3846e297ad5d01d 100644
> --- a/drivers/iio/adc/ad7380.c
> +++ b/drivers/iio/adc/ad7380.c
> @@ -1211,6 +1211,9 @@ static int ad7380_offload_buffer_predisable(struct iio_dev *indio_dev)
>  	struct ad7380_state *st = iio_priv(indio_dev);
>  	int ret;
>  
> +	spi_offload_trigger_disable(st->offload, st->offload_trigger);
> +	spi_unoptimize_message(&st->offload_msg);
> +
>  	if (st->seq) {
>  		ret = regmap_update_bits(st->regmap,
>  					 AD7380_REG_ADDR_CONFIG1,
> @@ -1222,10 +1225,6 @@ static int ad7380_offload_buffer_predisable(struct iio_dev *indio_dev)
>  		st->seq = false;
>  	}
>  
> -	spi_offload_trigger_disable(st->offload, st->offload_trigger);
> -
> -	spi_unoptimize_message(&st->offload_msg);
> -
>  	return 0;
>  }
>  
> 
> ---
> base-commit: 9f36acefb2621d980734a5bb7d74e0e24e0af166
> change-id: 20250320-iio-adc-ad7380-fix-spi-offload-buffer-predisable-a801dcfb9c00
> 
> Best regards,
> -- 
> David Lechner <dlechner@baylibre.com>
> 

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

* Re: [PATCH] iio: adc: ad7380: disable offload before using SPI bus
  2025-03-20 16:21 [PATCH] iio: adc: ad7380: disable offload before using SPI bus David Lechner
  2025-03-21  8:34 ` Nuno Sá
  2025-03-21 14:17 ` Angelo Dureghello
@ 2025-03-30 17:04 ` Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2025-03-30 17:04 UTC (permalink / raw)
  To: David Lechner
  Cc: linux-iio, Michael Hennerich, Nuno Sá, Angelo Dureghello,
	Jonathan Cameron, linux-kernel

On Thu, 20 Mar 2025 11:21:52 -0500
David Lechner <dlechner@baylibre.com> wrote:

> Move disabling of the SPI offload before attempting to use the SPI bus
> to write a register in ad7380_offload_buffer_predisable().
> 
> This caused a crash in the spi_engine_irq() interrupt handler due to
> being in an invalid state.
> 
> Fixes: bbeaec81a03e ("iio: ad7380: add support for SPI offload")
> Signed-off-by: David Lechner <dlechner@baylibre.com>
Hmm.  I've cheated a bit and created a temporary branch called
fixes-togreg-testing that's based on char-misc-next

That will all unwind once Linus (hopefully) takes Greg's pull request
and I'll rebase on that or rc1.

Anyhow, applied this patch to that magic branch.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/ad7380.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c
> index 4fcb49fdf56639784098f0147a9faef8dcb6b0f6..a2b41980c942e4cd1575bfe4f3846e297ad5d01d 100644
> --- a/drivers/iio/adc/ad7380.c
> +++ b/drivers/iio/adc/ad7380.c
> @@ -1211,6 +1211,9 @@ static int ad7380_offload_buffer_predisable(struct iio_dev *indio_dev)
>  	struct ad7380_state *st = iio_priv(indio_dev);
>  	int ret;
>  
> +	spi_offload_trigger_disable(st->offload, st->offload_trigger);
> +	spi_unoptimize_message(&st->offload_msg);
> +
>  	if (st->seq) {
>  		ret = regmap_update_bits(st->regmap,
>  					 AD7380_REG_ADDR_CONFIG1,
> @@ -1222,10 +1225,6 @@ static int ad7380_offload_buffer_predisable(struct iio_dev *indio_dev)
>  		st->seq = false;
>  	}
>  
> -	spi_offload_trigger_disable(st->offload, st->offload_trigger);
> -
> -	spi_unoptimize_message(&st->offload_msg);
> -
>  	return 0;
>  }
>  
> 
> ---
> base-commit: 9f36acefb2621d980734a5bb7d74e0e24e0af166
> change-id: 20250320-iio-adc-ad7380-fix-spi-offload-buffer-predisable-a801dcfb9c00
> 
> Best regards,


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

end of thread, other threads:[~2025-03-30 17:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-20 16:21 [PATCH] iio: adc: ad7380: disable offload before using SPI bus David Lechner
2025-03-21  8:34 ` Nuno Sá
2025-03-21 14:17 ` Angelo Dureghello
2025-03-30 17:04 ` Jonathan Cameron

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