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=1796382734; b=h6cto7B0slLEflyaMTo/9VcSUgn6CIhUPdowbnYUOqfZhNpwWnVOpvdOcIGtZ86wHkya p5/3vKl2NOLD1XchXQ6UR68Be0QaUbeufyEYqSGHV3FsB2QcGgVJjUNl5dMRVRz4S96uA XqQF6vPj/KuYGlXJnmoOsXHr5qVbQshoHqMkQjbGfbxbqoK7p6qTgYE9hqCr0V9Cqf1ma WmHsmaSJhFkDOHfXZIQFP++xadu+aivz86FZVCrQ9TBWQa2X5Nq5u5Pii04xlvr023hTB 2GTOP7sruZ2VsFamTSyJJxJJthxfxwhekPuymBPe3swBMN0apeElsF3E76oEukq0VBQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382734; 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=UzzDIB2Wz7B3DAUmVqawH9ksBtw/2N4qMvl5aEcox/0=; b=WVt8Fur8wSFHopl/1Ukl/tsRQx7j1ThGy635UlMnaFLvjg/u7ZOnfMJNbdEEwvezGMTx tZlflxIcUiy+FhKngxe73iMRKl2YsoLk+r5Azq95gkF2NqWCPsYK1VnwVAW2fIrPQ49hs RHsc2kYnDf3FT4j5QDkaLYpO3taBKErjpeNJd26gKTLaMDOEdyi7bhlbaA6oP7s8cR9Ow SQtN2AMaSVcHFX6WBSz3uXasQUuSEmMVtMPXrH34iqhBvgbYN7U3xE513WHSXQaojzfJd /CdUm2AfJGOwWc6lQeugGDmo3BV13wx9WcEvpnnhO0RoTMPUiVVKxnMLZ10vpnhm90Q== 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=Ulz958xn; 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 D4A2D60A2621; Fri, 4 Dec 2026 11:12:14 +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=Ulz958xn Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4853D1F00A23; Fri, 4 Dec 2026 11:12:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382734; bh=UzzDIB2Wz7B3DAUmVqawH9ksBtw/2N4qMvl5aEcox/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ulz958xnj368/9H1kSx3M5ZGU1VR322J97t/1/OC5gZWQdeBKNmiYgPrK3wf5QMdu LMJvqdrHHFx83MWsoVhy1c9U7eouHuUB4iLP7yX8hQCWj/f2wERfy+YCzEUGMeUMGi UM8XtEjxGi1EN1iycx6C04PyU6cJe2XSFV088Xk4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stanley Jhu , Bart Van Assche , Peter Wang , "Martin K. Petersen (Oracle)" Subject: [PATCH 6.18 579/703] scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper Date: Fri, 4 Dec 2026 19:07:58 +0900 Message-ID: <20261204100643.162885915@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: 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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stanley Jhu commit cbab12e5b4a7f49d5add4301de275351269cd431 upstream. ufshcd_clkscale_enable_store() and ufshcd_auto_hibern8_update() resume the UFS device W-LUN with ufshcd_rpm_get_sync() and ignore its return value. For clkscale_enable: 1. The W-LUN is runtime suspended and clock scaling is disabled. 2. User space writes 1 to clkscale_enable. 3. ufshcd_clkscale_enable_store() calls ufshcd_rpm_get_sync(). 4. The W-LUN runtime resume fails and the W-LUN stays suspended. 5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored. 6. ufshcd_clkscale_enable_store() enables clock scaling and resumes devfreq while the W-LUN is still suspended. For auto_hibern8: 1. The W-LUN starts a runtime suspend. 2. User space writes a new value to auto_hibern8. 3. ufshcd_auto_hibern8_update() sees that the W-LUN is not yet suspended and calls ufshcd_rpm_get_sync(). 4. ufshcd_rpm_get_sync() waits for the runtime suspend to finish and then runs the W-LUN runtime resume. 5. The W-LUN runtime resume fails and the W-LUN stays suspended. 6. ufshcd_rpm_get_sync() returns a negative errno, which is ignored. 7. ufshcd_auto_hibern8_update() writes REG_AUTO_HIBERNATE_IDLE_TIMER while the W-LUN is still suspended. Add ufshcd_rpm_resume_and_get() wrapping pm_runtime_resume_and_get() so failed resumes drop the usage reference automatically, and return early in ufshcd_clkscale_enable_store() and ufshcd_auto_hibern8_update() when it fails. Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun") Cc: stable@vger.kernel.org Signed-off-by: Stanley Jhu Reviewed-by: Bart Van Assche Reviewed-by: Peter Wang Link: https://patch.msgid.link/20261029040003.2100003-3-stanleyjhu@google.com Signed-off-by: Martin K. Petersen (Oracle) Signed-off-by: Greg Kroah-Hartman --- drivers/ufs/core/ufshcd-priv.h | 5 +++++ drivers/ufs/core/ufshcd.c | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -329,6 +329,11 @@ static inline int ufshcd_rpm_get_sync(st return pm_runtime_get_sync(&hba->ufs_device_wlun->sdev_gendev); } +static inline int ufshcd_rpm_resume_and_get(struct ufs_hba *hba) +{ + return pm_runtime_resume_and_get(&hba->ufs_device_wlun->sdev_gendev); +} + static inline int ufshcd_rpm_get_if_active(struct ufs_hba *hba) { return pm_runtime_get_if_active(&hba->ufs_device_wlun->sdev_gendev); --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -1809,7 +1809,9 @@ static ssize_t ufshcd_clkscale_enable_st if (value == hba->clk_scaling.is_enabled) goto out; - ufshcd_rpm_get_sync(hba); + err = ufshcd_rpm_resume_and_get(hba); + if (err) + goto out; ufshcd_hold(hba); hba->clk_scaling.is_enabled = value; @@ -4582,7 +4584,8 @@ void ufshcd_auto_hibern8_update(struct u WRITE_ONCE(hba->ahit, ahit); if (!pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) { - ufshcd_rpm_get_sync(hba); + if (ufshcd_rpm_resume_and_get(hba)) + return; ufshcd_hold(hba); ufshcd_configure_auto_hibern8(hba); ufshcd_release(hba);