From: "Seunghwan Baek" <sh8267.baek@samsung.com>
To: "'Bart Van Assche'" <bvanassche@acm.org>,
<linux-kernel@vger.kernel.org>, <linux-scsi@vger.kernel.org>,
<martin.petersen@oracle.com>,
<James.Bottomley@HansenPartnership.com>, <avri.altman@wdc.com>,
<alim.akhtar@samsung.com>
Cc: <grant.jung@samsung.com>, <jt77.jang@samsung.com>,
<junwoo80.lee@samsung.com>, <dh0421.hwang@samsung.com>,
<jangsub.yi@samsung.com>, <sh043.lee@samsung.com>,
<cw9316.lee@samsung.com>, <wkon.kim@samsung.com>,
<stable@vger.kernel.org>
Subject: RE: [PATCH v1 1/1] ufs: core: set SDEV_OFFLINE when ufs shutdown.
Date: Tue, 24 Sep 2024 11:17:15 +0900 [thread overview]
Message-ID: <003201db0e27$df93f250$9ebbd6f0$@samsung.com> (raw)
In-Reply-To: <fa8a4c1a-e583-496b-a0a2-bd86f86af508@acm.org>
> On 8/29/24 2:39 AM, Seunghwan Baek wrote:
> > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> > index a6f818cdef0e..4ac1492787c2 100644
> > --- a/drivers/ufs/core/ufshcd.c
> > +++ b/drivers/ufs/core/ufshcd.c
> > @@ -10215,7 +10215,9 @@ static void ufshcd_wl_shutdown(struct device
> *dev)
> > shost_for_each_device(sdev, hba->host) {
> > if (sdev == hba->ufs_device_wlun)
> > continue;
> > - scsi_device_quiesce(sdev);
> > + mutex_lock(&sdev->state_mutex);
> > + scsi_device_set_state(sdev, SDEV_OFFLINE);
> > + mutex_unlock(&sdev->state_mutex);
> > }
> > __ufshcd_wl_suspend(hba, UFS_SHUTDOWN_PM);
>
> Why to keep one scsi_device_quiesce() call and convert the other call?
> Please consider something like this change:
>
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index
> e808350c6774..914770dff18f 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -10134,11 +10134,10 @@ static void ufshcd_wl_shutdown(struct device
> *dev)
>
> /* Turn on everything while shutting down */
> ufshcd_rpm_get_sync(hba);
> - scsi_device_quiesce(sdev);
> shost_for_each_device(sdev, hba->host) {
> - if (sdev == hba->ufs_device_wlun)
> - continue;
> - scsi_device_quiesce(sdev);
> + mutex_lock(&sdev->state_mutex);
> + scsi_device_set_state(sdev, SDEV_OFFLINE);
> + mutex_unlock(&sdev->state_mutex);
> }
> __ufshcd_wl_suspend(hba, UFS_SHUTDOWN_PM);
>
> Thanks,
>
> Bart.
That's because SSU (Start Stop Unit) command must be sent during shutdown process.
If SDEV_OFFLINE is set for wlun, SSU command cannot be sent because it is rejected
by the scsi layer. Therefore, we consider to set SDEV_QUIESCE for wlun, and set
SDEV_OFFLINE for other lus.
static int ufshcd_execute_start_stop(struct scsi_device *sdev,
enum ufs_dev_pwr_mode pwr_mode,
struct scsi_sense_hdr *sshdr)
{
const unsigned char cdb[6] = { START_STOP, 0, 0, 0, pwr_mode << 4, 0 };
const struct scsi_exec_args args = {
.sshdr = sshdr,
.req_flags = BLK_MQ_REQ_PM, <<< set REQ_PM flag
.scmd_flags = SCMD_FAIL_IF_RECOVERING,
};
return scsi_execute_cmd(sdev, cdb, REQ_OP_DRV_IN, /*buffer=*/NULL,
/*bufflen=*/0, /*timeout=*/10 * HZ, /*retries=*/0,
&args);
}
static blk_status_t
scsi_device_state_check(struct scsi_device *sdev, struct request *req)
{
case SDEV_OFFLINE:
case SDEV_TRANSPORT_OFFLINE: <<< Refuse all commands
/*
* If the device is offline we refuse to process any
* commands. The device must be brought online
* before trying any recovery commands.
*/
if (!sdev->offline_already) {
sdev->offline_already = true;
sdev_printk(KERN_ERR, sdev,
"rejecting I/O to offline device\n");
}
return BLK_STS_IOERR;
case SDEV_QUIESCE: <<< Refuse all commands except REQ_PM flag
/*
* If the device is blocked we only accept power management
* commands.
*/
if (req && WARN_ON_ONCE(!(req->rq_flags & RQF_PM)))
return BLK_STS_RESOURCE;
return BLK_STS_OK;
next prev parent reply other threads:[~2024-09-24 2:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20240829093921epcas1p35d28696b0f79e2ae39d8e3690f088e64@epcas1p3.samsung.com>
[not found] ` <20240829093913.6282-1-sh8267.baek@samsung.com>
2024-08-29 9:39 ` [PATCH v1 1/1] ufs: core: set SDEV_OFFLINE when ufs shutdown Seunghwan Baek
2024-09-23 7:54 ` Seunghwan Baek
2024-09-23 17:31 ` Bart Van Assche
2024-09-23 17:41 ` Bart Van Assche
2024-09-24 2:17 ` Seunghwan Baek [this message]
2024-09-24 18:24 ` Bart Van Assche
2024-09-25 6:54 ` Seunghwan Baek
2024-10-08 5:27 ` Seunghwan Baek
2024-10-10 5:47 ` Kiwoong Kim
2024-10-08 17:58 ` Bart Van Assche
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='003201db0e27$df93f250$9ebbd6f0$@samsung.com' \
--to=sh8267.baek@samsung.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@wdc.com \
--cc=bvanassche@acm.org \
--cc=cw9316.lee@samsung.com \
--cc=dh0421.hwang@samsung.com \
--cc=grant.jung@samsung.com \
--cc=jangsub.yi@samsung.com \
--cc=jt77.jang@samsung.com \
--cc=junwoo80.lee@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=sh043.lee@samsung.com \
--cc=stable@vger.kernel.org \
--cc=wkon.kim@samsung.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