Re: [PATCH v2 2/2] scsi: ufs-mediatek: keep mphy state in sync when va09 disable fails
From: Xiangwu Lai
Date: Thu Nov 19 2026 - 02:24:59 EST
Hi Peter,
thanks for looking at both patches, and for the Reviewed-by on 1/2.
For the record, this replies to "[PATCH v2 2/2] scsi: ufs-mediatek:
keep mphy state in sync when va09 disable fails":
https://lore.kernel.org/all/20261118032015.974-3-laixiangwu@xxxxxxxxxxxxxxxxxxxx/
On Thu, 19 Nov 2026 13:33:01 +0800, Peter Wang wrote:
> If the VA09 regulator_disable fails, could we just restore
> the PHY power state?
Yes, agreed, that is the better fix. Forcing the state to false
(v2's approach) keeps the enable count of the va09 regulator stuck at
1 - the regulator core drops the consumer count only after a
successful disable - so the next power-on would raise it to 2 and it
never returns to zero: va09 would then never be physically disabled
and the devm-acquired regulator of patch 1/2 would hit
WARN_ON(enable_count) again on release.
Restoring the M-PHY also keeps the suspend error path safe: when the
power-off fails inside ufs_mtk_suspend(), the link is set off and
-EAGAIN is returned, and __ufshcd_wl_suspend() then runs
ufshcd_host_reset_and_restore() without powering the M-PHY back on -
with the state forced to false, that host reset would run against an
unpowered M-PHY. (The Sashiko AI review of v2 raised both points:
https://lore.kernel.org/all/sashiko-outbox-220026@xxxxxxxxxx/.)
So v3 drops the forced state clear and restores the power state
instead:
} else {
phy_power_off(mphy);
if (ufs_mtk_is_va09_supported(hba)) {
ufs_mtk_va09_pwr_ctrl(res, 0);
ret = regulator_disable(host->reg_va09);
if (ret) {
/*
* The va09 regulator stays enabled, so
* bring the M-PHY back up to keep the
* software state in sync with the
* hardware.
*/
ufs_mtk_va09_pwr_ctrl(res, 1);
phy_power_on(mphy);
}
}
}
mphy_powered_on is then left set, and the next power-off attempt
retries the full sequence, so the enable count stays balanced in the
end.
v3 is out as a new thread, with this change in 2/2 and your
Reviewed-by kept on the unchanged 1/2:
https://lore.kernel.org/all/20261119071611.117-1-laixiangwu@xxxxxxxxxxxxxxxxxxxx/
Best regards,
Xiangwu Lai