[PATCH v2 2/2] scsi: ufs-mediatek: keep mphy state in sync when va09 disable fails

Xiangwu Lai laixiangwu at cmss.chinamobile.com
Tue Nov 17 19:20:15 PST 2026


In ufs_mtk_mphy_power_on(), the power-off path calls phy_power_off()
before disabling the va09 regulator.  If regulator_disable() fails,
the error is returned while host->mphy_powered_on is left set,
although the M-PHY is physically powered off already.  The next call
with on = true then bails out through the !(on ^ host->mphy_powered_on)
check without powering the M-PHY back on, leaving the UFS link dead
(I/O timeouts, controller lockups).

The M-PHY is off regardless of the va09 disable result, so update the
state flag in the power-off path and let the next power-on retry the
whole sequence.

Found by code inspection while reviewing the va09 error paths of the
driver; the failure has not been observed on real hardware.

Link: https://lore.kernel.org/r/sashiko-outbox-219916@kernel.org
Fixes: cf137b3ea49a ("scsi: ufs-mediatek: Support VA09 regulator operations")
Signed-off-by: Xiangwu Lai <laixiangwu at cmss.chinamobile.com>
---
 drivers/ufs/host/ufs-mediatek.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index ebbc017d0..8d4b84d58 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -542,6 +542,14 @@ static int ufs_mtk_mphy_power_on(struct ufs_hba *hba, bool on)
 			ufs_mtk_va09_pwr_ctrl(res, 0);
 			ret = regulator_disable(host->reg_va09);
 		}
+		/*
+		 * The M-PHY is off regardless of the va09 result, so keep
+		 * the state in sync with the hardware.  Otherwise the next
+		 * power-on bails out through the
+		 * !(on ^ host->mphy_powered_on) check without powering the
+		 * M-PHY back on.
+		 */
+		host->mphy_powered_on = false;
 	}
 out:
 	if (ret) {
-- 
2.50.1.windows.1






More information about the Linux-mediatek mailing list