All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] scsi: ufs: correct ufshcd_shutdown flow
@ 2022-07-19 13:02 peter.wang
  2022-07-20 21:40 ` Bart Van Assche
  0 siblings, 1 reply; 8+ messages in thread
From: peter.wang @ 2022-07-19 13:02 UTC (permalink / raw)
  To: stanley.chu, linux-scsi, martin.petersen, avri.altman,
	alim.akhtar, jejb
  Cc: wsd_upstream, linux-mediatek, peter.wang, chun-hung.wu,
	alice.chao, cc.chou, chaotian.jing, jiajie.hao, powen.kao,
	qilin.tan, lin.gui

From: Peter Wang <peter.wang@mediatek.com>

After ufshcd_wl_shutdown set device poweroff and link off,
ufshcd_shutdown not turn off regulators/clocks.
Correct the flow to wait ufshcd_wl_shutdown done and turn off
regulators/clocks by polling ufs device/link state 500ms.
Also remove pm_runtime_get_sync because it is unnecessary.

Signed-off-by: Peter Wang <peter.wang@mediatek.com>
---
 drivers/ufs/core/ufshcd.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index c7b337480e3e..1c11af48b584 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -9461,10 +9461,14 @@ EXPORT_SYMBOL(ufshcd_runtime_resume);
  */
 int ufshcd_shutdown(struct ufs_hba *hba)
 {
-	if (ufshcd_is_ufs_dev_poweroff(hba) && ufshcd_is_link_off(hba))
-		goto out;
+	ktime_t timeout = ktime_add_ms(ktime_get(), 500);
 
-	pm_runtime_get_sync(hba->dev);
+	/* Wait ufshcd_wl_shutdown clear ufs state, timeout 500 ms */
+	while (!ufshcd_is_ufs_dev_poweroff(hba) || !ufshcd_is_link_off(hba)) {
+		if (ktime_after(ktime_get(), timeout))
+			goto out;
+		msleep(1);
+	}
 
 	ufshcd_suspend(hba);
 out:
-- 
2.18.0



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

end of thread, other threads:[~2022-07-25  3:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-19 13:02 [PATCH v1] scsi: ufs: correct ufshcd_shutdown flow peter.wang
2022-07-20 21:40 ` Bart Van Assche
2022-07-21  4:30   ` Peter Wang
2022-07-22  1:27     ` Chaotian Jing
2022-07-22  2:32       ` Peter Wang
2022-07-22 18:04     ` Bart Van Assche
2022-07-25  3:45       ` Peter Wang
2022-07-22 21:07     ` Bart Van Assche

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.