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 2/3] scsi: ufs: core: Hold host_sem in ufshcd_wl_poweroff()
Date: Tue, 10 Nov 2026 13:50:45 +0800 [thread overview]
Message-ID: <855918393f7613361da4dbfdfec89467afa4b3c8.camel@mediatek.com> (raw)
In-Reply-To: <973576304.21794277202839.JavaMail.epsvc@epcpadp1new>
On Tue, 2026-11-10 at 11:03 +0900, HOYOUNG SEO wrote:
> ufshcd_wl_suspend() takes hba->host_sem and ufshcd_wl_resume()
> releases
> it, which serializes the error handler against system suspend and
> resume. ufshcd_wl_poweroff(), the hibernation poweroff callback, also
> suspends the device with UFS_SHUTDOWN_PM but does not take host_sem.
> An
> error handler that runs in the meantime can reset the link
> concurrently
> with __ufshcd_wl_suspend().
>
> It also leaves host_sem unbalanced: if hibernation is aborted after
> ufshcd_wl_poweroff() has been called, ufshcd_wl_resume() is called as
> the .restore callback and releases host_sem, which was not acquired.
>
> Make ufshcd_wl_poweroff() behave like ufshcd_wl_suspend() and keep
> holding host_sem. It is released by ufshcd_wl_resume() if hibernation
> is
> aborted. If __ufshcd_wl_suspend() fails, release host_sem and return
> the
> error as ufshcd_wl_suspend() does, otherwise the error handler, which
> waits for host_sem, would block forever.
>
> This changes the behavior on failure: the error is now returned from
> the
> .poweroff callback, which aborts hibernation, instead of being
> ignored.
>
> Do not use hba->shutting_down here: it makes
> ufs_mtk_system_suspend(),
> which is also the .poweroff callback of the MediaTek host controller,
> fail with -EBUSY, and nothing clears it when hibernation is aborted.
>
> Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for
> wlun")
> Suggested-by: Bart Van Assche <bvanassche@acm.org>
> Signed-off-by: HOYOUNG SEO <hy50.seo@samsung.com>
> ---
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
next prev parent reply other threads:[~2026-11-10 5:50 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 [this message]
[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
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=855918393f7613361da4dbfdfec89467afa4b3c8.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®