]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: ufs: host: mediatek: Enhance recovery on hibernation exit failure
authorPeter Wang <peter.wang@mediatek.com>
Wed, 3 Sep 2025 02:44:37 +0000 (10:44 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:34:21 +0000 (15:34 -0500)
[ Upstream commit faac32d4ece30609f1a0930ca0ae951cf6dc1786 ]

Improve the recovery process for hibernation exit failures. Trigger the
error handler and break the suspend operation to ensure effective
recovery from hibernation errors. Activate the error handling mechanism
by ufshcd_force_error_recovery and scheduling the error handler work.

Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/ufs/core/ufshcd.c
drivers/ufs/host/ufs-mediatek.c
include/ufs/ufshcd.h

index 2d07902ce7f1b5852a42db8f1f3e406348716a36..d4dbb6769efa20e381cf816be910646d25294d9a 100644 (file)
@@ -6374,13 +6374,14 @@ void ufshcd_schedule_eh_work(struct ufs_hba *hba)
        }
 }
 
-static void ufshcd_force_error_recovery(struct ufs_hba *hba)
+void ufshcd_force_error_recovery(struct ufs_hba *hba)
 {
        spin_lock_irq(hba->host->host_lock);
        hba->force_reset = true;
        ufshcd_schedule_eh_work(hba);
        spin_unlock_irq(hba->host->host_lock);
 }
+EXPORT_SYMBOL_GPL(ufshcd_force_error_recovery);
 
 static void ufshcd_clk_scaling_allow(struct ufs_hba *hba, bool allow)
 {
index 5cb3af17aec47c5b63bae322ddb70e37d7839846..7c13bce03694ff21f1b269269a9b3d7d27b69316 100644 (file)
@@ -1483,7 +1483,7 @@ static void ufs_mtk_dev_vreg_set_lpm(struct ufs_hba *hba, bool lpm)
        }
 }
 
-static void ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
+static int ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
 {
        int ret;
 
@@ -1494,8 +1494,16 @@ static void ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
        ufs_mtk_wait_idle_state(hba, 5);
 
        ret = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100);
-       if (ret)
+       if (ret) {
                dev_warn(hba->dev, "exit h8 state fail, ret=%d\n", ret);
+
+               ufshcd_force_error_recovery(hba);
+
+               /* trigger error handler and break suspend */
+               ret = -EBUSY;
+       }
+
+       return ret;
 }
 
 static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
@@ -1506,7 +1514,7 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
 
        if (status == PRE_CHANGE) {
                if (ufshcd_is_auto_hibern8_supported(hba))
-                       ufs_mtk_auto_hibern8_disable(hba);
+                       return ufs_mtk_auto_hibern8_disable(hba);
                return 0;
        }
 
index 47cba116f87b81732e4decc4c15f9463fa0b3240..52ea0ab437fe0a19e58dfcb54543a10b0c7f5b0e 100644 (file)
@@ -1487,5 +1487,6 @@ int __ufshcd_write_ee_control(struct ufs_hba *hba, u32 ee_ctrl_mask);
 int ufshcd_write_ee_control(struct ufs_hba *hba);
 int ufshcd_update_ee_control(struct ufs_hba *hba, u16 *mask,
                             const u16 *other_mask, u16 set, u16 clr);
+void ufshcd_force_error_recovery(struct ufs_hba *hba);
 
 #endif /* End of Header */