All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5.15] scsi: ufs: core: Retry START_STOP on UNIT_ATTENTION
@ 2021-12-16 10:07 Adrian Hunter
  2021-12-17 14:57 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Adrian Hunter @ 2021-12-16 10:07 UTC (permalink / raw)
  To: stable

From: Jaegeuk Kim <jaegeuk@kernel.org>

commit af21c3fd5b3ec540a97b367a70b26616ff7e0c55 upstream.

Note for stable: This patch is required if commit edc0596cc04bf ("scsi:
ufs: core: Stop clearing UNIT ATTENTIONS") has been cherry-picked.

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.

This is the preparation to get rid of all UNIT ATTENTION code which should
be handled by users.

Link: https://lore.kernel.org/r/20211001182015.1347587-2-jaegeuk@kernel.org
Cc: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[Adrian: For stable]
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 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 55f2e4d6f10b..31adf25e57b0 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -8477,7 +8477,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;
@@ -8510,8 +8510,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.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 5.15] scsi: ufs: core: Retry START_STOP on UNIT_ATTENTION
  2021-12-16 10:07 [PATCH 5.15] scsi: ufs: core: Retry START_STOP on UNIT_ATTENTION Adrian Hunter
@ 2021-12-17 14:57 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2021-12-17 14:57 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: stable

On Thu, Dec 16, 2021 at 12:07:49PM +0200, Adrian Hunter wrote:
> From: Jaegeuk Kim <jaegeuk@kernel.org>
> 
> commit af21c3fd5b3ec540a97b367a70b26616ff7e0c55 upstream.
> 
> Note for stable: This patch is required if commit edc0596cc04bf ("scsi:
> ufs: core: Stop clearing UNIT ATTENTIONS") has been cherry-picked.
> 
> 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.
> 
> This is the preparation to get rid of all UNIT ATTENTION code which should
> be handled by users.
> 
> Link: https://lore.kernel.org/r/20211001182015.1347587-2-jaegeuk@kernel.org
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> [Adrian: For stable]
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>  drivers/scsi/ufs/ufshcd.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)

Now queued up, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-17 14:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-16 10:07 [PATCH 5.15] scsi: ufs: core: Retry START_STOP on UNIT_ATTENTION Adrian Hunter
2021-12-17 14:57 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.