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=1796381331; b=bvdyRWUeP2guNZo5X3VGF5WPVF5zAIm/o4M34N8qAHFML0evBDoCsEzVO2OdaQaffbYW aPDV9mfVJPjqAXd9HYCW1l4xrlMpdxUHS/AbL5CkSihdv30LSomJag99cKNigH1gvtKbg suNvgrRN2dsyWQG1kteT2iIhKVyfEOkrUt1Nj+7K6ewI+Yy/Wv/IhU3ya89HqYalyXYzT kE1xLbOnrM3Hv6t3Umoc5/TM0pJWeIsbkNC9xdzKI1iRkSrPjzwj93Pw6WqgyYTnluYc6 rH4j3wh/bVFS9kmLUwDCpNkH3RoFPfXlutEfUJCBIOStqtKbqZwnblSx0oG//tcGmOg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381331; 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=7S7B7WibZlJxuyFkhawqK2CTDFuWnnUAEX5xA4c9yrI=; b=e0CmwqAYX1s4uKyV5A41AwqjSthWmlyAUZP9ZiUpUitDGT0r3jiHPSr5NgHoySW8J+0y UjhLiV9Go0yorXL9WvZ3OsIlUhYa7Eo6ERoxhbZ/d2ja2Jkc2FCXiaSpSnszloCFoopwI GzQIGuzQG1bJvSOzCZGATwdcRhxnw0HEveyno8g7usB6F5tC1QiMcvf58JT1T9475x1oP 973ehFIfvzz6hdhv9hzjwA0yq1UgVhgGSiocUfGt8G3WWP4yaaqaPtcYDoJ6N0Qi9XzH/ 2/mJroEfY6Ex6gOAStnCsUfu5SxRJkb0cRrKHWRihJgc51wyoe5InuqlshfFJ/8yEHA== 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=H+Cr4Dai; 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 233D8606A322; Fri, 4 Dec 2026 10:48:51 +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=H+Cr4Dai Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BA431F000CE; Fri, 4 Dec 2026 10:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381331; bh=7S7B7WibZlJxuyFkhawqK2CTDFuWnnUAEX5xA4c9yrI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=H+Cr4Dai5jPB3UrkWTIDIkVC/SrayOuedQ8bX7ycMEGbxLPCDFJDF56Hnj8pW+4Zx NOOGM4FQFiHB8kfUljD44LWoXF0xpfYgc9Y/fqeGnDYpKuYtOfqhMrf3dtrGdsqTuu LCMQ8+0p8F6W+QPTYLC4VI8Qbl/knu51ByGGGfEs= 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 7.3 655/742] scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper Date: Fri, 4 Dec 2026 19:08:39 +0900 Message-ID: <20261204100652.481154639@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-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 @@ -388,6 +388,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 @@ -1840,7 +1840,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; @@ -4751,7 +4753,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); /* * Serialize with the host driver's AHIT control. Skip the