scsi: ufs: fixup active period of ufshcd interrupt
Subsystems (2)
cover scsi: ufs: fixup active period of ufshcd interrupt
This patchset fixes up active duration of ufshcd interrupt to avoid potential system hang issues.
Stanley Chu (2):
scsi: ufs: disable irq before disabling clocks
scsi: ufs: disable interrupt during clock-gating
drivers/scsi/ufs/ufshcd.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
Signature · 1 line
2.18.0
PATCH 1/2 scsi: ufs: disable irq before disabling clocks
During suspend flow, interrupt shall be disabled before disabling clocks to avoid potential system hang due to accessing host registers after host clocks are disabled.
For example, if an interrupt comes with IRQF_IRQPOLL flag configured with the misrouted interrupt recovery feature enabled, ufshcd ISR may be triggered even if nothing shall be done for UFS. In this case, system hang may happen if UFS interrupt status register is accessed with host clocks disabled.
--- drivers/scsi/ufs/ufshcd.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/scsi/ufs/ufshcd.c +6 -5
@@ -7908,6 +7908,11 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) ret =ufshcd_vops_suspend (hba, pm_op);if (ret) goto set_link_active; +/* +* Disable the host irq as host controller as there won't be any +* host controller transaction expected till resume. +*/ +ufshcd_disable_irq (hba);if (!ufshcd_is_link_active (hba))ufshcd_setup_clocks (hba, false);
@@ -7917,11 +7922,7 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) hba->clk_gating.state =CLKS_OFF ;trace_ufshcd_clk_gating (dev_name (hba->dev), hba->clk_gating.state); -/* -* Disable the host irq as host controller as there won't be any -* host controller transaction expected till resume. -*/ -ufshcd_disable_irq (hba); +/* Put the host controller in low power mode if possible */ ufshcd_hba_vreg_set_lpm (hba); goto out;
Signature · 1 line
2.18.0
PATCH 2/2 scsi: ufs: disable interrupt during clock-gating
In reply to Stanley ChuSimilar to suspend, ufshcd interrupt can be disabled since there won't be any host controller transaction expected till clocks ungated.
--- drivers/scsi/ufs/ufshcd.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/ufs/ufshcd.c +4 -0
@@ -1490,6 +1490,8 @@ static void ufshcd_ungate_work(struct work_struct *work)spin_unlock_irqrestore (hba->host->host_lock, flags);ufshcd_setup_clocks (hba, true); +ufshcd_enable_irq (hba); +/* Exit from hibern8 */ if (ufshcd_can_hibern8_during_gating (hba)) {/* Prevent gating in this path */
@@ -1636,6 +1638,8 @@ static void ufshcd_gate_work(struct work_struct *work)ufshcd_set_link_hibern8 (hba); } +ufshcd_disable_irq (hba); +if (!ufshcd_is_link_active (hba))ufshcd_setup_clocks (hba, false);else
Signature · 1 line
2.18.0
Re: [PATCH v1 2/2] scsi: ufs: disable interrupt during clock-gating
Quoted 24 lines · Stanley Chu
Similar to suspend, ufshcd interrupt can be disabled since there won't be any host controller transaction expected till clocks ungated.
Signed-off-by Stanley Chu <[email protected]>--- drivers/scsi/ufs/ufshcd.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/scsi/ufs/ufshcd.c +2
-0@@ -1490,6 +1490,8 @@ static void ufshcd_ungate_work(struct work_struct *work)spin_unlock_irqrestore (hba->host->host_lock, flags);ufshcd_setup_clocks (hba, true); +ufshcd_enable_irq (hba); +/* Exit from hibern8 */ if (ufshcd_can_hibern8_during_gating (hba)) {/* Prevent gating in this path */
drivers/scsi/ufs/ufshcd.c static void ufshcd_gate_work(struct work_struct *work) · line 1645
Quoted 8 lines
drivers/scsi/ufs/ufshcd.c +2
-0@@ -1636,6 +1638,8 @@ static void ufshcd_gate_work(struct work_struct *work)ufshcd_set_link_hibern8 (hba); } +ufshcd_disable_irq (hba); +if (!ufshcd_is_link_active (hba))ufshcd_setup_clocks (hba, false);else
Hi,
Does this save significant power? I see that gate/ungate of clocks happen far too frequently than suspend/resume.
Have you considered how much latency this would add to the gating/ungating path?
-asd
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, Linux Foundation Collaborative Project
Re: [PATCH v1 2/2] scsi: ufs: disable interrupt during clock-gating
Hi Asutosh,
Quoted 11 lines · Asutosh Das (asd)
Quoted 1 line
Hi,
Does this save significant power? I see that gate/ungate of clocks happen far too frequently than suspend/resume.Have you considered how much latency this would add to the gating/ungating path?
-asd
Yes, we have measured 200 times clk-gating/clk-ungating and latency data is showed as below,
For clk-gating with interrupt disabling toggled,
Average latency of each clk-gating: 55.117 us Average latency of irq-disabling during clk-gating: 4.2 us
For clk-ungating with interrupt enabling toggled,
Average latency of each clk-ungating: 118.324 us Average latency of irq-enabling during clk-ungating: 2.9 us
The evaluation here is based on below Can's patch therefore the interrupt control (enable_irq/disable_irq) latency is much shorter than before (request_irq/free_irq).
scsi: ufs: Do not free irq in suspend
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/scsi/ufs/ufshcd.c?id=8709c1f68536e256668812788af5b2bb027f49c3
BTW, the main purpose of this patch is aimed to protect ufshcd register from accessing while host clocks are disabled to fix potential system hang issue. The possible scenario is mentioned in commit message of patch "scsi: ufs: disable irq before disabling clocks" in the same series.
Thanks
Stanley
Asutosh Das (asd)
Reviewed-byRe: [PATCH v1 2/2] scsi: ufs: disable interrupt during clock-gating
Quoted 34 lines · Stanley Chu
Hi Asutosh,
Quoted 11 lines · Asutosh Das (asd)
Quoted 1 line
Hi,
Does this save significant power? I see that gate/ungate of clocks happen far too frequently than suspend/resume.Have you considered how much latency this would add to the gating/ungating path?
-asd
Yes, we have measured 200 times clk-gating/clk-ungating and latency data is showed as below,
For clk-gating with interrupt disabling toggled,
Average latency of each clk-gating: 55.117 us Average latency of irq-disabling during clk-gating: 4.2 us
For clk-ungating with interrupt enabling toggled,
Average latency of each clk-ungating: 118.324 us Average latency of irq-enabling during clk-ungating: 2.9 usThe evaluation here is based on below Can's patch therefore the interrupt control (enable_irq/disable_irq) latency is much shorter than before (request_irq/free_irq).
scsi: ufs: Do not free irq in suspend
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/scsi/ufs/ufshcd.c?id=8709c1f68536e256668812788af5b2bb027f49c3
Quoted 9 lines
BTW, the main purpose of this patch is aimed to protect ufshcd register from accessing while host clocks are disabled to fix potential system hang issue. The possible scenario is mentioned in commit message of patch "scsi: ufs: disable irq before disabling clocks" in the same series.
Thanks
Stanley
Thanks for the data.
It'd be interesting to know more on the - misrouted interrupt recovery feature though.
-
Thanks
Asutosh
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, Linux Foundation Collaborative Project
Dear reviewers,
Gentle ping for this patch set.
Quoted 9 lines · Stanley Chu
This patchset fixes up active duration of ufshcd interrupt to avoid potential system hang issues.
Stanley Chu (2):
scsi: ufs: disable irq before disabling clocks
scsi: ufs: disable interrupt during clock-gatingdrivers/scsi/ufs/ufshcd.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
Thanks,
Stanley
Avri Altman
Reviewed-byLooks good to me.
Quoted 15 lines · Stanley Chu
Quoted 1 line
This patchset fixes up active duration of ufshcd interrupt to avoid potential
system hang issues.
Quoted 8 lines
Stanley Chu (2):
scsi: ufs: disable irq before disabling clocks
scsi: ufs: disable interrupt during clock-gatingdrivers/scsi/ufs/ufshcd.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)Thanks,
Stanley
Martin K. Petersen
AppliedStanley,
Quoted 2 lines
This patchset fixes up active duration of ufshcd interrupt to avoid potential system hang issues.
Applied to 5.6/scsi-queue, thanks!
Signature · 6 lines
Martin K. Petersen Oracle Linux Engineering _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel