Skip to content

Commit fbdac19

Browse files
wxiong66martinkpetersen
authored andcommitted
scsi: ses: Retry failed Send/Receive Diagnostic commands
Setting SCSI logging level with error=3, we saw some errors from enclosues: [108017.360833] ses 0:0:9:0: tag#641 Done: NEEDS_RETRY Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=0s [108017.360838] ses 0:0:9:0: tag#641 CDB: Receive Diagnostic 1c 01 01 00 20 00 [108017.427778] ses 0:0:9:0: Power-on or device reset occurred [108017.427784] ses 0:0:9:0: tag#641 Done: SUCCESS Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s [108017.427788] ses 0:0:9:0: tag#641 CDB: Receive Diagnostic 1c 01 01 00 20 00 [108017.427791] ses 0:0:9:0: tag#641 Sense Key : Unit Attention [current] [108017.427793] ses 0:0:9:0: tag#641 Add. Sense: Bus device reset function occurred [108017.427801] ses 0:0:9:0: Failed to get diagnostic page 0x1 [108017.427804] ses 0:0:9:0: Failed to bind enclosure -19 [108017.427895] ses 0:0:10:0: Attached Enclosure device [108017.427942] ses 0:0:10:0: Attached scsi generic sg18 type 13 Retry if the Send/Receive Diagnostic commands complete with a transient error status (NOT_READY or UNIT_ATTENTION with ASC 0x29). Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Brian King <[email protected]> Reviewed-by: James Bottomley <[email protected]> Signed-off-by: Wen Xiong <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 9a8ef2c commit fbdac19

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

drivers/scsi/ses.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,16 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code,
8787
0
8888
};
8989
unsigned char recv_page_code;
90+
unsigned int retries = SES_RETRIES;
91+
struct scsi_sense_hdr sshdr;
92+
93+
do {
94+
ret = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen,
95+
&sshdr, SES_TIMEOUT, 1, NULL);
96+
} while (ret > 0 && --retries && scsi_sense_valid(&sshdr) &&
97+
(sshdr.sense_key == NOT_READY ||
98+
(sshdr.sense_key == UNIT_ATTENTION && sshdr.asc == 0x29)));
9099

91-
ret = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen,
92-
NULL, SES_TIMEOUT, SES_RETRIES, NULL);
93100
if (unlikely(ret))
94101
return ret;
95102

@@ -121,9 +128,16 @@ static int ses_send_diag(struct scsi_device *sdev, int page_code,
121128
bufflen & 0xff,
122129
0
123130
};
131+
struct scsi_sense_hdr sshdr;
132+
unsigned int retries = SES_RETRIES;
133+
134+
do {
135+
result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, buf, bufflen,
136+
&sshdr, SES_TIMEOUT, 1, NULL);
137+
} while (result > 0 && --retries && scsi_sense_valid(&sshdr) &&
138+
(sshdr.sense_key == NOT_READY ||
139+
(sshdr.sense_key == UNIT_ATTENTION && sshdr.asc == 0x29)));
124140

125-
result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, buf, bufflen,
126-
NULL, SES_TIMEOUT, SES_RETRIES, NULL);
127141
if (result)
128142
sdev_printk(KERN_ERR, sdev, "SEND DIAGNOSTIC result: %8x\n",
129143
result);

0 commit comments

Comments
 (0)