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=1796256858; b=ZJLv3sqiwKfKwpfgVHkeQ4YkKXpWYS7FmKzBPUOaN5JoUuxo+9wO/B0A1ml17XCd1skx p0G04/w+BYZP78YuOsTwNrkhoxjNTNM27eJgstJwL3IIlSPuIRN64S+A+vLtfViZBMTHU UJpzcS42HjFmON4ricIFY6rc5tutIr2vtAuvsIg0zWvcdFwwq7oGK6dZca5Du3D48szEZ 2yzTzZBam4BL+8KwXJE03kzoOn27FqJMEHYeTfBwHO0OitO2s6YlPbnxlWCpV0D/0QxWj UBSBfoQ+KBG3/1Izu/l6Df/0WT1SOVH/VMERLIrd5ComMMG19Dqyu5KdXgGm/zbiC+A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796256858; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=l1XPa1qseJMFOpSLytY37zicKYizToqJLr6a0B5CNuY=; b=uDclgTT8Ebd+asEDaVNJdAUPwH1AGsPQmQ69dtjUpOO+HjiWhVhlsrzzcR3Q4n/e2ZbI 1WYtzZWnqfRsvpK6fy+iAdjN9cl7ZUYh366J/q3h9YngXE1JaAM3BCa7VCOmo+OqBRxBU u0bfvmky/PsYk3O/06EwYCfNFaTb4oehbJmo6MhcnD8Nt7t8uYUaoCp5nfxHTDjVLTah/ cvgdcoyup5QvvTp1ughcHGLZbK/KDRln7FOhdQDpItNvR6eL7ZPImy1pU2V7ipI/n7oNp w+MmkkfqkIi0ggDkxQ7j2eKIJrBZNzraIgHbdoRLkAhq70L2FAT1xr85mLhHCXDSDzg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TxoxPzEF; 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 B5D00606A322 for ; Thu, 3 Dec 2026 00:14:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TxoxPzEF Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E3DE1F000C1; Thu, 3 Dec 2026 00:14:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796256858; bh=l1XPa1qseJMFOpSLytY37zicKYizToqJLr6a0B5CNuY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=TxoxPzEFIT30hVMZBwxP/oQe9SKwUVEGzdq8jr4yi5olf5FNTzTiBqxw9PzkQfWO7 KX3l9x4wzUkHdxV0UGawFg1EEzjgi9M7kvqsA120TgKVlTRLF6BPUao0kEpoP3EZ97 g0ouFb741Tz7nKArEDl9Hl4rlxRvYPTt624mYe6mx1heagxtnnbzCQPfsmkHWIoedJ hSIPgquJaPClD7clTd6eiDJcBAzwKEAO68cE1PVvEOOa0cMhi4aRJm5NMd3QeI8tpg RPb5urgzAYg36yGX8UfYb6KN4bh6MhDCR4g5efJYrCNSXu3ptoUl2fbhPPDs2S7Qyv Q2MEzKyoVrJyw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 3/3] scsi: ufs: core: Enter hibern8 before ufshcd_suspend() gates the clocks Reply-To: sashiko-reviews@lists.linux.dev To: "Vladimir Zapolskiy" Cc: linux-scsi@vger.kernel.org In-Reply-To: <20261202235113.1632498-4-vladimir.zapolskiy@linaro.org> References: <20261202235113.1632498-1-vladimir.zapolskiy@linaro.org> <20261202235113.1632498-4-vladimir.zapolskiy@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 00:14:17 +0000 X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [High] scsi: ufs: core: link state mismatch between vops suspend and resume - [High] scsi: ufs: core: broken link state on hibern8 failure in ufshcd_suspend() - [Medium] scsi: ufs: core: link state mismatch in ufshcd_rpm_ok_for_spm() - [Medium] scsi: ufs: core: missing hibern8 rollback in ufshcd_suspend() error path - [Low] scsi: ufs: core: Fixes tag cites 57d104c153d3 instead of 1ab27c9cf8b6 -- commit 6a05a39d71fec3d3537f39c83c27329442fd5d45 Author: Vladimir Zapolskiy > scsi: ufs: core: Enter hibern8 before ufshcd_suspend() gates the clocks > > Hosts with UFSHCD_CAP_HIBERN8_WITH_CLK_GATING may gate their clocks only > with the link in hibern8, and if ufshcd_gate_work() complies to it, > ufshcd_suspend() does not, because with rpm_lvl 0 or 2 it turns the > clocks off under an active link. As a result no request then completes > after the next resume until the host is reset, and every access after > a runtime suspend stalls for 8 to 11 seconds. > > Put an active link into hibern8 first; the W-LUN resume exits it again. > If that fails, return -EBUSY to keep the host staying active without > a runtime PM error. > > Fixes: 57d104c153d3 ("ufs: add UFS power management support") > Signed-off-by: Vladimir Zapolskiy [Severity: Low] 57d104c153d3 ("ufs: add UFS power management support") predates UFS clock gating and UFSHCD_CAP_HIBERN8_WITH_CLK_GATING. Should the Fixes: tag cite 1ab27c9cf8b6 ("ufs: Add support for clock gating") instead? > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c > index eedd74d7dbddb..b96f8a5592b17 100644 > --- a/drivers/ufs/core/ufshcd.c > +++ b/drivers/ufs/core/ufshcd.c > @@ -10809,6 +10809,13 @@ static int ufshcd_suspend(struct ufs_hba *hba) > =20 > if (!hba->is_powered) > return 0; > + > + if (ufshcd_can_hibern8_during_gating(hba) && > + ufshcd_is_link_active(hba)) { > + if (ufshcd_uic_hibern8_enter(hba)) > + return -EBUSY; [Severity: High] Can a failure in ufshcd_uic_hibern8_enter() here leave the link in UIC_LINK_BROKEN_STATE and cause the next W-LUN resume to fail? Unlike __ufshcd_wl_suspend(), ufshcd_suspend() runs after the W-LUN has suspended and cleared hba->pm_op_in_progress to false. When ufshcd_uic_hibern8_enter() fails with !hba->pm_op_in_progress, ufshcd_uic_pwr_ctrl() marks the link broken and schedules fatal error handling: drivers/ufs/core/ufshcd.c:ufshcd_uic_pwr_ctrl() { ... if (ret && !hba->pm_op_in_progress) { ufshcd_set_link_broken(hba); ufshcd_schedule_eh_work(hba); } ... } When __ufshcd_wl_resume() subsequently runs (either during system suspend rollback while eh_work is blocked on hba->host_sem, or from ufshcd_err_handling_prepare() -> ufshcd_rpm_get_sync() after runtime suspend returns -EBUSY), it only checks ufshcd_is_link_hibern8() and ufshcd_is_link_off(), skipping link recovery for UIC_LINK_BROKEN_STATE. At PM level 2, __ufshcd_wl_resume() then calls ufshcd_set_dev_pwr_mode() while hba->ufshcd_state is UFSHCD_STATE_EH_SCHEDULED_FATAL, and ufshcd_queuecommand() immediately fails the START_STOP_UNIT command with DID_BAD_TARGET. > + ufshcd_set_link_hibern8(hba); > + } [Severity: High] Does transitioning the link to Hibern8 in ufshcd_suspend() break link state symmetry between ufshcd_vops_suspend() and ufshcd_vops_resume()? At PM levels 0 and 2, __ufshcd_wl_suspend() runs ufshcd_vops_suspend() while hba->uic_link_state is still UIC_LINK_ACTIVE_STATE, before ufshcd_suspend() enters Hibern8 and sets UIC_LINK_HIBERN8_STATE. On resume, __ufshcd_wl_resume() runs ufshcd_vops_resume() before exiting Hibern8, so vops->resume() sees UIC_LINK_HIBERN8_STATE. In drivers/ufs/host/ufs-exynos.c, exynos_ufs_suspend() and exynos_ufs_resume() both gate PHY power on !ufshcd_is_link_active(hba): drivers/ufs/host/ufs-exynos.c:exynos_ufs_suspend() { ... if (!ufshcd_is_link_active(hba)) phy_power_off(ufs->phy); return 0; } drivers/ufs/host/ufs-exynos.c:exynos_ufs_resume() { ... if (!ufshcd_is_link_active(hba)) phy_power_on(ufs->phy); return 0; } exynos_ufs_suspend() skips phy_power_off(), while exynos_ufs_resume() calls phy_power_on(), leaking a ufs->phy->power_count reference on every suspend/resume cycle. ufs_mtk_suspend() / ufs_mtk_resume() and ufs_qcom_suspend() have similar checks on ufshcd_is_link_hibern8() and ufshcd_is_link_active(). [Severity: Medium] Does setting hba->uic_link_state to UIC_LINK_HIBERN8_STATE at rpm_lvl 0 or 2 also break ufshcd_rpm_ok_for_spm() during system suspend preparation? drivers/ufs/core/ufshcd.c:ufshcd_rpm_ok_for_spm() { ... link_state =3D ufs_get_pm_lvl_to_link_pwr_state(hba->spm_lvl); res =3D pm_runtime_suspended(dev) && hba->curr_dev_pwr_mode =3D=3D dev_pwr_mode && hba->uic_link_state =3D=3D link_state && !hba->dev_info.b_rpm_dev_flush_capable; ... } For PM levels 0 and 2, ufs_get_pm_lvl_to_link_pwr_state() returns UIC_LINK_ACTIVE_STATE. If spm_lvl is 0 or 2, hba->uic_link_state is now UIC_LINK_HIBERN8_STATE, so ufshcd_rpm_ok_for_spm() returns false and __ufshcd_suspend_prepare() forces a runtime resume just to re-suspend into the same state. Conversely, if spm_lvl is 1 or 3, hba->uic_link_state now matches UIC_LINK_HIBERN8_STATE and ufshcd_rpm_ok_for_spm() returns true, skipping system suspend even though __ufshcd_wl_suspend() and ufshcd_vops_suspend() only ran the active-link path. > /* > * Disable the host irq as host controller as there won't be any > * host controller transaction expected till resume. > */ > ufshcd_disable_irq(hba); > ret =3D ufshcd_setup_clocks(hba, false); > if (ret) { > ufshcd_enable_irq(hba); > goto out; > } [Severity: Medium] If ufshcd_setup_clocks(hba, false) fails here, does ufshcd_suspend() return an error while leaving the link in Hibern8 and hba->uic_link_state set to UIC_LINK_HIBERN8_STATE? Also, returning -EBUSY directly when ufshcd_uic_hibern8_enter() fails bypasses the out: label and skips logging UFS_EVT_SUSPEND_ERR via ufshcd_update_evt_hist(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202235113.1632= 498-1-vladimir.zapolskiy@linaro.org?part=3D3