linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND] [PATCH 1/1] ses: Retry UNIT ATTENTION for receive diagnostics
@ 2016-09-16 21:06 Brian King
  2016-09-16 21:25 ` Gabriel Krisman Bertazi
  2016-09-19 15:57 ` Martin K. Petersen
  0 siblings, 2 replies; 5+ messages in thread
From: Brian King @ 2016-09-16 21:06 UTC (permalink / raw)
  To: James.Bottomley
  Cc: martin.petersen, linux-scsi, krisman, wenxiong, brking, stable


If the ses driver receives a UNIT ATTENTION when issuing
a receive diagnostics while probing a SES device, it
fails to attach with messages such as:

scsi 1:0:7:0: Failed to get diagnostic page 0x8000002
scsi 1:0:7:0: Failed to bind enclosure -19

Fix this by eating unit attentions for these commands.

Cc: <stable@vger.kernel.org>
Suggested-by: Wen Xiong <wenxiong@linux.vnet.ibm.com>
Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---

 drivers/scsi/ses.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff -puN drivers/scsi/ses.c~ses_rcv_diag_retry drivers/scsi/ses.c
--- linux-2.6.git/drivers/scsi/ses.c~ses_rcv_diag_retry	2016-08-25 18:28:18.720565322 -0500
+++ linux-2.6.git-bjking1/drivers/scsi/ses.c	2016-08-25 18:28:29.687496342 -0500
@@ -86,7 +86,7 @@ static void init_device_slot_control(uns
 static int ses_recv_diag(struct scsi_device *sdev, int page_code,
 			 void *buf, int bufflen)
 {
-	int ret;
+	int ret, retries = SES_RETRIES;
 	unsigned char cmd[] = {
 		RECEIVE_DIAGNOSTIC,
 		1,		/* Set PCV bit */
@@ -96,11 +96,14 @@ static int ses_recv_diag(struct scsi_dev
 		0
 	};
 	unsigned char recv_page_code;
+	struct scsi_sense_hdr sshdr;
 
-	ret =  scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen,
-				NULL, SES_TIMEOUT, SES_RETRIES, NULL);
-	if (unlikely(!ret))
-		return ret;
+	do {
+		memset(&sshdr, 0, sizeof(sshdr));
+		ret =  scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen,
+					&sshdr, SES_TIMEOUT, retries, NULL);
+	} while (scsi_sense_valid(&sshdr) &&
+		 sshdr.sense_key == UNIT_ATTENTION && --retries);
 
 	recv_page_code = ((unsigned char *)buf)[0];
 
_

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

* Re: [RESEND] [PATCH 1/1] ses: Retry UNIT ATTENTION for receive diagnostics
  2016-09-16 21:06 [RESEND] [PATCH 1/1] ses: Retry UNIT ATTENTION for receive diagnostics Brian King
@ 2016-09-16 21:25 ` Gabriel Krisman Bertazi
  2016-09-19 15:57 ` Martin K. Petersen
  1 sibling, 0 replies; 5+ messages in thread
From: Gabriel Krisman Bertazi @ 2016-09-16 21:25 UTC (permalink / raw)
  To: Brian King; +Cc: James.Bottomley, martin.petersen, linux-scsi, wenxiong, stable

Brian King <brking@linux.vnet.ibm.com> writes:

> If the ses driver receives a UNIT ATTENTION when issuing
> a receive diagnostics while probing a SES device, it
> fails to attach with messages such as:
>
> scsi 1:0:7:0: Failed to get diagnostic page 0x8000002
> scsi 1:0:7:0: Failed to bind enclosure -19
>
> Fix this by eating unit attentions for these commands.


Reviewed-by: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>



-- 
Gabriel Krisman Bertazi

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

* Re: [RESEND] [PATCH 1/1] ses: Retry UNIT ATTENTION for receive diagnostics
  2016-09-16 21:06 [RESEND] [PATCH 1/1] ses: Retry UNIT ATTENTION for receive diagnostics Brian King
  2016-09-16 21:25 ` Gabriel Krisman Bertazi
@ 2016-09-19 15:57 ` Martin K. Petersen
  2016-09-19 16:20   ` James Bottomley
  1 sibling, 1 reply; 5+ messages in thread
From: Martin K. Petersen @ 2016-09-19 15:57 UTC (permalink / raw)
  To: Brian King
  Cc: James.Bottomley, martin.petersen, linux-scsi, krisman, wenxiong,
	stable

>>>>> "Brian" == Brian King <brking@linux.vnet.ibm.com> writes:

Brian> If the ses driver receives a UNIT ATTENTION when issuing a
Brian> receive diagnostics while probing a SES device, it fails to
Brian> attach with messages such as:

Brian> scsi 1:0:7:0: Failed to get diagnostic page 0x8000002 scsi
Brian> 1:0:7:0: Failed to bind enclosure -19

Brian> Fix this by eating unit attentions for these commands.

James?

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [RESEND] [PATCH 1/1] ses: Retry UNIT ATTENTION for receive diagnostics
  2016-09-19 15:57 ` Martin K. Petersen
@ 2016-09-19 16:20   ` James Bottomley
  2016-09-19 17:14     ` Ewan D. Milne
  0 siblings, 1 reply; 5+ messages in thread
From: James Bottomley @ 2016-09-19 16:20 UTC (permalink / raw)
  To: Martin K. Petersen, Brian King; +Cc: linux-scsi, krisman, wenxiong, stable

On Mon, 2016-09-19 at 11:57 -0400, Martin K. Petersen wrote:
> > > > > > "Brian" == Brian King <brking@linux.vnet.ibm.com> writes:
> 
> Brian> If the ses driver receives a UNIT ATTENTION when issuing a
> Brian> receive diagnostics while probing a SES device, it fails to
> Brian> attach with messages such as:
> 
> Brian> scsi 1:0:7:0: Failed to get diagnostic page 0x8000002 scsi
> Brian> 1:0:7:0: Failed to bind enclosure -19
> 
> Brian> Fix this by eating unit attentions for these commands.
> 
> James?

It seems to me that UA handling should be a part of scsi_execute_req
(and scsi_execute) ... that is unless anyone can find a caller that
would actually be interested.  I've been looking but haven't found one
so far.

James


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

* Re: [RESEND] [PATCH 1/1] ses: Retry UNIT ATTENTION for receive diagnostics
  2016-09-19 16:20   ` James Bottomley
@ 2016-09-19 17:14     ` Ewan D. Milne
  0 siblings, 0 replies; 5+ messages in thread
From: Ewan D. Milne @ 2016-09-19 17:14 UTC (permalink / raw)
  To: James Bottomley
  Cc: Martin K. Petersen, Brian King, linux-scsi, krisman, wenxiong

On Mon, 2016-09-19 at 09:20 -0700, James Bottomley wrote:
> On Mon, 2016-09-19 at 11:57 -0400, Martin K. Petersen wrote:
> > > > > > > "Brian" == Brian King <brking@linux.vnet.ibm.com> writes:
> > 
> > Brian> If the ses driver receives a UNIT ATTENTION when issuing a
> > Brian> receive diagnostics while probing a SES device, it fails to
> > Brian> attach with messages such as:
> > 
> > Brian> scsi 1:0:7:0: Failed to get diagnostic page 0x8000002 scsi
> > Brian> 1:0:7:0: Failed to bind enclosure -19
> > 
> > Brian> Fix this by eating unit attentions for these commands.
> > 
> > James?
> 
> It seems to me that UA handling should be a part of scsi_execute_req
> (and scsi_execute) ... that is unless anyone can find a caller that
> would actually be interested.  I've been looking but haven't found one
> so far.
> 
> James

Since UNIT ATTENTION is usually reporting a condition unrelated to
the command that was sent (I'm not sure 29 00 qualifies as unrelated
since it indicates loss of device state), we probably shouldn't
require every caller to retry on it.  Could we handle this internally,
(maybe unless it persists for N attempts), before returning?

We should still be going through the scsi_check_sense() path and
the device handlers need to see the sense.

(removed cc: stable from reply)

-Ewan



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

end of thread, other threads:[~2016-09-19 17:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-16 21:06 [RESEND] [PATCH 1/1] ses: Retry UNIT ATTENTION for receive diagnostics Brian King
2016-09-16 21:25 ` Gabriel Krisman Bertazi
2016-09-19 15:57 ` Martin K. Petersen
2016-09-19 16:20   ` James Bottomley
2016-09-19 17:14     ` Ewan D. Milne

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).