diff mbox series

[v1,1/3] ufs: host: mediatek: check link status after exit hibern8

Message ID 20231221110416.16176-2-peter.wang@mediatek.com (mailing list archive)
State Accepted, archived
Headers show
Series ufs: host: mediatek: Provide fixes in MediaTek platforms | expand

Commit Message

Peter Wang (王信友) Dec. 21, 2023, 11:04 a.m. UTC
From: Peter Wang <peter.wang@mediatek.com>

To prevent SSU(Active) error, check link status after exit hibern8.
If link is not VS_LINK_UP, return error and do ufshcd_link_recovery.

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

Comments

Chun-Hung Wu (巫駿宏) Dec. 25, 2023, 7:20 a.m. UTC | #1
On Thu, 2023-12-21 at 19:04 +0800, peter.wang@mediatek.com wrote:
> From: Peter Wang <peter.wang@mediatek.com>
> 
> To prevent SSU(Active) error, check link status after exit hibern8.
> If link is not VS_LINK_UP, return error and do ufshcd_link_recovery.
> 
> Signed-off-by: Peter Wang <peter.wang@mediatek.com>
> ---
>  drivers/ufs/host/ufs-mediatek.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-
> mediatek.c
> index fc61790d289b..104354a4d899 100644
> --- a/drivers/ufs/host/ufs-mediatek.c
> +++ b/drivers/ufs/host/ufs-mediatek.c
> @@ -1208,11 +1208,18 @@ static int ufs_mtk_link_set_hpm(struct
> ufs_hba *hba)
>  		return err;
>  
>  	err = ufshcd_uic_hibern8_exit(hba);
> -	if (!err)
> -		ufshcd_set_link_active(hba);
> -	else
> +	if (err)
>  		return err;
>  
> +	/* Check link state to make sure exit h8 success */
> +	ufs_mtk_wait_idle_state(hba, 5);
> +	err = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100);
> +	if (err) {
> +		dev_warn(hba->dev, "exit h8 state fail, err=%d\n",
> err);
> +		return err;
> +	}
> +	ufshcd_set_link_active(hba);
> +
>  	if (!hba->mcq_enabled) {
>  		err = ufshcd_make_hba_operational(hba);
>  	} else {

Reviewed-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>

Chun-Hung
diff mbox series

Patch

diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index fc61790d289b..104354a4d899 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -1208,11 +1208,18 @@  static int ufs_mtk_link_set_hpm(struct ufs_hba *hba)
 		return err;
 
 	err = ufshcd_uic_hibern8_exit(hba);
-	if (!err)
-		ufshcd_set_link_active(hba);
-	else
+	if (err)
 		return err;
 
+	/* Check link state to make sure exit h8 success */
+	ufs_mtk_wait_idle_state(hba, 5);
+	err = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100);
+	if (err) {
+		dev_warn(hba->dev, "exit h8 state fail, err=%d\n", err);
+		return err;
+	}
+	ufshcd_set_link_active(hba);
+
 	if (!hba->mcq_enabled) {
 		err = ufshcd_make_hba_operational(hba);
 	} else {