From: Stanley Jhu <stanleyjhu@google.com>
To: "Martin K . Petersen" <mkp@kernel.org>,
"James E . J . Bottomley"
<James.Bottomley@HansenPartnership.com>,
Alim Akhtar <alim.akhtar@samsung.com>,
Bart Van Assche <bvanassche@acm.org>,
Bean Huo <beanhuo@micron.com>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
Praveen Talari <praveen.talari@oss.qualcomm.com>,
Peter Wang <peter.wang@mediatek.com>,
Can Guo <can.guo@oss.qualcomm.com>,
John Garry <john.garry@linux.dev>,
linux-scsi@vger.kernel.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org,
Stanley Jhu <stanleyjhu@google.com>,
stable@vger.kernel.org
Subject: [PATCH] scsi: ufs: core: Keep clock-gating hold on failed W-LUN runtime resume
Date: Thu, 29 Oct 2026 15:08:30 +0800 [thread overview]
Message-ID: <20261029040002.2100002-1-stanleyjhu@google.com> (raw)
1. __ufshcd_wl_suspend() takes one ufshcd_hold() reference and sets
hba->clk_gating.is_suspended while the UFS device W-LUN enters
RPM_SUSPENDED.
2. Since commit eef1d74bf88f ("PM: runtime: Only set runtime_error on
suspend callback failures"), a failed runtime resume (for example
START STOP UNIT completing with an error) leaves the W-LUN in
RPM_SUSPENDED with power.runtime_error == 0, while
__ufshcd_wl_resume() already clears hba->clk_gating.is_suspended and
calls ufshcd_release().
3. The next W-LUN runtime resume runs __ufshcd_wl_resume() again without
an intervening suspend and calls ufshcd_release() a second time,
dropping a reference it does not own and underflowing
hba->clk_gating.active_reqs on UFSHCD_CAP_CLK_GATING hosts.
Keep hba->clk_gating.is_suspended and the suspend hold across a failed
W-LUN runtime resume, so the hold stays paired with the W-LUN
RPM_SUSPENDED state and the next successful resume releases it.
Fixes: eef1d74bf88f ("PM: runtime: Only set runtime_error on suspend callback failures")
Cc: stable@vger.kernel.org # v7.3+
Signed-off-by: Stanley Jhu <stanleyjhu@google.com>
---
drivers/ufs/core/ufshcd.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index cc75384c6502..9be370cea52a 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -10626,8 +10626,14 @@ static int __ufshcd_wl_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
out:
if (ret)
ufshcd_update_evt_hist(hba, UFS_EVT_WL_RES_ERR, (u32)ret);
- hba->clk_gating.is_suspended = false;
- ufshcd_release(hba);
+ /*
+ * A failed runtime resume leaves the W-LUN RPM_SUSPENDED, so keep
+ * is_suspended and the suspend hold for the next resume.
+ */
+ if (!ret || pm_op != UFS_RUNTIME_PM) {
+ hba->clk_gating.is_suspended = false;
+ ufshcd_release(hba);
+ }
hba->pm_op_in_progress = false;
return ret;
}
--
2.56.0.313.g2479322e68-goog
reply other threads:[~2026-10-29 7:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261029040002.2100002-1-stanleyjhu@google.com \
--to=stanleyjhu@google.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=alim.akhtar@samsung.com \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=can.guo@oss.qualcomm.com \
--cc=john.garry@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mkp@kernel.org \
--cc=peter.wang@mediatek.com \
--cc=praveen.talari@oss.qualcomm.com \
--cc=rafael@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®