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=1796389178; b=0s1tydSy3wUdY/LpDm4KX+ctN27pw02qZ1dEz/AaVaVl5HUjdjwIrhzoLWbDvCqY8d6M K+OWME+R0w/VK7bjdnazXPuSEVCN/xdP02rKy9a1fIH5BteC2xtaLjQwLox0Mq2ENAik6 F0YbhIthq2eLSCRCDYBxIbSXgCwPbKISyseA8uJaWiWV/ahUuG9CgSDZxix8yqwdvj+cy WrpW6jo+7bzzxavkE2kr2tISPw4sr1a5U7fxLuv8+rRSUzNacQBu2de0TlaG01HdqsrAS aVKmGcoexdmTgSecPBgoWe1OfkGoO3q81BOQG+vJHwM89uLmEWQRnVxarMHjd7UGgtQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389178; 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=/9isLbaKd65/NyOfLG64RwkeuM21khDx70onX2p00Ok=; b=wPG/unbFBu0zFLsk6ejlUX4/AVSbkXvw+rq6/h/XthqSX1LnqJT0XQWczX4v52RV1+gq +RSxtvSoCfEqKL/+FSn6AzutVq9FctwMFNGFhJHW9WlaKF+mlOvlkdX+HpzJ0Q8LJP2hn t1oXQrRe8ppY6ifok5dHWhX+GDY7ZTMgmC00urRToko9Jh86O6CYTgrgqrGXocCIWcHeV lVMpty6mBTY0MfG6dMXuVlneNquy6THVEf2+wK8FsjgT+MVJki5pemqVzbE/7DbNrm5Ay qjTYz63MZcedZSszdgGEJgab3PTH9liGDZOMwAPoZw9nF9l4JBB9WURlFMZJbmfgQcw== 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=FYm5xDNr; 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 31AF3606A32C; Fri, 4 Dec 2026 12:59:38 +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=FYm5xDNr Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43D971F00931; Fri, 4 Dec 2026 12:59:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389177; bh=/9isLbaKd65/NyOfLG64RwkeuM21khDx70onX2p00Ok=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FYm5xDNrYojfqB3E1YjOo2NoG7ghm1qnAqbDMIloWuvCq5DLiXWI/req/ZrBO3T7I 0fbTNLrLwjPHMgZ6Y/K1/R7jF4wSbpis5PTFK5PBR/Cf4bNCBWZtzwaOXZK4pvfGPB yFGhZcFOu4O1FoC/B7K8+ShNvbTinK0B3g4eX2SI= 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.1 0842/1059] scsi: ufs-mediatek: Restore the M-PHY power state when va09 disable fails Date: Fri, 4 Dec 2026 19:06:13 +0900 Message-ID: <20261204100705.836238120@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-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 e4fc86ed537ec..9a02a42342f93 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -441,6 +441,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