From: Stefan Klug <stefan.klug@ideasonboard.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Steven Rostedt <rostedt@goodmis.org>
Cc: Nicolas Dufresne <nicolas@ndufresne.ca>,
Xavier Roumegue <xavier.roumegue@oss.nxp.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH 3/4] media: dw100: Fix kernel oops with PREEMPT_RT enabled
Date: Tue, 06 Jan 2026 18:11:27 +0100 [thread overview]
Message-ID: <176771948736.12184.11458532023194713133@localhost> (raw)
In-Reply-To: <20260106004928.GL10026@pendragon.ideasonboard.com>
Quoting Laurent Pinchart (2026-01-06 01:49:28)
> On Mon, Jan 05, 2026 at 07:39:33PM -0500, Steven Rostedt wrote:
> > On Tue, 6 Jan 2026 01:59:21 +0200 Laurent Pinchart wrote:
> >
> > > > That's interesting, do you plan to update more drivers ? There is a lot of m2m
> > > > using hard IRQ to minimize the idle time (save a context switch), but RT support
> > > > might be more worth then that.
> > >
> > > This is a part of PREEMPT_RT that puzzles me. By turning regular
> > > spinlocks into mutexes, RT seems to break drivers that use those
> > > spinlocks in hard IRQ handlers. That's a very large number of drivers
> > > given how widespread regular spinlock usage is. Do drivers need to be
> > > manually converted to either raw spinlocks or threaded IRQ handlers ?
> >
> > No. Pretty much all interrupts are converted into threaded interrupt
> > handlers unless IRQF_NO_THREAD, IRQF_PERCPU, or IRQF_ONESHOT are specified.
> >
> > The interrupt line is disabled until the thread handler is called.
> >
> > > What about non-RT kernels, how can a driver avoid the thread scheduling
> > > penalty in those cases, do they need to manually select between
> > > request_irq() and request_threaded_irq() based on if RT is enabled ?
> > > This puzzles me, it feels like I must be missing something.
> >
> > The issue here is that the interrupt handler specifies ONESHOT which causes
> > the handler to be executed in hard interrupt context.
>
> Gotcha.
>
> Stefan, please explain in the commit message why the ONESHOT flag is
> set by the driver.
Hah, if I knew that :-).
The pieces I have are:
In the DT the interrupt line is marked as IRQ_TYPE_LEVEL_HIGH. I don't
know why and couldn't find a reference to that in the reference manual.
Assuming it is a level interrupt, then it makes sense to treat it as ONESHOT,
otherwise it would fire again immediately after handling the hard
interrupt...but it was a hard interrupt in first place - huh.
I just realize that I still miss a bit of the puzzle:
ONESHOT is doumented as:
"Interrupt is not reenabled after the hardirq handler finished. Used by
threaded interrupts which need to keep the irq line disabled until the
threaded handler has been run."
That makes perfect sense. So ONESHOT disables the irq line until the
thread_fn has completed (if it was set). Now on preempt_rt inside
irq_setup_forced_threading() we don't force threading if ONESHOT is
requested. Why is that?
So I'm left with two questions:
- Why aren't ONESHOT irq handlers forced to threaded on preempt_rt?
- Why was ONESHOT requested in first place as to my current knowledge it
really only makes sense if a thread_fn is defined.
Did I just answer my own question? ONESHOT only makes sense if there is
a thread_fn and it is assumed that the hard handler is necessary. So
preempt_rt doesn't try to change that?
That would mean the ONESHOT in the dw100 was not necessary in first
place but didn't do any harm until preempt_rt was enabled... And if
ONSHOT is *not* set preempt_rt would automatically force the irq handler
to be threaded and set the ONESHOT flag in irq_setup_forced_threading().
So everything would be fine except that we'd still hit the timeout issue
from patch 4/4.
So if I got that right, the dw100 driver is in the unfortunate
situation, that the irq handler consists of two parts where the first
part *must* run in hard interrupt context and the second part *should* run
in hard interrupt context but it is fine if it becomes threaded due to
preempt_rt. As we can't model that, the best we can do is to always run
the second part threaded...
So patch 4/4 seems correct until we get new information about the
hardware.
Any thoughts?
Best regards,
Stefan
>
> --
> Regards,
>
> Laurent Pinchart
next prev parent reply other threads:[~2026-01-06 17:11 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-05 11:35 [PATCH 0/4] media: dw100: Dynamic vertex map updates and fixes for PREEMPT_RT Stefan Klug
2026-01-05 11:35 ` [PATCH 1/4] media: dw100: Implement V4L2 requests support Stefan Klug
2026-01-05 18:46 ` Nicolas Dufresne
2026-01-06 0:33 ` Laurent Pinchart
2026-01-06 14:16 ` Stefan Klug
2026-01-06 14:35 ` Nicolas Dufresne
2026-01-06 14:59 ` Laurent Pinchart
2026-01-06 15:44 ` Nicolas Dufresne
2026-01-06 14:53 ` Laurent Pinchart
2026-01-06 15:41 ` Nicolas Dufresne
2026-01-06 15:45 ` Laurent Pinchart
2026-01-06 15:56 ` Nicolas Dufresne
2026-01-06 17:25 ` Laurent Pinchart
2026-01-05 11:35 ` [PATCH 2/4] media: dw100: Implement dynamic vertex map update Stefan Klug
2026-01-05 18:58 ` Nicolas Dufresne
2026-01-06 0:42 ` Laurent Pinchart
2026-01-06 13:47 ` Nicolas Dufresne
2026-01-06 14:29 ` Stefan Klug
2026-01-06 15:27 ` Nicolas Dufresne
2026-01-06 17:30 ` Laurent Pinchart
2026-01-06 14:35 ` Laurent Pinchart
2026-01-05 11:35 ` [PATCH 3/4] media: dw100: Fix kernel oops with PREEMPT_RT enabled Stefan Klug
2026-01-05 19:02 ` Nicolas Dufresne
2026-01-05 23:59 ` Laurent Pinchart
2026-01-06 0:39 ` Steven Rostedt
2026-01-06 0:49 ` Laurent Pinchart
2026-01-06 17:11 ` Stefan Klug [this message]
2026-01-12 11:43 ` Sebastian Andrzej Siewior
2026-01-14 17:22 ` Stefan Klug
2026-01-23 8:24 ` Sebastian Andrzej Siewior
2026-01-05 11:35 ` [PATCH 4/4] media: dw100: Split interrupt handler to fix timeout error Stefan Klug
2026-01-05 19:03 ` Nicolas Dufresne
2026-01-05 21:37 ` Steven Rostedt
2026-01-05 23:44 ` Laurent Pinchart
2026-01-06 0:43 ` Steven Rostedt
2026-01-06 0:51 ` Laurent Pinchart
2026-01-06 0:57 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=176771948736.12184.11458532023194713133@localhost \
--to=stefan.klug@ideasonboard.com \
--cc=bigeasy@linutronix.de \
--cc=clrkwllms@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=nicolas@ndufresne.ca \
--cc=rostedt@goodmis.org \
--cc=xavier.roumegue@oss.nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox