From: Peter Wang <peter.wang@mediatek.com>
To: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>,
<chaotian.jing@mediatek.com>
Cc: <chu.stanley@gmail.com>, <alim.akhtar@samsung.com>,
<bvanassche@acm.org>, <sashiko-bot@kernel.org>,
<linux-scsi@vger.kernel.org>,
<linux-mediatek@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 2/2] scsi: ufs-mediatek: restore the M-PHY power state when va09 disable fails
Date: Thu, 19 Nov 2026 16:36:27 +0800 [thread overview]
Message-ID: <2a83ef7d6fd36085ff4140a894f51e0a9c50caac.camel@mediatek.com> (raw)
In-Reply-To: <20261119071611.117-3-laixiangwu@cmss.chinamobile.com>
On Thu, 2026-11-19 at 15:16 +0800, Xiangwu Lai wrote:
> In ufs_mtk_mphy_power_on(), the power-off path tears the M-PHY down
> in
> two steps before regulator_disable() is called: phy_power_off() puts
> the PHY PLL and its clocks down, and ufs_mtk_va09_pwr_ctrl() asks the
> firmware to drop the VA09 supply. If regulator_disable() then fails,
> the M-PHY stays physically off while host->mphy_powered_on is left
> set, so the next power-on attempt bails out through the
> !(on ^ host->mphy_powered_on) check and never powers the M-PHY back
> up, leaving the UFS host with an unpowered PHY (I/O timeouts,
> controller lockups).
>
> Simply forcing mphy_powered_on to false would trade this for two more
> problems. First, the regulator core drops the consumer enable count
> only after a successful disable, so the count stays at 1, the next
> power-on raises it to 2 and it never returns to zero: va09 is then
> never physically disabled and the devm-acquired regulator would hit
> WARN_ON(enable_count) again on release. Second, when the power-off
> fails during ufs_mtk_suspend(), the error recovery in
> __ufshcd_wl_suspend() runs ufshcd_host_reset_and_restore() without
> powering the M-PHY back on, which would run against an unpowered PHY.
> (Both points were raised by the Sashiko AI review of v2.)
>
> Since the va09 regulator stays enabled when its disable fails,
> restore
> the M-PHY power state instead: power the PHY back on through
> ufs_mtk_va09_pwr_ctrl() and phy_power_on() and leave mphy_powered_on
> set. The next power-off attempt then retries the full sequence and
> the enable count stays balanced.
>
> Found by code inspection while reviewing the va09 error paths of the
> driver; the failure has not been observed on real hardware.
>
> Suggested-by: Peter Wang <peter.wang@mediatek.com>
> Link: https://lore.kernel.org/r/sashiko-outbox-220026@kernel.org
> Fixes: cf137b3ea49a ("scsi: ufs-mediatek: Support VA09 regulator
> operations")
> Signed-off-by: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
> ---
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
prev parent reply other threads:[~2026-11-19 8:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 7:16 [PATCH v3 0/2] scsi: ufs-mediatek: fix va09 regulator lifecycle Xiangwu Lai
2026-11-19 7:16 ` [PATCH v3 1/2] scsi: ufs-mediatek: use devm_regulator_get() for the va09 regulator Xiangwu Lai
2026-11-19 7:16 ` [PATCH v3 2/2] scsi: ufs-mediatek: restore the M-PHY power state when va09 disable fails Xiangwu Lai
2026-11-19 8:36 ` Peter Wang [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=2a83ef7d6fd36085ff4140a894f51e0a9c50caac.camel@mediatek.com \
--to=peter.wang@mediatek.com \
--cc=alim.akhtar@samsung.com \
--cc=bvanassche@acm.org \
--cc=chaotian.jing@mediatek.com \
--cc=chu.stanley@gmail.com \
--cc=laixiangwu@cmss.chinamobile.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-bot@kernel.org \
/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
all inboxes | Powered by JetHome®