From: Manish Pandey <manish.pandey@oss.qualcomm.com>
To: Peter Wang <peter.wang@mediatek.com>,
Stanley Jhu <stanleyjhu@google.com>,
linux-scsi@vger.kernel.org, "Martin K. Petersen" <mkp@kernel.org>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
Bart Van Assche <bvanassche@acm.org>,
Alim Akhtar <alim.akhtar@samsung.com>,
Bean Huo <beanhuo@micron.com>, Brian Kao <powenkao@google.com>,
Can Guo <can.guo@oss.qualcomm.com>,
"Bao D. Nguyen" <quic_nguyenb@quicinc.com>,
Hongjie Fang <hongjiefang@asrmicro.com>,
Praveen Talari <praveen.talari@oss.qualcomm.com>,
Hoyoung Seo <hy50.seo@samsung.com>,
John Garry <john.garry@linux.dev>,
Hyeoncheol Jeong <hyenc.jeong@samsung.com>,
Jens Axboe <axboe@kernel.dk>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] scsi: ufs: core: Do not recover the link concurrently with a PM callback
Date: Tue, 1 Dec 2026 21:27:10 +0530 [thread overview]
Message-ID: <7cf2d678-6785-49f4-85df-a3fcf4741405@oss.qualcomm.com> (raw)
In-Reply-To: <77e60c6e52705b3abd97d72ab3a766a5e6ba229e.camel@mediatek.com>
Hi Stanley,
This fix is helping as far as it goes with
ufshcd_err_handler Vs __ufshcd_wl_resume
but there is a second, structurally identical bypass that the commit
didn't touch, in ufshcd_eh_host_reset_handler()
(the SCSI .eh_host_reset_handler callback),
static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd)
{
...
if (hba->pm_op_in_progress) {
if (ufshcd_link_recovery(hba))
err = FAILED;
return err;
}
...
}
This has exactly the same shape:
it calls ufshcd_link_recovery(hba) directly, without taking
hba->host_sem and without going through ufshcd_err_handling_prepare() /
ufshcd_rpm_get_sync().
Also i would like to know what is the plan for Stable kernels Like
kernel 6.18 ? As same issue is observed there also.
Thanks
Manish
On 16-11-2026 18:23, Peter Wang wrote:
> On Fri, 2026-11-13 at 19:12 +0800, Stanley Jhu wrote:
>> From: Brian Kao <powenkao@google.com>
>>
>> ufshcd_set_dev_pwr_mode() now recovers the link after a START STOP
>> UNIT timeout. ufshcd_err_handler() must not recover the link while a
>> PM callback runs. Its pm_op_in_progress branch still does so when a
>> fatal UIC error arrives during that recovery.
>>
>
> Hi Stanley,
>
> Could we just add a check to prevent the concurrency issue
> in ufshcd_link_recovery?
>
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -1,10 +1,16 @@
> int ufshcd_link_recovery(struct ufs_hba *hba)
> {
> int ret;
> unsigned long flags;
>
> spin_lock_irqsave(hba->host->host_lock, flags);
> + if (ufshcd_eh_in_progress(hba)) {
> + spin_unlock_irqrestore(hba->host->host_lock, flags);
> + dev_info(hba->dev, "%s: link recovery already in
> progress, skipping\n",
> + __func__);
> + return -EBUSY;
> + }
> hba->ufshcd_state = UFSHCD_STATE_RESET;
> ufshcd_set_eh_in_progress(hba);
> spin_unlock_irqrestore(hba->host->host_lock, flags);
>
>
>
>> @@ -7074,23 +7074,6 @@ static void ufshcd_err_handler(struct
>> work_struct *work)
>> hba->saved_uic_err, hba->force_reset,
>> ufshcd_is_link_broken(hba) ? "; link is broken" :
>> "");
>>
>> - if (hba->ufs_device_wlun) {
>> - /*
>> - * Use ufshcd_rpm_get_noresume() here to safely
>> perform link
>> - * recovery even if an error occurs during runtime
>> suspend or
>> - * runtime resume. This avoids potential deadlocks
>> that could
>> - * happen if we tried to resume the device while a
>> PM operation
>> - * is already in progress.
>> - */
>> - ufshcd_rpm_get_noresume(hba);
>> - if (hba->pm_op_in_progress) {
>> - ufshcd_link_recovery(hba);
>> - ufshcd_rpm_put(hba);
>> - return;
>> - }
>> - ufshcd_rpm_put(hba);
>> - }
>> -
>>
>
> This section of code is used when a UIC error occurs
> before SSU is sent.
>
> Because the error handler uses link recovery, it will
> recover from the error quickly rather than waiting for
> the 10s SSU timeout. The end user will feel lag because
> the I/O cannot resume for 10s.
>
> Thanks
> Peter
prev parent reply other threads:[~2026-12-01 15:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 11:12 [PATCH v2 0/2] scsi: ufs: core: Fix device management and PM recovery Stanley Jhu
2026-11-13 11:12 ` [PATCH v2 1/2] scsi: ufs: core: Recover link in ufshcd_set_dev_pwr_mode() on timeout Stanley Jhu
2026-11-13 20:37 ` Bart Van Assche
2026-11-15 8:20 ` Stanley Jhu
2026-11-16 12:45 ` Peter Wang
2026-11-13 11:12 ` [PATCH v2 2/2] scsi: ufs: core: Do not recover the link concurrently with a PM callback Stanley Jhu
2026-11-16 12:53 ` Peter Wang
2026-12-01 15:57 ` Manish Pandey [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=7cf2d678-6785-49f4-85df-a3fcf4741405@oss.qualcomm.com \
--to=manish.pandey@oss.qualcomm.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=alim.akhtar@samsung.com \
--cc=axboe@kernel.dk \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=can.guo@oss.qualcomm.com \
--cc=hongjiefang@asrmicro.com \
--cc=hy50.seo@samsung.com \
--cc=hyenc.jeong@samsung.com \
--cc=john.garry@linux.dev \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mkp@kernel.org \
--cc=peter.wang@mediatek.com \
--cc=powenkao@google.com \
--cc=praveen.talari@oss.qualcomm.com \
--cc=quic_nguyenb@quicinc.com \
--cc=rafael.j.wysocki@intel.com \
--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®