From: Brian Norris <briannorris@chromium.org>
To: Stanley Jhu <stanleyjhu@google.com>
Cc: "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>,
"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, stable@vger.kernel.org
Subject: Re: [PATCH] scsi: ufs: core: Keep clock-gating hold on failed W-LUN runtime resume
Date: Tue, 3 Nov 2026 11:43:38 -0800 [thread overview]
Message-ID: <auo5ar8427cuH_nX@google.com> (raw)
In-Reply-To: <20261029040002.2100002-1-stanleyjhu@google.com>
Hi Stanley,
I'm not extremely familiar with the UFS or block layers here, so I'm
just coming from a general driver + runtime PM perspective. That said, I
have some thoughts:
On Thu, Oct 29, 2026 at 03:08:30PM +0800, Stanley Jhu wrote:
> 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.
I _think_ this reasoning and patch all looks good, with one possible
exception: ufshcd has explicit recovery in ufshcd_recover_pm_error(),
which relies on checking power.runtime_error, and then explicitly
overrides the status to active to clear the error.
It seems to me like commit eef1d74bf88f might have subverted some of
that logic too, because resume failures will no longer latch a
runtime_error value, so that recovery function may not be doing
much/anything. Is that a problem too?
> 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);
> + }
This looks right to me, as a non-expert in this code, and it may even
have been wrong before commit eef1d74bf88f.
Reviewed-by: Brian Norris <briannorris@chromium.org>
> hba->pm_op_in_progress = false;
> return ret;
> }
> --
> 2.56.0.313.g2479322e68-goog
>
prev parent reply other threads:[~2026-11-03 19:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 7:08 Stanley Jhu
2026-11-03 19:43 ` Brian Norris [this message]
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=auo5ar8427cuH_nX@google.com \
--to=briannorris@chromium.org \
--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 \
--cc=stanleyjhu@google.com \
/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®