* [PATCH v1] ufs: core: Avoid IRQ thread wakeup during active UIC command
@ 2026-03-04 7:12 peter.wang
2026-03-04 14:43 ` Bart Van Assche
0 siblings, 1 reply; 5+ messages in thread
From: peter.wang @ 2026-03-04 7:12 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: wsd_upstream, linux-mediatek, peter.wang, chun-hung.wu,
alice.chao, cc.chou, chaotian.jing, tun-yu.yu, eddie.huang,
naomi.chu, ed.tsai, bvanassche
From: Peter Wang <peter.wang@mediatek.com>
Only return IRQ_WAKE_THREAD when MCQ and ESI are not enabled
and no UIC command is active. Since the default UIC command
timeout is 500ms, handling IRQs in a thread during an active UIC
command can easily lead to timeouts due to delayed processing.
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
---
drivers/ufs/core/ufshcd.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 9908375b2f98..3f18c1a39f27 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -7201,8 +7201,11 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
u32 intr_status, enabled_intr_status;
/* Move interrupt handling to thread when MCQ & ESI are not enabled */
- if (!hba->mcq_enabled || !hba->mcq_esi_enabled)
- return IRQ_WAKE_THREAD;
+ if (!hba->mcq_enabled || !hba->mcq_esi_enabled) {
+ /* UIC commands should be processed promptly */
+ if (!hba->active_uic_cmd)
+ return IRQ_WAKE_THREAD;
+ }
intr_status = ufshcd_readl(hba, REG_INTERRUPT_STATUS);
enabled_intr_status = intr_status & ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
--
2.45.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v1] ufs: core: Avoid IRQ thread wakeup during active UIC command
2026-03-04 7:12 [PATCH v1] ufs: core: Avoid IRQ thread wakeup during active UIC command peter.wang
@ 2026-03-04 14:43 ` Bart Van Assche
2026-03-05 3:27 ` Peter Wang (王信友)
0 siblings, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2026-03-04 14:43 UTC (permalink / raw)
To: peter.wang, linux-scsi, martin.petersen, avri.altman, alim.akhtar,
jejb
Cc: wsd_upstream, linux-mediatek, chun-hung.wu, alice.chao, cc.chou,
chaotian.jing, tun-yu.yu, eddie.huang, naomi.chu, ed.tsai
On 3/4/26 1:12 AM, peter.wang@mediatek.com wrote:
> Only return IRQ_WAKE_THREAD when MCQ and ESI are not enabled
> and no UIC command is active. Since the default UIC command
> timeout is 500ms, handling IRQs in a thread during an active UIC
> command can easily lead to timeouts due to delayed processing.
A context switch takes somewhere between 1 and 10 microseconds.
That is several orders of magnitude below the UIC command timeout.
Something else must be causing the observed UIC timeouts.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] ufs: core: Avoid IRQ thread wakeup during active UIC command
2026-03-04 14:43 ` Bart Van Assche
@ 2026-03-05 3:27 ` Peter Wang (王信友)
2026-03-05 12:17 ` Bart Van Assche
0 siblings, 1 reply; 5+ messages in thread
From: Peter Wang (王信友) @ 2026-03-05 3:27 UTC (permalink / raw)
To: linux-scsi@vger.kernel.org, jejb@linux.ibm.com,
avri.altman@sandisk.com, bvanassche@acm.org,
alim.akhtar@samsung.com, martin.petersen@oracle.com
Cc: Alice Chao (趙珮均),
Eddie Huang (黃智傑),
CC Chou (周志杰),
Ed Tsai (蔡宗軒), wsd_upstream,
Chaotian Jing (井朝天),
Chun-Hung Wu (巫駿宏),
Naomi Chu (朱詠田),
linux-mediatek@lists.infradead.org,
Tun-yu Yu (游敦聿)
On Wed, 2026-03-04 at 08:43 -0600, Bart Van Assche wrote:
> A context switch takes somewhere between 1 and 10 microseconds.
> That is several orders of magnitude below the UIC command timeout.
> Something else must be causing the observed UIC timeouts.
>
> Thanks,
>
> Bart.
Hi Bart,
The main reason is not context switch time.
The problem is that a threaded IRQ handler can be preempted
by a regular IRQ.
When the system is busy, for example during kernel boot,
there are many other module IRQs present in the system.
Thanks
Peter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] ufs: core: Avoid IRQ thread wakeup during active UIC command
2026-03-05 3:27 ` Peter Wang (王信友)
@ 2026-03-05 12:17 ` Bart Van Assche
2026-03-06 3:49 ` Peter Wang (王信友)
0 siblings, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2026-03-05 12:17 UTC (permalink / raw)
To: Peter Wang (王信友), linux-scsi@vger.kernel.org,
jejb@linux.ibm.com, avri.altman@sandisk.com,
alim.akhtar@samsung.com, martin.petersen@oracle.com
Cc: Alice Chao (趙珮均),
Eddie Huang (黃智傑),
CC Chou (周志杰),
Ed Tsai (蔡宗軒), wsd_upstream,
Chaotian Jing (井朝天),
Chun-Hung Wu (巫駿宏),
Naomi Chu (朱詠田),
linux-mediatek@lists.infradead.org,
Tun-yu Yu (游敦聿)
On 3/4/26 9:27 PM, Peter Wang (王信友) wrote:
> The main reason is not context switch time.
> The problem is that a threaded IRQ handler can be preempted
> by a regular IRQ.
> When the system is busy, for example during kernel boot,
> there are many other module IRQs present in the system.
Spending 500 ms in interrupts without giving the CPU a chance to run is
excessive, isn't it? Anyway, if you really need this patch, please
mention the above information in the patch description and combine the
two if-statements into a single if-statement, e.g. as follows:
if ((!hba->mcq_enabled || !hba->mcq_esi_enabled) &&
!hba->active_uic_cmd)
...
Thanks,
Bart.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v1] ufs: core: Avoid IRQ thread wakeup during active UIC command
2026-03-05 12:17 ` Bart Van Assche
@ 2026-03-06 3:49 ` Peter Wang (王信友)
0 siblings, 0 replies; 5+ messages in thread
From: Peter Wang (王信友) @ 2026-03-06 3:49 UTC (permalink / raw)
To: linux-scsi@vger.kernel.org, jejb@linux.ibm.com,
avri.altman@sandisk.com, bvanassche@acm.org,
alim.akhtar@samsung.com, martin.petersen@oracle.com
Cc: Alice Chao (趙珮均),
CC Chou (周志杰),
Eddie Huang (黃智傑),
Ed Tsai (蔡宗軒), wsd_upstream,
Chaotian Jing (井朝天),
Chun-Hung Wu (巫駿宏),
Naomi Chu (朱詠田),
linux-mediatek@lists.infradead.org,
Tun-yu Yu (游敦聿)
On Thu, 2026-03-05 at 06:17 -0600, Bart Van Assche wrote:
> Spending 500 ms in interrupts without giving the CPU a chance to run
> is
> excessive, isn't it? Anyway, if you really need this patch, please
> mention the above information in the patch description and combine
> the
> two if-statements into a single if-statement, e.g. as follows:
>
> if ((!hba->mcq_enabled || !hba->mcq_esi_enabled) &&
> !hba->active_uic_cmd)
> ...
>
> Thanks,
>
> Bart.
>
Yes, I will add more description in the next version.
Thanks
Peter
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-03-06 3:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-04 7:12 [PATCH v1] ufs: core: Avoid IRQ thread wakeup during active UIC command peter.wang
2026-03-04 14:43 ` Bart Van Assche
2026-03-05 3:27 ` Peter Wang (王信友)
2026-03-05 12:17 ` Bart Van Assche
2026-03-06 3:49 ` Peter Wang (王信友)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox