linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Tejun Heo <tj@kernel.org>
Cc: Matthias Prager <linux@matthiasprager.de>,
	Robert Trace <maillist@farcaster.org>,
	linux-scsi@vger.kernel.org, Jens Axboe <jaxboe@fusionio.com>,
	Eric Moore <Eric.Moore@lsi.com>, Alan <alan@lxorguk.ukuu.org.uk>,
	"Darrick J. Wong" <djwong@us.ibm.com>,
	linux-ide@vger.kernel.org
Subject: Re: 'Device not ready' issue on mpt2sas since 3.1.10
Date: Wed, 25 Jul 2012 23:55:55 +0400	[thread overview]
Message-ID: <1343246155.12094.59.camel@dabdike> (raw)
In-Reply-To: <20120725171723.GB32378@google.com>

On Wed, 2012-07-25 at 10:17 -0700, Tejun Heo wrote:
> Hello, James.
> 
> On Wed, Jul 25, 2012 at 06:19:13PM +0400, James Bottomley wrote:
> > > I haven't consulted SAT but it seems like a bug in SAS driver or
> > > firmware.  If it's a driver bug, we better fix it there.  If a
> > > firmware bug, working around those is one of major roles of drivers,
> > > so I think setting allow_restart is fine.
> > 
> > Actually, I don't think so.  SAT-2 section 8.12.2 does say 
> > 
> >         if the device is in the stopped state as the result of
> >         processing a START STOP UNIT command (see 9.11), then the SATL
> >         shall terminate the TEST UNIT READY command with CHECK CONDITION
> >         status with the sense key set to NOT READY and the additional
> >         sense code of LOGICAL UNIT NOT READY, INITIALIZING COMMAND
> >         REQUIRED;
> > 
> > START STOP UNIT (with START=0) translates to STANDBY IMMEDIATE, and
> > that's what hdparm -y issues.  We don't see this in /drivers/ata because
> > TEST UNIT READY always returns success.
> 
> Urgh... ATA device in standby mode is ready for any command and
> definitely doesn't need an "initializing command".  Oh, well...

Well, it does in sleep mode ... which seems to most closely map to what
SCSI thinks of as a stopped unit. I checked the specs just in case there
was an error ... they all say STANDBY not SLEEP.

> > So it looks like the mpt2sas SAT is doing the correct thing and we only
> > don't see this problem in normal SATA devices because of a bug in the
> > libata-scsi SAT.
> 
> libata is inconsistent with the standard but I think the standard is
> wrong here. :(

Well, reading it, so do I.  Unfortunately, we get to deal with the world
as it is rather than as we would wish it to be.  We likely have this
problem with a lot of USB SATLs as well ...

It looks like a hack like this might be needed.

James

---

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 4a6381c..7e59a7f 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -42,6 +42,8 @@
 
 #include <trace/events/scsi.h>
 
+static void scsi_eh_done(struct scsi_cmnd *scmd);
+
 #define SENSE_TIMEOUT		(10*HZ)
 
 /*
@@ -241,6 +243,14 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
 	if (! scsi_command_normalize_sense(scmd, &sshdr))
 		return FAILED;	/* no valid sense data */
 
+	if (scmd->cmnd[0] == TEST_UNIT_READY && scmd->scsi_done != scsi_eh_done)
+		/* 
+		 * nasty: for mid-layer issued TURs, we need to return the
+		 * actual sense data without any recovery attempt.  For eh
+		 * issued ones, we need to try to recover and interpret
+		 */
+		return SUCCESS;
+
 	if (scsi_sense_is_deferred(&sshdr))
 		return NEEDS_RETRY;
 
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 56a9379..91d3366 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -764,6 +764,16 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
 	sdev->model = (char *) (sdev->inquiry + 16);
 	sdev->rev = (char *) (sdev->inquiry + 32);
 
+	if (strncmp(sdev->vendor, "ATA     ", 8) == 0) {
+		/* 
+		 * sata emulation layer device.  This is a hack to work around
+		 * the SATL power management specifications which state that
+		 * when the SATL detects the device has gone into standby
+		 * mode, it shall respond with NOT READY.
+		 */
+		sdev->allow_restart = 1;
+	}
+
 	if (*bflags & BLIST_ISROM) {
 		sdev->type = TYPE_ROM;
 		sdev->removable = 1;



  reply	other threads:[~2012-07-25 19:56 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-22 11:19 'Device not ready' issue on mpt2sas since 3.1.10 Matthias Prager
2012-07-09 14:40 ` Matthias Prager
2012-07-09 19:37   ` Robert Trace
2012-07-09 20:45     ` Darrick J. Wong
2012-07-09 22:24       ` Robert Trace
2012-07-10  0:21         ` Matthias Prager
2012-07-10  1:56           ` Robert Trace
2012-07-10 16:54         ` Darrick J. Wong
2012-07-10  0:12     ` Matthias Prager
2012-07-10  1:51       ` Robert Trace
2012-07-10 23:27         ` Robert Trace
2012-07-11 12:19           ` Matthias Prager
2012-07-11 13:48             ` Matthias Prager
2012-07-17 18:09               ` Tejun Heo
2012-07-17 19:39                 ` Matthias Prager
2012-07-17 20:01                   ` Tejun Heo
2012-07-21 12:15                     ` Matthias Prager
2012-07-22 17:31                       ` Tejun Heo
2012-07-22 23:14                         ` Matthias Prager
2012-07-23 15:26                           ` Tejun Heo
2012-07-24 22:04                             ` Matthias Prager
2012-07-25 10:26                               ` Reddy, Sreekanth
2012-07-25 14:19                         ` James Bottomley
2012-07-25 17:17                           ` Tejun Heo
2012-07-25 19:55                             ` James Bottomley [this message]
2012-07-25 23:56                               ` Matthias Prager
2012-07-26 19:16                                 ` Robert Trace
2012-08-16 18:26                               ` Robert Trace
2012-08-16 20:24                                 ` Matthias Prager
2012-08-16 20:33                                   ` Robert Trace
2012-07-25 22:35                         ` tomm
2012-07-26 19:20                           ` Robert Trace
2012-07-09 22:08   ` NeilBrown
2012-07-10  0:03     ` Matthias Prager
  -- strict thread matches above, loose matches on Subject: below --
2015-11-27 10:28 Felix Matouschek

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=1343246155.12094.59.camel@dabdike \
    --to=james.bottomley@hansenpartnership.com \
    --cc=Eric.Moore@lsi.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=djwong@us.ibm.com \
    --cc=jaxboe@fusionio.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux@matthiasprager.de \
    --cc=maillist@farcaster.org \
    --cc=tj@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).