Skip to content

Commit f5ca8d0

Browse files
ptr324martinkpetersen
authored andcommitted
scsi: ufs: host: mediatek: Disable auto-hibern8 during power mode changes
Disable auto-hibern8 during power mode transitions to prevent unintended entry into auto-hibern8. Restore the original auto-hibern8 timer value after completing the power mode change to maintain system stability and prevent potential issues during power state transitions. Signed-off-by: Peter Wang <peter.wang@mediatek.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent c73cd5e commit f5ca8d0

1 file changed

Lines changed: 30 additions & 23 deletions

File tree

drivers/ufs/host/ufs-mediatek.c

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,19 +1429,49 @@ static int ufs_mtk_pre_pwr_change(struct ufs_hba *hba,
14291429
return ret;
14301430
}
14311431

1432+
static int ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
1433+
{
1434+
int ret;
1435+
1436+
/* disable auto-hibern8 */
1437+
ufshcd_writel(hba, 0, REG_AUTO_HIBERNATE_IDLE_TIMER);
1438+
1439+
/* wait host return to idle state when auto-hibern8 off */
1440+
ufs_mtk_wait_idle_state(hba, 5);
1441+
1442+
ret = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100);
1443+
if (ret) {
1444+
dev_warn(hba->dev, "exit h8 state fail, ret=%d\n", ret);
1445+
1446+
ufshcd_force_error_recovery(hba);
1447+
1448+
/* trigger error handler and break suspend */
1449+
ret = -EBUSY;
1450+
}
1451+
1452+
return ret;
1453+
}
1454+
14321455
static int ufs_mtk_pwr_change_notify(struct ufs_hba *hba,
14331456
enum ufs_notify_change_status stage,
14341457
const struct ufs_pa_layer_attr *dev_max_params,
14351458
struct ufs_pa_layer_attr *dev_req_params)
14361459
{
14371460
int ret = 0;
1461+
static u32 reg;
14381462

14391463
switch (stage) {
14401464
case PRE_CHANGE:
1465+
if (ufshcd_is_auto_hibern8_supported(hba)) {
1466+
reg = ufshcd_readl(hba, REG_AUTO_HIBERNATE_IDLE_TIMER);
1467+
ufs_mtk_auto_hibern8_disable(hba);
1468+
}
14411469
ret = ufs_mtk_pre_pwr_change(hba, dev_max_params,
14421470
dev_req_params);
14431471
break;
14441472
case POST_CHANGE:
1473+
if (ufshcd_is_auto_hibern8_supported(hba))
1474+
ufshcd_writel(hba, reg, REG_AUTO_HIBERNATE_IDLE_TIMER);
14451475
break;
14461476
default:
14471477
ret = -EINVAL;
@@ -1686,29 +1716,6 @@ static void ufs_mtk_dev_vreg_set_lpm(struct ufs_hba *hba, bool lpm)
16861716
}
16871717
}
16881718

1689-
static int ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
1690-
{
1691-
int ret;
1692-
1693-
/* disable auto-hibern8 */
1694-
ufshcd_writel(hba, 0, REG_AUTO_HIBERNATE_IDLE_TIMER);
1695-
1696-
/* wait host return to idle state when auto-hibern8 off */
1697-
ufs_mtk_wait_idle_state(hba, 5);
1698-
1699-
ret = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100);
1700-
if (ret) {
1701-
dev_warn(hba->dev, "exit h8 state fail, ret=%d\n", ret);
1702-
1703-
ufshcd_force_error_recovery(hba);
1704-
1705-
/* trigger error handler and break suspend */
1706-
ret = -EBUSY;
1707-
}
1708-
1709-
return ret;
1710-
}
1711-
17121719
static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
17131720
enum ufs_notify_change_status status)
17141721
{

0 commit comments

Comments
 (0)