scsi: ufs: Fix possible infinite loop in ufshcd_hold
authorStanley Chu <stanley.chu@mediatek.com>
Sun, 9 Aug 2020 05:07:34 +0000 (13:07 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 18 Aug 2020 01:52:45 +0000 (21:52 -0400)
commit93b6c5db06028a3b55122bbb74d0715dd8ca4ae0
tree19b62b1c83a5534c7f6ea6a46deffc9a2e55d2a4
parentfa39ab5184d64563cd36f2fb5f0d3fbad83a432c
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.

Link: https://lore.kernel.org/r/20200809050734.18740-1-stanley.chu@mediatek.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Co-developed-by: Andy Teng <andy.teng@mediatek.com>
Signed-off-by: Andy Teng <andy.teng@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ufs/ufshcd.c