From: sashiko-bot@kernel.org
To: "Xiangwu Lai" <laixiangwu@cmss.chinamobile.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2 2/2] scsi: ufs-mediatek: keep mphy state in sync when va09 disable fails
Date: Wed, 18 Nov 2026 03:37:50 +0000 [thread overview]
Message-ID: <sashiko-outbox-220026@kernel.org> (raw)
In-Reply-To: <20261118032015.974-3-laixiangwu@cmss.chinamobile.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] scsi: ufs-mediatek: reg_va09 enable_count leak in
ufs_mtk_mphy_power_on()
- [Medium] scsi: ufs-mediatek: M-PHY left off during ufs_mtk_suspend()
error recovery
--
commit 228f00d5e6d65bb4a18b8cbe9dee1c4060e6f74c
Author: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
scsi: ufs-mediatek: keep mphy state in sync when va09 disable fails
This commit sets host->mphy_powered_on to false unconditionally in the
power-off branch of ufs_mtk_mphy_power_on() so that a subsequent power-on
attempt does not bail out early if disabling the va09 regulator failed.
Link: https://lore.kernel.org/r/sashiko-outbox-219916@kernel.org
> diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
> index 4895fe3b2a99e..b1ad983f80ae9 100644
> --- a/drivers/ufs/host/ufs-mediatek.c
> +++ b/drivers/ufs/host/ufs-mediatek.c
> @@ -543,6 +543,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;
[Severity: Medium]
Does setting host->mphy_powered_on = false when regulator_disable() fails
leak an enable_count reference on host->reg_va09?
When _regulator_disable() fails in _regulator_do_disable(), it returns the
error before calling _regulator_handle_consumer_disable(), so
host->reg_va09->enable_count remains 1. With host->mphy_powered_on cleared,
the next ufs_mtk_mphy_power_on(hba, true) call invokes
regulator_enable(host->reg_va09) again and increments enable_count to 2.
Subsequent power-off calls only decrement enable_count once from 2 to 1,
preventing VA09 from ever being physically disabled and triggering
WARN_ON(regulator->enable_count) in _regulator_put() on driver unbind.
[Severity: Medium]
Does returning the regulator_disable() error with the M-PHY powered off
break error recovery in ufs_mtk_suspend()?
When ufs_mtk_mphy_power_on(hba, false) returns an error to
ufs_mtk_suspend(), ufs_mtk_suspend() jumps to fail, calls
ufshcd_set_link_off(hba), and returns -EAGAIN to __ufshcd_wl_suspend():
drivers/ufs/core/ufshcd.c:__ufshcd_wl_suspend() {
...
ret = ufshcd_vops_suspend(hba, pm_op, POST_CHANGE);
if (ret)
goto set_link_active;
goto out;
set_link_active:
...
if (ufshcd_is_link_hibern8(hba) && !ufshcd_uic_hibern8_exit(hba))
ufshcd_set_link_active(hba);
else if (ufshcd_is_link_off(hba))
ufshcd_host_reset_and_restore(hba);
...
}
__ufshcd_wl_suspend() aborts the suspend and immediately runs
ufshcd_host_reset_and_restore(hba) without calling ufs_mtk_resume().
Because neither ufshcd_host_reset_and_restore() nor its vops callbacks call
ufs_mtk_mphy_power_on(hba, true), host reset and link startup run while the
M-PHY and VA09 power control are still off.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118032015.974-1-laixiangwu@cmss.chinamobile.com?part=2
prev parent reply other threads:[~2026-11-18 3:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 3:20 [PATCH v2 0/2] scsi: ufs-mediatek: fix va09 regulator lifecycle Xiangwu Lai
2026-11-18 3:20 ` [PATCH v2 1/2] scsi: ufs-mediatek: use devm_regulator_get() for the va09 regulator Xiangwu Lai
2026-11-18 3:20 ` [PATCH v2 2/2] scsi: ufs-mediatek: keep mphy state in sync when va09 disable fails Xiangwu Lai
2026-11-18 3:37 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-220026@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=laixiangwu@cmss.chinamobile.com \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox