[PATCH v2 3/3] media: dw100: Fix kernel oops with PREEMPT_RT enabled

Stefan Klug posted 3 patches 2 weeks, 4 days ago
There is a newer version of this series
[PATCH v2 3/3] media: dw100: Fix kernel oops with PREEMPT_RT enabled
Posted by Stefan Klug 2 weeks, 4 days ago
On kernels with PREEMPT_RT enabled, a "BUG: scheduling while atomic"
kernel oops occurs inside dw100_irq_handler -> vb2_buffer_done. This is
because vb2_buffer_done takes a spinlock which is not allowed within
interrupt context on PREEMPT_RT.

Fix that by dropping the IRQF_ONESHOT flag. There was only a hard
interrupt handler specified anyways, so IRQF_ONESHOT didn't have any
effect on non PREEMPT_RT systems. On PREEMPT_RT systems the interrupt
handler is automatically changed to threaded and the IRQF_ONESHOT flag
get's set internally.

There is one caveat though: During development regular "dw100
32e30000.dwe: Interrupt error: 0x1" errors occurred due to
DW100_INTERRUPT_STATUS_INT_ERR_TIME_OUT being set. This only happened on
non PREEMPT_RT setups when the interrupt handler was manually forced to
be threaded. On PREEMPT_RT systems (where the interrupt handler is now
implicitly threaded) this error was never seen.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
---

Changes in v2:
- Dropped the IRQF_ONESHOT instead of making the interrupt handler
  threaded to fix the issue.
- I didn't keep the r-by tag from Nicolas as the solution is now a
  different one.
---
 drivers/media/platform/nxp/dw100/dw100.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/nxp/dw100/dw100.c b/drivers/media/platform/nxp/dw100/dw100.c
index d2b1c62b52db47ea1d2242caaf334fff30c6f366..4c8be66f87519b36b2273ecf3f34eab03c5e6738 100644
--- a/drivers/media/platform/nxp/dw100/dw100.c
+++ b/drivers/media/platform/nxp/dw100/dw100.c
@@ -1593,7 +1593,7 @@ static int dw100_probe(struct platform_device *pdev)
 
 	pm_runtime_put_sync(&pdev->dev);
 
-	ret = devm_request_irq(&pdev->dev, irq, dw100_irq_handler, IRQF_ONESHOT,
+	ret = devm_request_irq(&pdev->dev, irq, dw100_irq_handler, 0,
 			       dev_name(&pdev->dev), dw_dev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to request irq: %d\n", ret);

-- 
2.51.0
Re: [PATCH v2 3/3] media: dw100: Fix kernel oops with PREEMPT_RT enabled
Posted by Sebastian Andrzej Siewior 2 weeks, 3 days ago
On 2026-01-22 15:44:58 [+0100], Stefan Klug wrote:
…
> There is one caveat though: During development regular "dw100
> 32e30000.dwe: Interrupt error: 0x1" errors occurred due to
> DW100_INTERRUPT_STATUS_INT_ERR_TIME_OUT being set. This only happened on
> non PREEMPT_RT setups when the interrupt handler was manually forced to
> be threaded. On PREEMPT_RT systems (where the interrupt handler is now
> implicitly threaded) this error was never seen.

This not something I would expect. If it is forced-threaded it is
forced-threaded on both (RT && !RT) so it should behave the same. It
might be related who it is handled (order wise) with the other (related)
interrupts in the system. Anyway. Removing that flag is the right flag
to do.

> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Sebastian