]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: ufs: host: mediatek: Change ref-clk timeout policy
authorPeter Wang <peter.wang@mediatek.com>
Tue, 22 Jul 2025 03:07:18 +0000 (11:07 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 25 Jul 2025 02:20:09 +0000 (22:20 -0400)
Update the timeout policy for ref-clk control.

 - If a clock-on operation times out, it is assumed that the clock is
   off. The system will notify TFA to perform clock-off settings.

 - If a clock-off operation times out, it is assumed that the clock will
   eventually turn off. The 'ref_clk_enabled' flag is set directly.

Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Link: https://lore.kernel.org/r/20250722030841.1998783-4-peter.wang@mediatek.com
Reviewed-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ufs/host/ufs-mediatek.c

index 90351fff501cf2cf9da4b8a461f559206ae6d3d8..b30203d83ef102b60aa7d3046c68efd4c1b9deb9 100644 (file)
@@ -351,7 +351,16 @@ static int ufs_mtk_setup_ref_clk(struct ufs_hba *hba, bool on)
 
        dev_err(hba->dev, "missing ack of refclk req, reg: 0x%x\n", value);
 
-       ufs_mtk_ref_clk_notify(host->ref_clk_enabled, POST_CHANGE, res);
+       /*
+        * If clock on timeout, assume clock is off, notify tfa do clock
+        * off setting.(keep DIFN disable, release resource)
+        * If clock off timeout, assume clock will off finally,
+        * set ref_clk_enabled directly.(keep DIFN disable, keep resource)
+        */
+       if (on)
+               ufs_mtk_ref_clk_notify(false, POST_CHANGE, res);
+       else
+               host->ref_clk_enabled = false;
 
        return -ETIMEDOUT;