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=1796381911; b=Jy97c7sojWek1L4BoPmhDu+gwsmOA5tqWhrVPhItANipkJwgJZcGPGCCzmGAJlBpONBV zl7WfbWFVYua816zP7h3ntaNZsXzcMl83pLEOyAYnOTKZO6E7POVGVM+MkjRZypOk3jwP S2JmpCBP2O18psCTdhfvh6XkNJBCoc0oTyChUUDFvZEUGIzMJLD8qAYJXcfvBxI38eAHT OwuSJ0d9RzFXpD8oECuMrjCoDq7yL/lv0U2/SLwWxAZFSImGjaniiJwn3JlxyzpUBW8CA T9r5q72ttLMJST2AjhbNSYvV3No2J/7YQo2jGvj3lIx7L1bwtrrY2HeTufuuO6KXqLA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381911; 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=JICi02KhRSpPNpWaJJZl81PEjq2I9usJI/CxUWtOI8A=; b=nMNTvDd5XW+LfzjKzcoJnrvdXqclJE+fnPzNr+JgDaDoMOmlXW1pntKaEwhKGpv1HiYd D3mDQEAr2/0DTXRbvkdWAKc1QuGUO3IV72YvIDPOUM3IzCcOGlqU09IVudlEA24z3qkbz es72hIABtn6BZBn0lL5x786soWnxPEmsCaQiS24leMyA6G+IwZbRYqLZ38UboM/bcFaqt +6XpiJvAow6qBin4qdpErdC4QXnOSksGILwSEHHWEqyk9yEN2bgsBo16SMzapReKgiq39 M7BTJsOEuw18Cxx0tFJYrrwpnFqlRetJsmorKlBbJhBmHng7ytcUU8IgliO3HLeXOsQ== 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="lQE8b/Hw"; 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 4F6E6606A32D; Fri, 4 Dec 2026 10:58:31 +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=lQE8b/Hw Received: by smtp.kernel.org (Postfix) with ESMTPSA id C146C1F000CE; Fri, 4 Dec 2026 10:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381911; bh=JICi02KhRSpPNpWaJJZl81PEjq2I9usJI/CxUWtOI8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lQE8b/HwIQBzB5hjRbPktqpZ3FylRgTfUC01FQr3wEi5ymZzRDKCZvZ8UpGfI0aCw Kpiy2A7SAdZosMO3oxNLIuphHXFrFEFo6Us/yBUHL+AjL8juimaSJZRKCuyD2fs4J1 JxacNpO8O2ktTOC8/Ep0sexecwvkHdQ///ErzYR8= 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.18 224/703] scsi: ufs-mediatek: Restore the M-PHY power state when va09 disable fails Date: Fri, 4 Dec 2026 19:02:03 +0900 Message-ID: <20261204100633.789838468@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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 3c63adca561d2..d465567db433e 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -508,6 +508,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