scsi: ufs: Fix possible infinite loop in ufshcd_hold
Subsystems (2)
PATCH v3 1/1 scsi: ufs: Fix possible infinite loop in ufshcd_hold
In ufshcd_suspend(), after clk-gating is suspended and link is set as Hibern8 state, ufshcd_hold() is still possibly invoked before ufshcd_suspend() returns. For example, MediaTek's suspend vops may issue UIC commands which would call ufshcd_hold() during the command issuing flow.
Now if UFSHCD_CAP_HIBERN8_WITH_CLK_GATING capability is enabled, then ufshcd_hold() may enter infinite loops because there is no clk-ungating work scheduled or pending. In this case, ufshcd_hold() shall just bypass, and keep the link as Hibern8 state.
---
Changes since v2:
- Rebase to the latest Martin's queue branch
- Add missing Reviewed tag since Avri's letter is not showing up in LKML and Patchwork
--- drivers/scsi/ufs/ufshcd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +4 -1
@@ -1561,6 +1561,7 @@ static void ufshcd_ungate_work(struct work_struct *work)int ufshcd_hold (struct ufs_hba *hba,bool async) {int rc =0 ; +bool flush_result;unsigned long flags;if (!ufshcd_is_clkgating_allowed (hba))
@@ -1592,7 +1593,9 @@ int ufshcd_hold(struct ufs_hba *hba, bool async)break ; }spin_unlock_irqrestore (hba->host->host_lock, flags); -flush_work (&hba->clk_gating.ungate_work); + flush_result =flush_work (&hba->clk_gating.ungate_work); +if (hba->clk_gating.is_suspended && !flush_result) + goto out;spin_lock_irqsave (hba->host->host_lock, flags); goto start; }
Signature · 1 line
2.18.0
Martin K. Petersen
AppliedQuoted 10 lines · Stanley Chu
In
ufshcd_suspend(), after clk-gating is suspended and link is set as Hibern8 state,ufshcd_hold()is still possibly invoked beforeufshcd_suspend()returns. For example, MediaTek's suspend vops may issue UIC commands which would callufshcd_hold()during the command issuing flow.Now if
UFSHCD_CAP_HIBERN8_WITH_CLK_GATINGcapability is enabled, thenufshcd_hold()may enter infinite loops because there is no clk-ungating work scheduled or pending. In this case,ufshcd_hold()shall just bypass, and keep the link as Hibern8 state.
Applied to 5.9/scsi-fixes, thanks!
[1/1] scsi: ufs: Fix possible infinite loop in ufshcd_hold
https://git.kernel.org/mkp/scsi/c/93b6c5db0602
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering