Re: [PATCH] scsi: ufs: core: Avoid sleeping in hard interrupt context when PREEMP_RT is enabled.

From: Sebastian Andrzej Siewior

Date: Wed Jul 15 2026 - 11:34:55 EST


On 2026-07-15 17:15:08 [+0200], Gregory CLEMENT wrote:
> Hello Sebastian,
Hi,

> > If MCQ is enabled then request_threaded_irq(, mask_interrupt_only,
> > ufshcd_threaded_intr, IRQF_NO_THREAD)
> >
>
> I'm implementing your solution to see if it fixes the issue without
> introducing a regression., but I'm puzzled by this previous line:
> `mask_interrupt_only ??`.

mask_interrupt_only means the function would mask the interrupt in the
device (UFS) hardware so the IRQ does not raise again once interrupts
are enabled again. The ufshcd_threaded_intr() routine would then have to
unmask the interrupt at the end of its doing so the IRQ can raise again.

> Also, I don't understand why `IRQF_NO_THREAD` is used for the threaded
> IRQ; it seems to indicate opposite behavior. Could you please explain
> what you have in mind ?

The previous without IRQF_NO_THREAD provide a primary handler just
masking the IRQ line and a threaded handler. One thread visible in the
system.
With `threadirqs' or PREEMPT_RT enabled the IRQ core will thread the
primary handler (masking just the IRQ line) and the threaded handler
which does the work. So you will see two threads. Also the interrupt
line will be masked (in the IRQ-chip) as long the two handler are
running. ps will show two threads.

To limit this, IRQF_NO_THREAD will ensure that the primary handler
(which masks the IRQ line in the device's HW) will not be threaded. It
is brief, takes no locks so why not. The secondary handler is the only
thread. The IRQ will also not be masked in the IRQ-chip.

> Grégory
>
Sebastian