Commit 9a9ddb8a authored by Stanley Chu's avatar Stanley Chu Committed by Martin K. Petersen

scsi: ufs: ufs-mediatek: Fix flag of unipro low-power mode

Forcibly leave UniPro low-power mode if UIC commands failed.  This makes
hba_enable_delay_us as correct (default) value for re-enabling the host.

At the same time, change type of parameter "lpm" in function
ufs_mtk_unipro_set_pm() to "bool".

Link: https://lore.kernel.org/r/20200908064507.30774-4-stanley.chu@mediatek.comSigned-off-by: default avatarStanley Chu <stanley.chu@mediatek.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent a3e40b80
...@@ -419,7 +419,7 @@ static int ufs_mtk_pwr_change_notify(struct ufs_hba *hba, ...@@ -419,7 +419,7 @@ static int ufs_mtk_pwr_change_notify(struct ufs_hba *hba,
return ret; return ret;
} }
static int ufs_mtk_unipro_set_pm(struct ufs_hba *hba, u32 lpm) static int ufs_mtk_unipro_set_pm(struct ufs_hba *hba, bool lpm)
{ {
int ret; int ret;
struct ufs_mtk_host *host = ufshcd_get_variant(hba); struct ufs_mtk_host *host = ufshcd_get_variant(hba);
...@@ -427,8 +427,14 @@ static int ufs_mtk_unipro_set_pm(struct ufs_hba *hba, u32 lpm) ...@@ -427,8 +427,14 @@ static int ufs_mtk_unipro_set_pm(struct ufs_hba *hba, u32 lpm)
ret = ufshcd_dme_set(hba, ret = ufshcd_dme_set(hba,
UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0), UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0),
lpm); lpm);
if (!ret) if (!ret || !lpm) {
/*
* Forcibly set as non-LPM mode if UIC commands is failed
* to use default hba_enable_delay_us value for re-enabling
* the host.
*/
host->unipro_lpm = lpm; host->unipro_lpm = lpm;
}
return ret; return ret;
} }
...@@ -438,7 +444,9 @@ static int ufs_mtk_pre_link(struct ufs_hba *hba) ...@@ -438,7 +444,9 @@ static int ufs_mtk_pre_link(struct ufs_hba *hba)
int ret; int ret;
u32 tmp; u32 tmp;
ufs_mtk_unipro_set_pm(hba, 0); ret = ufs_mtk_unipro_set_pm(hba, false);
if (ret)
return ret;
/* /*
* Setting PA_Local_TX_LCC_Enable to 0 before link startup * Setting PA_Local_TX_LCC_Enable to 0 before link startup
...@@ -546,7 +554,7 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba) ...@@ -546,7 +554,7 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba)
if (err) if (err)
return err; return err;
err = ufs_mtk_unipro_set_pm(hba, 0); err = ufs_mtk_unipro_set_pm(hba, false);
if (err) if (err)
return err; return err;
...@@ -567,10 +575,10 @@ static int ufs_mtk_link_set_lpm(struct ufs_hba *hba) ...@@ -567,10 +575,10 @@ static int ufs_mtk_link_set_lpm(struct ufs_hba *hba)
{ {
int err; int err;
err = ufs_mtk_unipro_set_pm(hba, 1); err = ufs_mtk_unipro_set_pm(hba, true);
if (err) { if (err) {
/* Resume UniPro state for following error recovery */ /* Resume UniPro state for following error recovery */
ufs_mtk_unipro_set_pm(hba, 0); ufs_mtk_unipro_set_pm(hba, false);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment