]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: ufs: host: mediatek: Adjust clock scaling for PM flow
authorPeter Wang <peter.wang@mediatek.com>
Wed, 24 Sep 2025 09:43:24 +0000 (17:43 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 22 Oct 2025 01:36:45 +0000 (21:36 -0400)
Adjust clock scaling during suspend and resume in the UFS Mediatek
driver. Ensure that the clock scales down during suspend if it was
scaled up, and scales up again after resume.  This adjustment maintains
proper power management.

Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Acked-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>
Link: https://patch.msgid.link/20250924094527.2992256-3-peter.wang@mediatek.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ufs/host/ufs-mediatek.c

index 009031fee7449964e85312cd5174de8dd6ace075..0622b7b32e5111224e66138c96c908b3551d2dc5 100644 (file)
@@ -1774,9 +1774,11 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
 
        ufs_mtk_sram_pwr_ctrl(false, res);
 
-       /* Release pm_qos if in scale-up mode during suspend */
-       if (ufshcd_is_clkscaling_supported(hba) && (host->clk_scale_up))
+       /* Release pm_qos/clk if in scale-up mode during suspend */
+       if (ufshcd_is_clkscaling_supported(hba) && (host->clk_scale_up)) {
                ufshcd_pm_qos_update(hba, false);
+               _ufs_mtk_clk_scale(hba, false);
+       }
 
        return 0;
 fail:
@@ -1804,9 +1806,11 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
        if (err)
                goto fail;
 
-       /* Request pm_qos if in scale-up mode after resume */
-       if (ufshcd_is_clkscaling_supported(hba) && (host->clk_scale_up))
+       /* Request pm_qos/clk if in scale-up mode after resume */
+       if (ufshcd_is_clkscaling_supported(hba) && (host->clk_scale_up)) {
                ufshcd_pm_qos_update(hba, true);
+               _ufs_mtk_clk_scale(hba, true);
+       }
 
        if (ufshcd_is_link_hibern8(hba)) {
                err = ufs_mtk_link_set_hpm(hba);