diff mbox series

[v1] scsi: ufs: skip shutdown if hba is not powered

Message ID 1568780438-28753-1-git-send-email-stanley.chu@mediatek.com (mailing list archive)
State Mainlined
Commit f51913eef23f74c3bd07899dc7f1ed6df9e521d8
Headers show
Series [v1] scsi: ufs: skip shutdown if hba is not powered | expand

Commit Message

Stanley Chu Sept. 18, 2019, 4:20 a.m. UTC
In some cases, hba may go through shutdown flow without successful
initialization and then make system hang.

For example, if ufshcd_change_power_mode() gets error and
leads to ufshcd_hba_exit() to release resources of the host,
future shutdown flow may hang the system since the host register
will be accessed in unpowered state.

To solve this issue, simply add checking to skip shutdown for above
kind of situation.

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
 drivers/scsi/ufs/ufshcd.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Bean Huo Sept. 19, 2019, 3:49 p.m. UTC | #1
>To solve this issue, simply add checking to skip shutdown for above kind of
>situation.
>
>Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Acked-by: Bean Huo <beanhuo@micron.com>
Martin K. Petersen Sept. 24, 2019, 2:24 a.m. UTC | #2
Stanley,

> In some cases, hba may go through shutdown flow without successful
> initialization and then make system hang.

Applied to 5.4/scsi-fixes, thanks!
diff mbox series

Patch

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 60a24fe908e7..a601ce0f6195 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -8121,6 +8121,9 @@  int ufshcd_shutdown(struct ufs_hba *hba)
 {
 	int ret = 0;
 
+	if (!hba->is_powered)
+		goto out;
+
 	if (ufshcd_is_ufs_dev_poweroff(hba) && ufshcd_is_link_off(hba))
 		goto out;