From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796383548; b=Rheyvp06WEhwnGEAtncHailKh47PocRCOxa4uB/ztgpRZml3Q3HTNm6ksWKjIa4UXQEY Z3EADtu/2p6Br+WHxoQmDVOV/BlZuuLA8yuL/4NPNKnO0IJU9hG7b1Z9euh9Wup+8FEcl AMY3lxurUzY03YSE7aHujIZuGs4ASQHm6Bk8k3quAAXTrI1OECLwNp5mYm7YtIcAG5lpR OAUPZAEJVDn8BBmSdARLxepLz0OJ/6VtGcIEGLlwT9vJSccFWsJgIXOeDu5KBddbuEfUH eK7D3qorLbY6xT35SXf4KFJ3k3Cn7wpDvK7Zkl9jp/4QSGC/nSx9Uv+JUtiQBrHHi+A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383548; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=tmD6jL75uGOpqXuY1GJeMFh407rSodU/h5oPAG4/Pak=; b=0KaDPojuPxekg/uOBfU700OVmCjRZ7FoTnwxxIvF8lcAWGX8G6oF1ngAxZkL1TPRRCQp KLb1fLNpsR01kP5kmlM/qPQ6msWSzN2kQZXnNYKqBl9AczD2SzFPnp3i3oV5x0WA+JBIe s1aTWYGAEw4YxV95yvUDTqHfhG5R9oyCag7EB8lvayFBplHhQ/aNmUGWhWMx5AoAKWg69 rJeCSIhqea5Xw0j/+r48yPsD7fw7GKIt1YNgyVZVt9kaS4uhwvmqMjBBO2krXlXIv0hIT zVhqujjLIkBHu1zxWF/OPOsaYpLtBZshi4qhMJqdtZF8ukDbRgH5jwC/ozC0W/elmaw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=aMUTkUwq; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFFD9606A32C; Fri, 4 Dec 2026 11:25:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=aMUTkUwq Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B4EC1F000C2; Fri, 4 Dec 2026 11:25:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383548; bh=tmD6jL75uGOpqXuY1GJeMFh407rSodU/h5oPAG4/Pak=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aMUTkUwqWpHLNOMBDsCbwqF+ZBjBqpMizbrxo7TNfYV+m3TTy6tmVXs3Wmj3P1Ggi nXb98N1Qq1af3etTMn5S9RaxZ5FLsCN/lG6C9vqp+3632aF22mzutdjz2R7+c0ueSK lZI9EpFC1FH1GRc1jzVffKboD0ErC5kbO3hFICcs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Peter Wang , Xiangwu Lai , "Martin K. Petersen (Oracle)" , Sasha Levin Subject: [PATCH 6.12 231/555] scsi: ufs-mediatek: Restore the M-PHY power state when va09 disable fails Date: Fri, 4 Dec 2026 19:04:34 +0900 Message-ID: <20261204100618.027507201@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xiangwu Lai [ Upstream commit 71b5da0b45fb83b590f1ec3df5361c7754b0e113 ] 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 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 Reviewed-by: Peter Wang Link: https://patch.msgid.link/20261119071611.117-3-laixiangwu@cmss.chinamobile.com Signed-off-by: Martin K. Petersen (Oracle) Signed-off-by: Sasha Levin --- drivers/ufs/host/ufs-mediatek.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c index e4156238f51d9..1053166105139 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -476,6 +476,16 @@ static int ufs_mtk_mphy_power_on(struct ufs_hba *hba, bool on) 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); + } } } out: -- 2.53.0