@@ -58,6 +58,9 @@
/* Task management command timeout */
#define TM_CMD_TIMEOUT 100 /* msecs */
+/* Shutdown wait devcie into power off timeout */
+#define UFS_SHUTDWON_TIMEOUT 500 /* msecs */
+
/* maximum number of retries for a general UIC command */
#define UFS_UIC_COMMAND_RETRIES 3
@@ -9461,10 +9464,15 @@ 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;
+ unsigned long timeout;
- pm_runtime_get_sync(hba->dev);
+ /* Wait ufshcd_wl_shutdown clear ufs state */
+ timeout = jiffies + msecs_to_jiffies(UFS_SHUTDWON_TIMEOUT);
+ while (!ufshcd_is_ufs_dev_poweroff(hba) || !ufshcd_is_link_off(hba)) {
+ if (time_after(jiffies, timeout))
+ goto out;
+ msleep(1);
+ }
ufshcd_suspend(hba);
out: