ufs: core: Avoid IRQ thread wakeup during active UIC command
Subsystems (3)
PATCH 1/1 ufs: core: Avoid IRQ thread wakeup during active UIC command
From: Peter Wang <[email protected]>
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.
--- drivers/ufs/core/ufshcd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/ufs/core/ufshcd.c +5 -2
@@ -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 );
Signature · 1 line
2.45.2
Bart Van Assche
reviewerQuoted 4 lines · On 3/4/26 1:12 AM, [email protected] wrote:
Only return
IRQ_WAKE_THREADwhen 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.
Quoted 7 lines · Bart Van Assche
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
Bart Van Assche
reviewerQuoted 5 lines · Peter Wang (王信友)
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.
Quoted 7 lines · Bart Van Assche
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:
Quoted 8 lines
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