Skip to content

Commit f29ec85

Browse files
Sanjeev Ymartinkpetersen
authored andcommitted
scsi: ufs: host: mediatek: Return error directly on idle wait timeout
Optimize the recovery flow by returning an error code immediately if a wait idle timeout occurs, rather than waiting for the link to reach the up state. Shorten the recovery process and improve error handling efficiency when idle state transitions fail. Signed-off-by: Sanjeev Y <sanjeev.y@mediatek.com> Reviewed-by: Peter Wang <peter.wang@mediatek.com> Signed-off-by: Peter Wang <peter.wang@mediatek.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent f5ca8d0 commit f29ec85

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

drivers/ufs/host/ufs-mediatek.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ static void ufs_mtk_dbg_sel(struct ufs_hba *hba)
416416
}
417417
}
418418

419-
static void ufs_mtk_wait_idle_state(struct ufs_hba *hba,
419+
static int ufs_mtk_wait_idle_state(struct ufs_hba *hba,
420420
unsigned long retry_ms)
421421
{
422422
u64 timeout, time_checked;
@@ -452,8 +452,12 @@ static void ufs_mtk_wait_idle_state(struct ufs_hba *hba,
452452
break;
453453
} while (time_checked < timeout);
454454

455-
if (wait_idle && sm != VS_HCE_BASE)
455+
if (wait_idle && sm != VS_HCE_BASE) {
456456
dev_info(hba->dev, "wait idle tmo: 0x%x\n", val);
457+
return -ETIMEDOUT;
458+
}
459+
460+
return 0;
457461
}
458462

459463
static int ufs_mtk_wait_link_state(struct ufs_hba *hba, u32 state,
@@ -1437,9 +1441,13 @@ static int ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
14371441
ufshcd_writel(hba, 0, REG_AUTO_HIBERNATE_IDLE_TIMER);
14381442

14391443
/* wait host return to idle state when auto-hibern8 off */
1440-
ufs_mtk_wait_idle_state(hba, 5);
1444+
ret = ufs_mtk_wait_idle_state(hba, 5);
1445+
if (ret)
1446+
goto out;
14411447

14421448
ret = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100);
1449+
1450+
out:
14431451
if (ret) {
14441452
dev_warn(hba->dev, "exit h8 state fail, ret=%d\n", ret);
14451453

@@ -1614,7 +1622,11 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba)
16141622
return err;
16151623

16161624
/* Check link state to make sure exit h8 success */
1617-
ufs_mtk_wait_idle_state(hba, 5);
1625+
err = ufs_mtk_wait_idle_state(hba, 5);
1626+
if (err) {
1627+
dev_warn(hba->dev, "wait idle fail, err=%d\n", err);
1628+
return err;
1629+
}
16181630
err = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100);
16191631
if (err) {
16201632
dev_warn(hba->dev, "exit h8 state fail, err=%d\n", err);

0 commit comments

Comments
 (0)