From: "hoyoung seo" <hy50.seo@samsung.com>
To: "'Bart Van Assche'" <bvanassche@acm.org>,
<linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<mkp@kernel.org>, <martin.petersen@oracle.com>,
<stanleyjhu@google.com>, <alim.akhtar@samsung.com>,
<kwangwon.min@samsung.com>, <kwmad.kim@samsung.com>,
<cpgs@samsung.com>, <h10.kim@samsung.com>
Subject: RE: [PATCH v6 3/3] scsi: ufs: core: Set shutting_down in ufshcd_wl_poweroff()
Date: Fri, 6 Nov 2026 15:09:27 +0900 [thread overview]
Message-ID: <015601dd6db5$65501c40$2ff054c0$@samsung.com> (raw)
In-Reply-To: <5f1692ad-d718-4446-bd62-57e7049be92a@acm.org>
Hi Bart,
Thank you for the review and the Reviewed-by on patch 1.
I will take your suggestion for ufshcd_wl_poweroff(): it will take
host_sem and keep holding it until ufshcd_wl_resume() releases it, so it
behaves like ufshcd_wl_suspend() and the unbalanced up() on the
.restore path goes away too. I will add the Fixes: tag (b294ff3e3449,
which added the WLUN .poweroff callback) and Suggested-by, and put the
patch in front of the one that limits the early link recovery.
For the patch that limits the early link recovery, v7 will:
- use READ_ONCE() in ufshcd_err_handler() and WRITE_ONCE() in
ufshcd_wl_runtime_suspend() and ufshcd_wl_runtime_resume();
- describe the behavior change during shutdown in the commit message:
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();
- correct the poweroff statement: the error handler waits for host_sem
there, it is not stopped by hba->shutting_down.
I will send v7 shortly.
Thanks,
> -----Original Message-----
> From: Bart Van Assche <bvanassche@acm.org>
> Sent: Friday, November 6, 2026 1:50 PM
> To: HOYOUNG SEO <hy50.seo@samsung.com>; linux-scsi@vger.kernel.org; linux-
> kernel@vger.kernel.org; mkp@kernel.org; martin.petersen@oracle.com;
> stanleyjhu@google.com; alim.akhtar@samsung.com; kwangwon.min@samsung.com;
> kwmad.kim@samsung.com; cpgs@samsung.com; h10.kim@samsung.com
> Subject: Re: [PATCH v6 3/3] scsi: ufs: core: Set shutting_down in
> ufshcd_wl_poweroff()
>
> On 11/5/26 6:15 PM, HOYOUNG SEO wrote:
> > + down(&hba->host_sem);
> > + hba->shutting_down = true;
> > + up(&hba->host_sem);
> > +
> > __ufshcd_wl_suspend(hba, UFS_SHUTDOWN_PM);
>
> I agree with both issues reported by Sashiko:
> - ufs_mtk_system_suspend() is also the .poweroff callback of the
> MediaTek host controller device and returns -EBUSY if
> hba->shutting_down has been set. Since the .poweroff callback of the
> WLUN is called before that of its parent, this patch makes
> hibernation fail on MediaTek hosts.
> - If hibernation is aborted after the WLUN .poweroff callback has been
> called, ufshcd_wl_resume() is called as .restore callback.
> Nothing clears hba->shutting_down, so the error handler and user
> access (ufshcd_is_user_access_allowed()) remain disabled.
>
> Additionally, the existing code already has an unbalanced
> up(&hba->host_sem) on that path: ufshcd_wl_poweroff() does not acquire
> host_sem but ufshcd_wl_resume() releases it.
>
> How about making ufshcd_wl_poweroff() behave like ufshcd_wl_suspend()
> instead, i.e. acquire host_sem and keep holding it until .restore releases
> it? Something like this (untested):
>
> static int ufshcd_wl_poweroff(struct device *dev) {
> struct scsi_device *sdev = to_scsi_device(dev);
> struct ufs_hba *hba = shost_priv(sdev->host);
>
> /* Released by ufshcd_wl_resume() if hibernation is aborted. */
> down(&hba->host_sem);
> __ufshcd_wl_suspend(hba, UFS_SHUTDOWN_PM);
> return 0;
> }
>
> That serializes the error handler against poweroff the same way as for
> system suspend, fixes the unbalanced up() call and leaves
> hba->shutting_down alone. Please also add a Fixes: tag and move this
> patch in front of patch 2/3.
>
> Thanks,
>
> Bart.
prev parent reply other threads:[~2026-11-06 6:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20261106022018epcas2p44e9634ca254c1a5d4c1ecb64723512ef@epcas2p4.samsung.com>
2026-11-06 2:15 ` [PATCH v6 0/3] scsi: ufs: core: Avoid redundant link recovery from the error handler during PM HOYOUNG SEO
[not found] ` <CGME20261106022020epcas2p397f84c634df3397fcb1c98d1837bb83f@epcas2p3.samsung.com>
2026-11-06 2:15 ` [PATCH v6 1/3] scsi: ufs: core: Clear saved errors in ufshcd_link_recovery() HOYOUNG SEO
2026-11-06 4:46 ` Bart Van Assche
2026-11-06 7:08 ` Peter Wang
[not found] ` <CGME20261106022020epcas2p2af29bc4d81ede559c5a74076721aba7f@epcas2p2.samsung.com>
2026-11-06 2:15 ` [PATCH v6 2/3] scsi: ufs: core: Limit early link recovery in the error handler to runtime PM HOYOUNG SEO
2026-11-06 4:48 ` Bart Van Assche
2026-11-06 7:10 ` Peter Wang
2026-11-06 7:58 ` hoyoung seo
2026-11-06 9:44 ` Peter Wang
[not found] ` <CGME20261106022021epcas2p20d78ac51e55f03348d496f45e96031e1@epcas2p2.samsung.com>
2026-11-06 2:15 ` [PATCH v6 3/3] scsi: ufs: core: Set shutting_down in ufshcd_wl_poweroff() HOYOUNG SEO
2026-11-06 4:49 ` Bart Van Assche
2026-11-06 6:09 ` hoyoung seo [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='015601dd6db5$65501c40$2ff054c0$@samsung.com' \
--to=hy50.seo@samsung.com \
--cc=alim.akhtar@samsung.com \
--cc=bvanassche@acm.org \
--cc=cpgs@samsung.com \
--cc=h10.kim@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®