mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: buffer: only set IRQF_ONESHOT when thread handler is provided
@ 2026-05-14 22:46 Дамјан Гео ргиевски
  2026-05-15 10:46 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Дамјан Гео ргиевски @ 2026-05-14 22:46 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
  Cc: linux-iio, linux-kernel,
	Дамјан
	Георгиевски

iio_triggered_buffer_setup_ext() unconditionally passes IRQF_ONESHOT to
iio_alloc_pollfunc(), even when the caller provides no thread function.
This causes a warning in __setup_irq() when the trigger is later
attached:

  WARNING: kernel/irq/manage.c:1502 at __setup_irq+0x4ee/0x700

IRQF_ONESHOT keeps the IRQ masked until the threaded handler completes,
but with no threaded handler this is semantically wrong. Only set the
flag when a thread function is actually provided.

Assisted-by: GitHub Copilot CLI:claude-opus-4-6
Signed-off-by: Дамјан Георгиевски <gdamjan@gmail.com>
---
This patch is a safety fix for how the Industrial I/O (IIO) subsystem handles
interrupts when setting up a triggered buffer.

It changes the flags passed to iio_alloc_pollfunc to ensure that the IRQF_ONESHOT
flag is only applied when a threaded interrupt handler actually exists.

Full disclosure, I got the warning on my laptop, and got Claude to debug
it. The explanation it gave sounds reasonable to me, but I'm not
personally familiar with the actual code.
---
 drivers/iio/buffer/industrialio-triggered-buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/buffer/industrialio-triggered-buffer.c b/drivers/iio/buffer/industrialio-triggered-buffer.c
index 9bf75dee7ff8..40eea3a44724 100644
--- a/drivers/iio/buffer/industrialio-triggered-buffer.c
+++ b/drivers/iio/buffer/industrialio-triggered-buffer.c
@@ -64,7 +64,7 @@ int iio_triggered_buffer_setup_ext(struct iio_dev *indio_dev,
 
 	indio_dev->pollfunc = iio_alloc_pollfunc(h,
 						 thread,
-						 IRQF_ONESHOT,
+						 thread ? IRQF_ONESHOT : 0,
 						 indio_dev,
 						 "%s_consumer%d",
 						 indio_dev->name,

---
base-commit: 1d5dcaa3bd65f2e8c9baa14a393d3a2dc5db7524
change-id: 20260513-patch-iio-buffer-395d8ca94768

Best regards,
--  
Дамјан Георгиевски <gdamjan@gmail.com>


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

* Re: [PATCH] iio: buffer: only set IRQF_ONESHOT when thread handler is provided
  2026-05-14 22:46 [PATCH] iio: buffer: only set IRQF_ONESHOT when thread handler is provided Дамјан Гео ргиевски
@ 2026-05-15 10:46 ` Andy Shevchenko
  2026-05-15 14:20   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2026-05-15 10:46 UTC (permalink / raw)
  To: Дамјан Гео
	ргиевски
  Cc: Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, linux-iio, linux-kernel

On Fri, May 15, 2026 at 12:46:00AM +0200, Дамјан Гео ргиевски wrote:
> iio_triggered_buffer_setup_ext() unconditionally passes IRQF_ONESHOT to
> iio_alloc_pollfunc(), even when the caller provides no thread function.
> This causes a warning in __setup_irq() when the trigger is later
> attached:
> 
>   WARNING: kernel/irq/manage.c:1502 at __setup_irq+0x4ee/0x700
> 
> IRQF_ONESHOT keeps the IRQ masked until the threaded handler completes,
> but with no threaded handler this is semantically wrong. Only set the
> flag when a thread function is actually provided.

Yes, please read the mailing list archive and find the previous attempt to fix
this and the associated discussions.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] iio: buffer: only set IRQF_ONESHOT when thread handler is provided
  2026-05-15 10:46 ` Andy Shevchenko
@ 2026-05-15 14:20   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2026-05-15 14:20 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Дамјан Гео
	ргиевски,
	David Lechner, Nuno Sá,
	Andy Shevchenko, linux-iio, linux-kernel

On Fri, 15 May 2026 13:46:30 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Fri, May 15, 2026 at 12:46:00AM +0200, Дамјан Гео ргиевски wrote:
> > iio_triggered_buffer_setup_ext() unconditionally passes IRQF_ONESHOT to
> > iio_alloc_pollfunc(), even when the caller provides no thread function.
> > This causes a warning in __setup_irq() when the trigger is later
> > attached:
> > 
> >   WARNING: kernel/irq/manage.c:1502 at __setup_irq+0x4ee/0x700
> > 
> > IRQF_ONESHOT keeps the IRQ masked until the threaded handler completes,
> > but with no threaded handler this is semantically wrong. Only set the
> > flag when a thread function is actually provided.  
> 
> Yes, please read the mailing list archive and find the previous attempt to fix
> this and the associated discussions.
> 


Just to check - what is the driver in use?  The fixes so far all belong in the
drivers, not papering over it in the core (note this is maybe the 3rd time
this same patch has been posted and rejected!) 

Jonathan

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

end of thread, other threads:[~2026-05-15 14:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-14 22:46 [PATCH] iio: buffer: only set IRQF_ONESHOT when thread handler is provided Дамјан Гео ргиевски
2026-05-15 10:46 ` Andy Shevchenko
2026-05-15 14:20   ` Jonathan Cameron

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

Powered by JetHome