From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org,
martin.petersen@oracle.com, bvanassche@acm.org
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 1/2] scsi: ufs: retry START_STOP on UNIT_ATTENTION
Date: Thu, 30 Sep 2021 12:52:36 -0700 [thread overview]
Message-ID: <20210930195237.1521436-1-jaegeuk@kernel.org> (raw)
Commit 57d104c153d3 ("ufs: add UFS power management support") made the UFS
driver submit a REQUEST SENSE command before submitting a power management
command to a WLUN to clear the POWER ON unit attention. Instead of
submitting a REQUEST SENSE command before submitting a power management
command, retry the power management command until it succeeds.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
drivers/scsi/ufs/ufshcd.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 3841ab49f556..1f21d371e231 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -8630,7 +8630,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
struct scsi_sense_hdr sshdr;
struct scsi_device *sdp;
unsigned long flags;
- int ret;
+ int ret, retries;
spin_lock_irqsave(hba->host->host_lock, flags);
sdp = hba->sdev_ufs_device;
@@ -8665,8 +8665,14 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
* callbacks hence set the RQF_PM flag so that it doesn't resume the
* already suspended childs.
*/
- ret = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
- START_STOP_TIMEOUT, 0, 0, RQF_PM, NULL);
+ for (retries = 3; retries > 0; --retries) {
+ ret = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
+ START_STOP_TIMEOUT, 0, 0, RQF_PM, NULL);
+ if (!scsi_status_is_check_condition(ret) ||
+ !scsi_sense_valid(&sshdr) ||
+ sshdr.sense_key != UNIT_ATTENTION)
+ break;
+ }
if (ret) {
sdev_printk(KERN_WARNING, sdp,
"START_STOP failed for power mode: %d, result %x\n",
--
2.33.0.800.g4c38ced690-goog
next reply other threads:[~2021-09-30 19:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-30 19:52 Jaegeuk Kim [this message]
2021-09-30 19:52 ` [PATCH 2/2] scsi: ufs: Stop clearing unit attentions Jaegeuk Kim
2021-10-01 4:58 ` Adrian Hunter
2021-10-01 6:52 ` Adrian Hunter
2021-10-01 16:59 ` Bart Van Assche
2021-10-01 17:21 ` Douglas Gilbert
2021-10-01 17:40 ` Bart Van Assche
2021-10-01 17:24 ` Adrian Hunter
2021-10-01 16:19 ` Bart Van Assche
2021-09-30 19:55 ` [PATCH 1/2] scsi: ufs: retry START_STOP on UNIT_ATTENTION Bart Van Assche
-- strict thread matches above, loose matches on Subject: below --
2021-10-01 18:20 [PATCH 0/2 v2] kill clearing UA in UFS driver Jaegeuk Kim
2021-10-01 18:20 ` [PATCH 1/2] scsi: ufs: retry START_STOP on UNIT_ATTENTION Jaegeuk Kim
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=20210930195237.1521436-1-jaegeuk@kernel.org \
--to=jaegeuk@kernel.org \
--cc=bvanassche@acm.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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