[PATCH 19/21] iio: Use IRQF_NO_THREAD

Sebastian Andrzej Siewior posted 21 patches 2 weeks, 3 days ago
There is a newer version of this series
[PATCH 19/21] iio: Use IRQF_NO_THREAD
Posted by Sebastian Andrzej Siewior 2 weeks, 3 days ago
The interrupt handler iio_trigger_generic_data_rdy_poll() will invoke
other interrupt handler and this supposed to happen from within the
hardirq.

Use IRQF_NO_THREAD to forbid forced-threading.

Cc: Jonathan Cameron <jic23@kernel.org>
Cc: David Lechner <dlechner@baylibre.com>
Cc: "Nuno Sá" <nuno.sa@analog.com>
Cc: Andy Shevchenko <andy@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Cc: linux-iio@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/iio/accel/bma180.c        |  5 +++--
 drivers/iio/adc/ad7766.c          | 10 ++--------
 drivers/iio/gyro/itg3200_buffer.c |  2 +-
 drivers/iio/light/si1145.c        |  2 +-
 4 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
index 8925f5279e627..7bc6761f51354 100644
--- a/drivers/iio/accel/bma180.c
+++ b/drivers/iio/accel/bma180.c
@@ -986,8 +986,9 @@ static int bma180_probe(struct i2c_client *client)
 		}
 
 		ret = devm_request_irq(dev, client->irq,
-			iio_trigger_generic_data_rdy_poll, IRQF_TRIGGER_RISING,
-			"bma180_event", data->trig);
+				       iio_trigger_generic_data_rdy_poll,
+				       IRQF_TRIGGER_RISING | IRQF_NO_THREAD,
+				       "bma180_event", data->trig);
 		if (ret) {
 			dev_err(dev, "unable to request IRQ\n");
 			goto err_trigger_free;
diff --git a/drivers/iio/adc/ad7766.c b/drivers/iio/adc/ad7766.c
index 4d570383ef025..9e4a66477d2d0 100644
--- a/drivers/iio/adc/ad7766.c
+++ b/drivers/iio/adc/ad7766.c
@@ -184,12 +184,6 @@ static const struct iio_info ad7766_info = {
 	.read_raw = &ad7766_read_raw,
 };
 
-static irqreturn_t ad7766_irq(int irq, void *private)
-{
-	iio_trigger_poll(private);
-	return IRQ_HANDLED;
-}
-
 static int ad7766_set_trigger_state(struct iio_trigger *trig, bool enable)
 {
 	struct ad7766 *ad7766 = iio_trigger_get_drvdata(trig);
@@ -260,8 +254,8 @@ static int ad7766_probe(struct spi_device *spi)
 		 * Some platforms might not allow the option to power it down so
 		 * don't enable the interrupt to avoid extra load on the system
 		 */
-		ret = devm_request_irq(&spi->dev, spi->irq, ad7766_irq,
-				       IRQF_TRIGGER_FALLING | IRQF_NO_AUTOEN,
+		ret = devm_request_irq(&spi->dev, spi->irq, iio_trigger_generic_data_rdy_poll,
+				       IRQF_TRIGGER_FALLING | IRQF_NO_AUTOEN | IRQF_NO_THREAD,
 				       dev_name(&spi->dev),
 				       ad7766->trig);
 		if (ret < 0)
diff --git a/drivers/iio/gyro/itg3200_buffer.c b/drivers/iio/gyro/itg3200_buffer.c
index a624400a239cb..767b87b7feea7 100644
--- a/drivers/iio/gyro/itg3200_buffer.c
+++ b/drivers/iio/gyro/itg3200_buffer.c
@@ -120,7 +120,7 @@ int itg3200_probe_trigger(struct iio_dev *indio_dev)
 
 	ret = request_irq(st->i2c->irq,
 			  &iio_trigger_generic_data_rdy_poll,
-			  IRQF_TRIGGER_RISING,
+			  IRQF_NO_THREAD | IRQF_TRIGGER_RISING,
 			  "itg3200_data_rdy",
 			  st->trig);
 	if (ret)
diff --git a/drivers/iio/light/si1145.c b/drivers/iio/light/si1145.c
index f8eb251eca8dc..ef0abc4499b74 100644
--- a/drivers/iio/light/si1145.c
+++ b/drivers/iio/light/si1145.c
@@ -1248,7 +1248,7 @@ static int si1145_probe_trigger(struct iio_dev *indio_dev)
 
 	ret = devm_request_irq(&client->dev, client->irq,
 			  iio_trigger_generic_data_rdy_poll,
-			  IRQF_TRIGGER_FALLING,
+			  IRQF_TRIGGER_FALLING | IRQF_NO_THREAD,
 			  "si1145_irq",
 			  trig);
 	if (ret < 0) {
-- 
2.51.0
Re: [PATCH 19/21] iio: Use IRQF_NO_THREAD
Posted by David Lechner 2 weeks, 2 days ago
On 1/23/26 5:37 AM, Sebastian Andrzej Siewior wrote:
> The interrupt handler iio_trigger_generic_data_rdy_poll() will invoke
> other interrupt handler and this supposed to happen from within the
> hardirq.
> 
> Use IRQF_NO_THREAD to forbid forced-threading.
> 

...

> diff --git a/drivers/iio/adc/ad7766.c b/drivers/iio/adc/ad7766.c
> index 4d570383ef025..9e4a66477d2d0 100644
> --- a/drivers/iio/adc/ad7766.c
> +++ b/drivers/iio/adc/ad7766.c
> @@ -184,12 +184,6 @@ static const struct iio_info ad7766_info = {
>  	.read_raw = &ad7766_read_raw,
>  };
>  
> -static irqreturn_t ad7766_irq(int irq, void *private)
> -{
> -	iio_trigger_poll(private);
> -	return IRQ_HANDLED;
> -}
> -

Replacing this with iio_trigger_generic_data_rdy_poll() seems like a
separate improvement that should be in a separate patch.

At a minimum, the commit message should explain this change. But I expect
the reason will make it obvious it should be a separate patch.

>  static int ad7766_set_trigger_state(struct iio_trigger *trig, bool enable)
>  {
>  	struct ad7766 *ad7766 = iio_trigger_get_drvdata(trig);
> @@ -260,8 +254,8 @@ static int ad7766_probe(struct spi_device *spi)
>  		 * Some platforms might not allow the option to power it down so
>  		 * don't enable the interrupt to avoid extra load on the system
>  		 */
> -		ret = devm_request_irq(&spi->dev, spi->irq, ad7766_irq,
> -				       IRQF_TRIGGER_FALLING | IRQF_NO_AUTOEN,
> +		ret = devm_request_irq(&spi->dev, spi->irq, iio_trigger_generic_data_rdy_poll,
> +				       IRQF_TRIGGER_FALLING | IRQF_NO_AUTOEN | IRQF_NO_THREAD,
>  				       dev_name(&spi->dev),
>  				       ad7766->trig);
>  		if (ret < 0)
Re: [PATCH 19/21] iio: Use IRQF_NO_THREAD
Posted by Sebastian Andrzej Siewior 2 weeks ago
On 2026-01-23 14:56:32 [-0600], David Lechner wrote:
> > -static irqreturn_t ad7766_irq(int irq, void *private)
> > -{
> > -	iio_trigger_poll(private);
> > -	return IRQ_HANDLED;
> > -}
> > -
> 
> Replacing this with iio_trigger_generic_data_rdy_poll() seems like a
> separate improvement that should be in a separate patch.
> 
> At a minimum, the commit message should explain this change. But I expect
> the reason will make it obvious it should be a separate patch.

The other use iio_trigger_generic_data_rdy_poll() as the handler except
this one. Which uses a wrapper around it. It looked to easier to add
this hunk.
What do you want (split or keep)?

> >  static int ad7766_set_trigger_state(struct iio_trigger *trig, bool enable)
> >  {
> >  	struct ad7766 *ad7766 = iio_trigger_get_drvdata(trig);
> > @@ -260,8 +254,8 @@ static int ad7766_probe(struct spi_device *spi)
> >  		 * Some platforms might not allow the option to power it down so
> >  		 * don't enable the interrupt to avoid extra load on the system
> >  		 */
> > -		ret = devm_request_irq(&spi->dev, spi->irq, ad7766_irq,
> > -				       IRQF_TRIGGER_FALLING | IRQF_NO_AUTOEN,
> > +		ret = devm_request_irq(&spi->dev, spi->irq, iio_trigger_generic_data_rdy_poll,
> > +				       IRQF_TRIGGER_FALLING | IRQF_NO_AUTOEN | IRQF_NO_THREAD,
> >  				       dev_name(&spi->dev),
> >  				       ad7766->trig);
> >  		if (ret < 0)

Sebastian
Re: [PATCH 19/21] iio: Use IRQF_NO_THREAD
Posted by David Lechner 1 week, 6 days ago
On 1/26/26 2:09 AM, Sebastian Andrzej Siewior wrote:
> On 2026-01-23 14:56:32 [-0600], David Lechner wrote:
>>> -static irqreturn_t ad7766_irq(int irq, void *private)
>>> -{
>>> -	iio_trigger_poll(private);
>>> -	return IRQ_HANDLED;
>>> -}
>>> -
>>
>> Replacing this with iio_trigger_generic_data_rdy_poll() seems like a
>> separate improvement that should be in a separate patch.
>>
>> At a minimum, the commit message should explain this change. But I expect
>> the reason will make it obvious it should be a separate patch.
> 
> The other use iio_trigger_generic_data_rdy_poll() as the handler except
> this one. Which uses a wrapper around it. It looked to easier to add
> this hunk.
> What do you want (split or keep)?
> 
I would still expect a separate patch to replace the duplicate
function with iio_trigger_generic_data_rdy_poll(). That change
stands on it's own, so deserves a separate patch.
Re: [PATCH 19/21] iio: Use IRQF_NO_THREAD
Posted by Andy Shevchenko 2 weeks, 2 days ago
On Fri, Jan 23, 2026 at 12:37:05PM +0100, Sebastian Andrzej Siewior wrote:
> The interrupt handler iio_trigger_generic_data_rdy_poll() will invoke
> other interrupt handler and this supposed to happen from within the
> hardirq.
> 
> Use IRQF_NO_THREAD to forbid forced-threading.

...

> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: David Lechner <dlechner@baylibre.com>
> Cc: "Nuno Sá" <nuno.sa@analog.com>
> Cc: Andy Shevchenko <andy@kernel.org>
> Cc: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Michael Hennerich <Michael.Hennerich@analog.com>
> Cc: linux-iio@vger.kernel.org

Same comment about Cc list.

...

>  	ret = request_irq(st->i2c->irq,
>  			  &iio_trigger_generic_data_rdy_poll,
> -			  IRQF_TRIGGER_RISING,
> +			  IRQF_NO_THREAD | IRQF_TRIGGER_RISING,

Maybe swap their positions as it's done everywhere else for the consistency's
sake?

>  			  "itg3200_data_rdy",
>  			  st->trig);

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH 19/21] iio: Use IRQF_NO_THREAD
Posted by Sebastian Andrzej Siewior 2 weeks ago
On 2026-01-23 16:50:58 [+0200], Andy Shevchenko wrote:
> >  	ret = request_irq(st->i2c->irq,
> >  			  &iio_trigger_generic_data_rdy_poll,
> > -			  IRQF_TRIGGER_RISING,
> > +			  IRQF_NO_THREAD | IRQF_TRIGGER_RISING,
> 
> Maybe swap their positions as it's done everywhere else for the consistency's
> sake?

Almost missed this. I swapped the flags, re-ident-ed.
Also updated the commit message that ad7766_irq() is identical to
iio_trigger_generic_data_rdy_poll() and can be replaced. Hope that works
for everyone.

> >  			  "itg3200_data_rdy",
> >  			  st->trig);

Sebastian