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=1796386346; b=tYIQeQXJ0J/TCyeczh6ft8ZJLTT0xAO8VYKBIqUOktiVmNGhstTLmdOzKe6AxVCfIZm4 C4mK69VuNVE+RebcjceKHxunaK9gEMC3KiYzaj/bQ6q8bQGSGvb2X3rGpdmWVkHi05K0W sRx5isglpAg7SwZNsoxypxnF4Dnoi3FtyNk34crrZoZ9IaXYnQOS8KdUHVrHbrOM0EQK1 lvwFonmHCW8scZm6A15T/ijktNS0JqrMb2cCdk1tUbO/5bkmZ3ls2JhyA9Lf9sI3eADBz n4qxGckLm/YiO5neAI6mgnPK6viDWChugUa3dCq0HggXqSd4QPX3f6VGG6LVtESwHZA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386346; 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=UliMQEjPeAOiqwUX4FQzO9x0EaB9u64brdbax6SM55A=; b=0Za+z+SbyKlh1jawpry/jE30V7CMA0EDsKhicmXIq5IvXGKlelFSAKN2iZqli8mMCl90 m6mUuwYWU8kvakiCy8Ez1k1C9StV607sKc3DytoMQ+5g3pplC/SA0WEJPo9X+Hueq98Jn eGKaiYVSvFArwWOsSwoom1C4CNR79CmvDyUCz6GwG/xeNioCsP3z/VDhkeRYRnUzog3oi Ids0h+w+UR1TYdVdFvGqPrI1CveM8LKqJxSyXDQfSIO6YtLTAq0sJ7+esOuU0T7GvEPmx sa0oW+zCe4TJPY4PCkQ+lD0I4pUoNAG0ZOTVyDA/3Exd9Z3XymeTZ0CLbOsgKLE/EAw== 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=l4hbbLNJ; 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 2C17B606A322; Fri, 4 Dec 2026 12:12:26 +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=l4hbbLNJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48D8C1F00939; Fri, 4 Dec 2026 12:12:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386345; bh=UliMQEjPeAOiqwUX4FQzO9x0EaB9u64brdbax6SM55A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=l4hbbLNJfmjnmTiWuUKI6A2e95ql5Dd3dlnaCHxSRHX/aPmq45yXTR4jbKHeJvr7I XgT0TKAaCcSMpeLUIukQCtXDI+NDNK+4rtqnvdl7PNeJTsGM+NzZPzRir4u33hRX3v KKoc+cJOMnYQaTMwtSvFm6funj5qmgT3bK/74T8M= 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.6 0923/1167] scsi: ufs-mediatek: Restore the M-PHY power state when va09 disable fails Date: Fri, 4 Dec 2026 19:05:50 +0900 Message-ID: <20261204100726.238613766@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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 606e90ce8ca70..e7f5990ac70cc 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -445,6 +445,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