public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>,
	James Bottomley <james.bottomley@hansenpartnership.com>,
	linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.de>,
	Hannes Reinecke <hare@suse.com>
Subject: [PATCH 3/3] ses: Retry Power-on-reset check condition
Date: Thu, 21 Dec 2017 12:22:34 +0100	[thread overview]
Message-ID: <1513855354-86603-4-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1513855354-86603-1-git-send-email-hare@suse.de>

During startup any SCSI request might encounter a 'Power-on/reset'
sense code, which just can be retried.
In the case of ses it needs to be retried, otherwise ses will
errorneously detect this as a failure and not attach the driver.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/ses.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index c1f96b0..9c8b3db 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -110,14 +110,20 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code,
 		0
 	};
 	unsigned char recv_page_code;
+	int retries = SES_RETRIES;
 	struct scsi_sense_hdr sshdr;
 
+retry:
 	ret =  scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen,
-				&sshdr, SES_TIMEOUT, SES_RETRIES, NULL);
+				&sshdr, SES_TIMEOUT, retries, NULL);
 	if (unlikely(ret)) {
-		if (status_byte(ret) == CHECK_CONDITION &&
-		    sshdr.asc == 0x25 && sshdr.ascq == 0x00) {
-			ret = -ENODEV;
+		if (status_byte(ret) == CHECK_CONDITION) {
+			if (sshdr.asc == 0x29) {
+				retries--;
+				goto retry;
+			}
+			if (sshdr.asc == 0x25 && sshdr.ascq == 0x00)
+				ret = -ENODEV;
 		}
 		return ret;
 	}
-- 
1.8.5.6

  parent reply	other threads:[~2017-12-21 11:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-21 11:22 [PATCH 0/3] Another round of SES fixes Hannes Reinecke
2017-12-21 11:22 ` [PATCH 1/3] ses: make initial allocation size configurable Hannes Reinecke
2017-12-22 17:14   ` James Bottomley
2017-12-23 14:29     ` Hannes Reinecke
2017-12-21 11:22 ` [PATCH 2/3] ses: skip error messages for invalid LUNs Hannes Reinecke
2017-12-22 17:39   ` James Bottomley
2017-12-23 14:37     ` Hannes Reinecke
2017-12-21 11:22 ` Hannes Reinecke [this message]
2017-12-21 15:29   ` [PATCH 3/3] ses: Retry Power-on-reset check condition James Bottomley
2017-12-21 15:39     ` Hannes Reinecke

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=1513855354-86603-4-git-send-email-hare@suse.de \
    --to=hare@suse.de \
    --cc=hare@suse.com \
    --cc=hch@lst.de \
    --cc=james.bottomley@hansenpartnership.com \
    --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