From: Peter Wang <peter.wang@mediatek.com>
To: HOYOUNG SEO <hy50.seo@samsung.com>, <linux-scsi@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <bvanassche@acm.org>,
<mkp@kernel.org>, <martin.petersen@oracle.com>,
<stanleyjhu@google.com>, <alim.akhtar@samsung.com>,
<kwangwon.min@samsung.com>, <kwmad.kim@samsung.com>,
<cpgsproxy1@samsung.com>, <h10.kim@samsung.com>
Subject: Re: [PATCH v9 3/3] scsi: ufs: core: Limit early link recovery in the error handler to runtime PM
Date: Tue, 10 Nov 2026 13:51:29 +0800 [thread overview]
Message-ID: <47cdd8b1b52b448c9672c54ea1291079ddddd1a0.camel@mediatek.com> (raw)
In-Reply-To: <2052256418.81794277203434.JavaMail.epsvc@epcpadp1new>
On Tue, 2026-11-10 at 11:03 +0900, HOYOUNG SEO wrote:
> ufshcd_err_handler() recovers the link without taking hba->host_sem
> whenever hba->pm_op_in_progress is set. That early path was added by
> commit f966e02ae521 ("scsi: ufs: core: Fix runtime suspend error
> deadlock") because the regular error handling would wait for a
> runtime
> PM operation that cannot complete while the error handler is waiting.
>
> pm_op_in_progress is also set during system suspend, system resume,
> shutdown and poweroff, where the early path is not needed and runs
> concurrently with the PM path itself. For example, if a LINERESET is
> reported and the hibern8 exit fails in __ufshcd_wl_resume() during
> system resume, both ufshcd_err_handler() and __ufshcd_wl_resume()
> call
> ufshcd_link_recovery(), and the host and the device may be reset at
> the
> same time.
>
> Only take the early path while pm_op_in_progress is set and a runtime
> suspend or resume of the WLUN is in progress. The runtime PM core
> sets
> the runtime status of the WLUN to RPM_SUSPENDING or RPM_RESUMING
> while
> ufshcd_wl_runtime_suspend() or ufshcd_wl_runtime_resume() runs, and
> it
> is RPM_ACTIVE or RPM_SUSPENDED during system PM. The runtime status
> alone is not enough: it also covers the block layer steps before and
> after the driver callbacks, where the early link recovery must not
> run.
> pm_op_in_progress is only set while __ufshcd_wl_suspend() or
> __ufshcd_wl_resume() run, which is inside that window.
>
> Both checks are done in the new helper
> ufshcd_rpm_transition_in_progress(), next to the other ufshcd_rpm_*()
> helpers. The runtime status is read with READ_ONCE() and without
> power.lock held. It is only available with CONFIG_PM, so the helper
> returns false without it. Both values are read without locking. As
> the
> window of pm_op_in_progress is contained in the runtime PM window, a
> stale value of either one can only make the error handler take the
> regular path, like an error handler that starts just before or after
> the PM operation.
>
> For the other PM operations the regular error handling is safe:
>
> - the system PM callbacks hold host_sem from ufshcd_wl_suspend()
> until
> ufshcd_wl_resume() returns, and ufshcd_wl_poweroff() holds it as
> well, so the error handler waits for them;
> - during shutdown, hba->shutting_down makes the error handler stop.
>
> This changes the behavior during shutdown: errors that occur while
> the
> final START STOP UNIT command is being processed are no longer
> handled
> by the error handler. Recovery then only happens through
> ufshcd_eh_timed_out().
>
> Fixes: e23ef4f22db3 ("scsi: ufs: core: Fix error handler host_sem
> issue")
> Signed-off-by: HOYOUNG SEO <hy50.seo@samsung.com>
> ---
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
prev parent reply other threads:[~2026-11-10 5:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1794275305.git.hy50.seo@samsung.com>
[not found] ` <CGME20261110020746epcas2p2ed2c3b150d2ecbf810658264841e790e@epcas2p2.samsung.com>
2026-11-10 2:03 ` [PATCH v9 1/3] scsi: ufs: core: Clear saved errors in ufshcd_link_recovery() HOYOUNG SEO
[not found] ` <CGME20261110020747epcas2p20410190486c9b48b4b2a4e9d8a4c2292@epcas2p2.samsung.com>
2026-11-10 2:03 ` [PATCH v9 2/3] scsi: ufs: core: Hold host_sem in ufshcd_wl_poweroff() HOYOUNG SEO
2026-11-10 5:50 ` Peter Wang
[not found] ` <CGME20261110020748epcas2p25076a34f183116ca4d8714dacf214958@epcas2p2.samsung.com>
2026-11-10 2:03 ` [PATCH v9 3/3] scsi: ufs: core: Limit early link recovery in the error handler to runtime PM HOYOUNG SEO
2026-11-10 5:51 ` Peter Wang [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=47cdd8b1b52b448c9672c54ea1291079ddddd1a0.camel@mediatek.com \
--to=peter.wang@mediatek.com \
--cc=alim.akhtar@samsung.com \
--cc=bvanassche@acm.org \
--cc=cpgsproxy1@samsung.com \
--cc=h10.kim@samsung.com \
--cc=hy50.seo@samsung.com \
--cc=kwangwon.min@samsung.com \
--cc=kwmad.kim@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mkp@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®