linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] scsi: ufs: skip shutdown if hba is not powered
@ 2019-09-18  4:20 Stanley Chu
       [not found] ` <1568780438-28753-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Stanley Chu @ 2019-09-18  4:20 UTC (permalink / raw)
  To: linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	martin.petersen-QHcLZuEGTsvQT0dZR+AlfA, avri.altman-Sjgp3cTcYWE,
	alim.akhtar-Sze3O3UU22JBDgjK7y7TUQ,
	pedrom.sousa-HKixBCOQz3hWk0Htik3J/w, jejb-tEXmvtCZX7AybS5Ee8rs3A
  Cc: andy.teng-NuS5LvNUpcJWk0Htik3J/w,
	chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w,
	kuohong.wang-NuS5LvNUpcJWk0Htik3J/w,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	peter.wang-NuS5LvNUpcJWk0Htik3J/w,
	matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w, Stanley Chu,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	beanhuo-AL4WhLSQfzjQT0dZR+AlfA

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-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
 drivers/scsi/ufs/ufshcd.c | 3 +++
 1 file changed, 3 insertions(+)

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;
 
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-09-24  2:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-18  4:20 [PATCH v1] scsi: ufs: skip shutdown if hba is not powered Stanley Chu
     [not found] ` <1568780438-28753-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2019-09-19 15:49   ` [EXT] " Bean Huo (beanhuo)
2019-09-24  2:24   ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).