aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/53c700.c2
-rw-r--r--drivers/scsi/ch.c2
-rw-r--r--drivers/scsi/constants.c120
-rw-r--r--drivers/scsi/osst.c8
-rw-r--r--drivers/scsi/scsi.c2
-rw-r--r--drivers/scsi/scsi_error.c2
-rw-r--r--drivers/scsi/scsi_ioctl.c2
-rw-r--r--drivers/scsi/scsi_lib.c4
-rw-r--r--drivers/scsi/sd.c9
-rw-r--r--drivers/scsi/sg.c2
-rw-r--r--drivers/scsi/sr_ioctl.c6
-rw-r--r--drivers/scsi/st.c6
-rw-r--r--drivers/scsi/storvsc_drv.c3
-rw-r--r--drivers/scsi/ufs/ufshcd.c4
-rw-r--r--drivers/usb/storage/debug.c10
-rw-r--r--drivers/xen/xen-scsiback.c4
-rw-r--r--include/scsi/scsi_dbg.h17
-rw-r--r--include/scsi/scsi_eh.h2
18 files changed, 107 insertions, 98 deletions
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index fabd4be2c985..68bf423008a4 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -602,7 +602,7 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata,
602#ifdef NCR_700_DEBUG 602#ifdef NCR_700_DEBUG
603 printk(" ORIGINAL CMD %p RETURNED %d, new return is %d sense is\n", 603 printk(" ORIGINAL CMD %p RETURNED %d, new return is %d sense is\n",
604 SCp, SCp->cmnd[7], result); 604 SCp, SCp->cmnd[7], result);
605 scsi_print_sense("53c700", SCp); 605 scsi_print_sense(SCp);
606 606
607#endif 607#endif
608 dma_unmap_single(hostdata->dev, slot->dma_handle, 608 dma_unmap_single(hostdata->dev, slot->dma_handle,
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 52060e72b75d..53621a34c5f9 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -206,7 +206,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
206 DPRINTK("result: 0x%x\n",result); 206 DPRINTK("result: 0x%x\n",result);
207 if (driver_byte(result) & DRIVER_SENSE) { 207 if (driver_byte(result) & DRIVER_SENSE) {
208 if (debug) 208 if (debug)
209 scsi_print_sense_hdr(ch->name, &sshdr); 209 scsi_print_sense_hdr(ch->device, ch->name, &sshdr);
210 errno = ch_find_errno(&sshdr); 210 errno = ch_find_errno(&sshdr);
211 211
212 switch(sshdr.sense_key) { 212 switch(sshdr.sense_key) {
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 2f447075adbb..9065b6f8f51b 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -1292,18 +1292,19 @@ static const struct error_info additional[] =
1292 1292
1293struct error_info2 { 1293struct error_info2 {
1294 unsigned char code1, code2_min, code2_max; 1294 unsigned char code1, code2_min, code2_max;
1295 const char * str;
1295 const char * fmt; 1296 const char * fmt;
1296}; 1297};
1297 1298
1298static const struct error_info2 additional2[] = 1299static const struct error_info2 additional2[] =
1299{ 1300{
1300 {0x40, 0x00, 0x7f, "Ram failure (%x)"}, 1301 {0x40, 0x00, 0x7f, "Ram failure", ""},
1301 {0x40, 0x80, 0xff, "Diagnostic failure on component (%x)"}, 1302 {0x40, 0x80, 0xff, "Diagnostic failure on component", ""},
1302 {0x41, 0x00, 0xff, "Data path failure (%x)"}, 1303 {0x41, 0x00, 0xff, "Data path failure", ""},
1303 {0x42, 0x00, 0xff, "Power-on or self-test failure (%x)"}, 1304 {0x42, 0x00, 0xff, "Power-on or self-test failure", ""},
1304 {0x4D, 0x00, 0xff, "Tagged overlapped commands (task tag %x)"}, 1305 {0x4D, 0x00, 0xff, "Tagged overlapped commands", "task tag "},
1305 {0x70, 0x00, 0xff, "Decompression exception short algorithm id of %x"}, 1306 {0x70, 0x00, 0xff, "Decompression exception", "short algorithm id of "},
1306 {0, 0, 0, NULL} 1307 {0, 0, 0, NULL, NULL}
1307}; 1308};
1308 1309
1309/* description of the sense key values */ 1310/* description of the sense key values */
@@ -1349,7 +1350,8 @@ EXPORT_SYMBOL(scsi_sense_key_string);
1349 * This string may contain a "%x" and should be printed with ascq as arg. 1350 * This string may contain a "%x" and should be printed with ascq as arg.
1350 */ 1351 */
1351const char * 1352const char *
1352scsi_extd_sense_format(unsigned char asc, unsigned char ascq) { 1353scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt)
1354{
1353#ifdef CONFIG_SCSI_CONSTANTS 1355#ifdef CONFIG_SCSI_CONSTANTS
1354 int i; 1356 int i;
1355 unsigned short code = ((asc << 8) | ascq); 1357 unsigned short code = ((asc << 8) | ascq);
@@ -1360,8 +1362,10 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq) {
1360 for (i = 0; additional2[i].fmt; i++) { 1362 for (i = 0; additional2[i].fmt; i++) {
1361 if (additional2[i].code1 == asc && 1363 if (additional2[i].code1 == asc &&
1362 ascq >= additional2[i].code2_min && 1364 ascq >= additional2[i].code2_min &&
1363 ascq <= additional2[i].code2_max) 1365 ascq <= additional2[i].code2_max) {
1364 return additional2[i].fmt; 1366 *fmt = additional2[i].fmt;
1367 return additional2[i].str;
1368 }
1365 } 1369 }
1366#endif 1370#endif
1367 return NULL; 1371 return NULL;
@@ -1369,49 +1373,53 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq) {
1369EXPORT_SYMBOL(scsi_extd_sense_format); 1373EXPORT_SYMBOL(scsi_extd_sense_format);
1370 1374
1371void 1375void
1372scsi_show_extd_sense(unsigned char asc, unsigned char ascq) 1376scsi_show_extd_sense(const struct scsi_device *sdev, const char *name,
1377 unsigned char asc, unsigned char ascq)
1373{ 1378{
1374 const char *extd_sense_fmt = scsi_extd_sense_format(asc, ascq); 1379 const char *extd_sense_fmt = NULL;
1380 const char *extd_sense_str = scsi_extd_sense_format(asc, ascq,
1381 &extd_sense_fmt);
1382
1383 if (extd_sense_str) {
1384 if (extd_sense_fmt)
1385 sdev_prefix_printk(KERN_INFO, sdev, name,
1386 "Add. Sense: %s (%s%x)",
1387 extd_sense_str, extd_sense_fmt,
1388 ascq);
1389 else
1390 sdev_prefix_printk(KERN_INFO, sdev, name,
1391 "Add. Sense: %s", extd_sense_str);
1375 1392
1376 if (extd_sense_fmt) {
1377 if (strstr(extd_sense_fmt, "%x")) {
1378 printk("Add. Sense: ");
1379 printk(extd_sense_fmt, ascq);
1380 } else
1381 printk("Add. Sense: %s", extd_sense_fmt);
1382 } else { 1393 } else {
1383 if (asc >= 0x80) 1394 sdev_prefix_printk(KERN_INFO, sdev, name,
1384 printk("<<vendor>> ASC=0x%x ASCQ=0x%x", asc, 1395 "%sASC=0x%x %sASCQ=0x%x\n",
1385 ascq); 1396 asc >= 0x80 ? "<<vendor>> " : "", asc,
1386 if (ascq >= 0x80) 1397 ascq >= 0x80 ? "<<vendor>> " : "", ascq);
1387 printk("ASC=0x%x <<vendor>> ASCQ=0x%x", asc,
1388 ascq);
1389 else
1390 printk("ASC=0x%x ASCQ=0x%x", asc, ascq);
1391 } 1398 }
1392
1393 printk("\n");
1394} 1399}
1395EXPORT_SYMBOL(scsi_show_extd_sense); 1400EXPORT_SYMBOL(scsi_show_extd_sense);
1396 1401
1397void 1402void
1398scsi_show_sense_hdr(struct scsi_sense_hdr *sshdr) 1403scsi_show_sense_hdr(const struct scsi_device *sdev, const char *name,
1404 const struct scsi_sense_hdr *sshdr)
1399{ 1405{
1400 const char *sense_txt; 1406 const char *sense_txt;
1401 1407
1402 sense_txt = scsi_sense_key_string(sshdr->sense_key); 1408 sense_txt = scsi_sense_key_string(sshdr->sense_key);
1403 if (sense_txt) 1409 if (sense_txt)
1404 printk("Sense Key : %s ", sense_txt); 1410 sdev_prefix_printk(KERN_INFO, sdev, name,
1411 "Sense Key : %s [%s]%s\n", sense_txt,
1412 scsi_sense_is_deferred(sshdr) ?
1413 "deferred" : "current",
1414 sshdr->response_code >= 0x72 ?
1415 " [descriptor]" : "");
1405 else 1416 else
1406 printk("Sense Key : 0x%x ", sshdr->sense_key); 1417 sdev_prefix_printk(KERN_INFO, sdev, name,
1407 1418 "Sense Key : 0x%x [%s]%s", sshdr->sense_key,
1408 printk("%s", scsi_sense_is_deferred(sshdr) ? "[deferred] " : 1419 scsi_sense_is_deferred(sshdr) ?
1409 "[current] "); 1420 "deferred" : "current",
1410 1421 sshdr->response_code >= 0x72 ?
1411 if (sshdr->response_code >= 0x72) 1422 " [descriptor]" : "");
1412 printk("[descriptor]");
1413
1414 printk("\n");
1415} 1423}
1416EXPORT_SYMBOL(scsi_show_sense_hdr); 1424EXPORT_SYMBOL(scsi_show_sense_hdr);
1417 1425
@@ -1419,12 +1427,11 @@ EXPORT_SYMBOL(scsi_show_sense_hdr);
1419 * Print normalized SCSI sense header with a prefix. 1427 * Print normalized SCSI sense header with a prefix.
1420 */ 1428 */
1421void 1429void
1422scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr) 1430scsi_print_sense_hdr(const struct scsi_device *sdev, const char *name,
1431 const struct scsi_sense_hdr *sshdr)
1423{ 1432{
1424 printk(KERN_INFO "%s: ", name); 1433 scsi_show_sense_hdr(sdev, name, sshdr);
1425 scsi_show_sense_hdr(sshdr); 1434 scsi_show_extd_sense(sdev, name, sshdr->asc, sshdr->ascq);
1426 printk(KERN_INFO "%s: ", name);
1427 scsi_show_extd_sense(sshdr->asc, sshdr->ascq);
1428} 1435}
1429EXPORT_SYMBOL(scsi_print_sense_hdr); 1436EXPORT_SYMBOL(scsi_print_sense_hdr);
1430 1437
@@ -1513,33 +1520,26 @@ scsi_decode_sense_extras(const unsigned char *sense_buffer, int sense_len,
1513} 1520}
1514 1521
1515/* Normalize and print sense buffer with name prefix */ 1522/* Normalize and print sense buffer with name prefix */
1516void __scsi_print_sense(const char *name, const unsigned char *sense_buffer, 1523void __scsi_print_sense(const struct scsi_device *sdev, const char *name,
1517 int sense_len) 1524 const unsigned char *sense_buffer, int sense_len)
1518{ 1525{
1519 struct scsi_sense_hdr sshdr; 1526 struct scsi_sense_hdr sshdr;
1520 1527
1521 printk(KERN_INFO "%s: ", name);
1522 scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr); 1528 scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr);
1523 scsi_show_sense_hdr(&sshdr); 1529 scsi_show_sense_hdr(sdev, name, &sshdr);
1524 scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr); 1530 scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr);
1525 printk(KERN_INFO "%s: ", name); 1531 scsi_show_extd_sense(sdev, name, sshdr.asc, sshdr.ascq);
1526 scsi_show_extd_sense(sshdr.asc, sshdr.ascq);
1527} 1532}
1528EXPORT_SYMBOL(__scsi_print_sense); 1533EXPORT_SYMBOL(__scsi_print_sense);
1529 1534
1530/* Normalize and print sense buffer in SCSI command */ 1535/* Normalize and print sense buffer in SCSI command */
1531void scsi_print_sense(char *name, struct scsi_cmnd *cmd) 1536void scsi_print_sense(const struct scsi_cmnd *cmd)
1532{ 1537{
1533 struct scsi_sense_hdr sshdr; 1538 struct gendisk *disk = cmd->request->rq_disk;
1539 const char *disk_name = disk ? disk->disk_name : NULL;
1534 1540
1535 scmd_printk(KERN_INFO, cmd, " "); 1541 __scsi_print_sense(cmd->device, disk_name, cmd->sense_buffer,
1536 scsi_decode_sense_buffer(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE, 1542 SCSI_SENSE_BUFFERSIZE);
1537 &sshdr);
1538 scsi_show_sense_hdr(&sshdr);
1539 scsi_decode_sense_extras(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
1540 &sshdr);
1541 scmd_printk(KERN_INFO, cmd, " ");
1542 scsi_show_extd_sense(sshdr.asc, sshdr.ascq);
1543} 1543}
1544EXPORT_SYMBOL(scsi_print_sense); 1544EXPORT_SYMBOL(scsi_print_sense);
1545 1545
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index dff37a250d79..3d0d13c4da15 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -259,9 +259,10 @@ static int osst_chk_result(struct osst_tape * STp, struct osst_request * SRpnt)
259 SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2], 259 SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2],
260 SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]); 260 SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]);
261 if (scode) printk(OSST_DEB_MSG "%s:D: Sense: %02x, ASC: %02x, ASCQ: %02x\n", 261 if (scode) printk(OSST_DEB_MSG "%s:D: Sense: %02x, ASC: %02x, ASCQ: %02x\n",
262 name, scode, sense[12], sense[13]); 262 name, scode, sense[12], sense[13]);
263 if (cmdstatp->have_sense) 263 if (cmdstatp->have_sense)
264 __scsi_print_sense("osst ", SRpnt->sense, SCSI_SENSE_BUFFERSIZE); 264 __scsi_print_sense(STp->device, name,
265 SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
265 } 266 }
266 else 267 else
267#endif 268#endif
@@ -275,7 +276,8 @@ static int osst_chk_result(struct osst_tape * STp, struct osst_request * SRpnt)
275 SRpnt->cmd[0] != TEST_UNIT_READY)) { /* Abnormal conditions for tape */ 276 SRpnt->cmd[0] != TEST_UNIT_READY)) { /* Abnormal conditions for tape */
276 if (cmdstatp->have_sense) { 277 if (cmdstatp->have_sense) {
277 printk(KERN_WARNING "%s:W: Command with sense data:\n", name); 278 printk(KERN_WARNING "%s:W: Command with sense data:\n", name);
278 __scsi_print_sense("osst ", SRpnt->sense, SCSI_SENSE_BUFFERSIZE); 279 __scsi_print_sense(STp->device, name,
280 SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
279 } 281 }
280 else { 282 else {
281 static int notyetprinted = 1; 283 static int notyetprinted = 1;
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 79c77b485a67..32eaac03cf4e 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -606,7 +606,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
606 scsi_print_result(cmd); 606 scsi_print_result(cmd);
607 scsi_print_command(cmd); 607 scsi_print_command(cmd);
608 if (status_byte(cmd->result) & CHECK_CONDITION) 608 if (status_byte(cmd->result) & CHECK_CONDITION)
609 scsi_print_sense("", cmd); 609 scsi_print_sense(cmd);
610 if (level > 3) 610 if (level > 3)
611 scmd_printk(KERN_INFO, cmd, 611 scmd_printk(KERN_INFO, cmd,
612 "scsi host busy %d failed %d\n", 612 "scsi host busy %d failed %d\n",
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 0ed666112b4f..0084f0b21a91 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1180,7 +1180,7 @@ int scsi_eh_get_sense(struct list_head *work_q,
1180 SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, 1180 SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd,
1181 "sense requested for %p result %x\n", 1181 "sense requested for %p result %x\n",
1182 scmd, scmd->result)); 1182 scmd, scmd->result));
1183 SCSI_LOG_ERROR_RECOVERY(3, scsi_print_sense("bh", scmd)); 1183 SCSI_LOG_ERROR_RECOVERY(3, scsi_print_sense(scmd));
1184 1184
1185 rtn = scsi_decide_disposition(scmd); 1185 rtn = scsi_decide_disposition(scmd);
1186 1186
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 12fe676d1343..5207274574f5 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -126,7 +126,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
126 sdev_printk(KERN_INFO, sdev, 126 sdev_printk(KERN_INFO, sdev,
127 "ioctl_internal_command return code = %x\n", 127 "ioctl_internal_command return code = %x\n",
128 result); 128 result);
129 scsi_print_sense_hdr(" ", &sshdr); 129 scsi_print_sense_hdr(sdev, NULL, &sshdr);
130 break; 130 break;
131 } 131 }
132 } 132 }
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 389bc6fd19ae..3c96e3923520 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -912,7 +912,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
912 if ((sshdr.asc == 0x0) && (sshdr.ascq == 0x1d)) 912 if ((sshdr.asc == 0x0) && (sshdr.ascq == 0x1d))
913 ; 913 ;
914 else if (!(req->cmd_flags & REQ_QUIET)) 914 else if (!(req->cmd_flags & REQ_QUIET))
915 scsi_print_sense("", cmd); 915 scsi_print_sense(cmd);
916 result = 0; 916 result = 0;
917 /* BLOCK_PC may have set error */ 917 /* BLOCK_PC may have set error */
918 error = 0; 918 error = 0;
@@ -1041,7 +1041,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
1041 if (!(req->cmd_flags & REQ_QUIET)) { 1041 if (!(req->cmd_flags & REQ_QUIET)) {
1042 scsi_print_result(cmd); 1042 scsi_print_result(cmd);
1043 if (driver_byte(result) & DRIVER_SENSE) 1043 if (driver_byte(result) & DRIVER_SENSE)
1044 scsi_print_sense("", cmd); 1044 scsi_print_sense(cmd);
1045 scsi_print_command(cmd); 1045 scsi_print_command(cmd);
1046 } 1046 }
1047 if (!scsi_end_request(req, error, blk_rq_err_bytes(req), 0)) 1047 if (!scsi_end_request(req, error, blk_rq_err_bytes(req), 0))
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 52b40b1e8c45..3ae75402809a 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3336,10 +3336,11 @@ module_exit(exit_sd);
3336static void sd_print_sense_hdr(struct scsi_disk *sdkp, 3336static void sd_print_sense_hdr(struct scsi_disk *sdkp,
3337 struct scsi_sense_hdr *sshdr) 3337 struct scsi_sense_hdr *sshdr)
3338{ 3338{
3339 sd_printk(KERN_INFO, sdkp, " "); 3339 scsi_show_sense_hdr(sdkp->device,
3340 scsi_show_sense_hdr(sshdr); 3340 sdkp->disk ? sdkp->disk->disk_name : NULL, sshdr);
3341 sd_printk(KERN_INFO, sdkp, " "); 3341 scsi_show_extd_sense(sdkp->device,
3342 scsi_show_extd_sense(sshdr->asc, sshdr->ascq); 3342 sdkp->disk ? sdkp->disk->disk_name : NULL,
3343 sshdr->asc, sshdr->ascq);
3343} 3344}
3344 3345
3345static void sd_print_result(struct scsi_disk *sdkp, int result) 3346static void sd_print_result(struct scsi_disk *sdkp, int result)
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 55cbc6689d27..2fe2701d86db 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1365,7 +1365,7 @@ sg_rq_end_io(struct request *rq, int uptodate)
1365 if ((sdp->sgdebug > 0) && 1365 if ((sdp->sgdebug > 0) &&
1366 ((CHECK_CONDITION == srp->header.masked_status) || 1366 ((CHECK_CONDITION == srp->header.masked_status) ||
1367 (COMMAND_TERMINATED == srp->header.masked_status))) 1367 (COMMAND_TERMINATED == srp->header.masked_status)))
1368 __scsi_print_sense(__func__, sense, 1368 __scsi_print_sense(sdp->device, __func__, sense,
1369 SCSI_SENSE_BUFFERSIZE); 1369 SCSI_SENSE_BUFFERSIZE);
1370 1370
1371 /* Following if statement is a patch supplied by Eric Youngdale */ 1371 /* Following if statement is a patch supplied by Eric Youngdale */
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index 6389fcff12ec..17e0c2b28a99 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -246,7 +246,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
246 "CDROM not ready. Make sure there " 246 "CDROM not ready. Make sure there "
247 "is a disc in the drive.\n"); 247 "is a disc in the drive.\n");
248#ifdef DEBUG 248#ifdef DEBUG
249 scsi_print_sense_hdr("sr", &sshdr); 249 scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr);
250#endif 250#endif
251 err = -ENOMEDIUM; 251 err = -ENOMEDIUM;
252 break; 252 break;
@@ -258,14 +258,14 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
258 err = -EDRIVE_CANT_DO_THIS; 258 err = -EDRIVE_CANT_DO_THIS;
259#ifdef DEBUG 259#ifdef DEBUG
260 __scsi_print_command(cgc->cmd); 260 __scsi_print_command(cgc->cmd);
261 scsi_print_sense_hdr("sr", &sshdr); 261 scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr);
262#endif 262#endif
263 break; 263 break;
264 default: 264 default:
265 sr_printk(KERN_ERR, cd, 265 sr_printk(KERN_ERR, cd,
266 "CDROM (ioctl) error, command: "); 266 "CDROM (ioctl) error, command: ");
267 __scsi_print_command(cgc->cmd); 267 __scsi_print_command(cgc->cmd);
268 scsi_print_sense_hdr("sr", &sshdr); 268 scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr);
269 err = -EIO; 269 err = -EIO;
270 } 270 }
271 } 271 }
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 36ab023793ca..63c35ed3c88d 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -381,7 +381,8 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)
381 SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2], 381 SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2],
382 SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]); 382 SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]);
383 if (cmdstatp->have_sense) 383 if (cmdstatp->have_sense)
384 __scsi_print_sense(name, SRpnt->sense, SCSI_SENSE_BUFFERSIZE); 384 __scsi_print_sense(STp->device, name,
385 SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
385 } ) /* end DEB */ 386 } ) /* end DEB */
386 if (!debugging) { /* Abnormal conditions for tape */ 387 if (!debugging) { /* Abnormal conditions for tape */
387 if (!cmdstatp->have_sense) 388 if (!cmdstatp->have_sense)
@@ -397,7 +398,8 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)
397 SRpnt->cmd[0] != MODE_SENSE && 398 SRpnt->cmd[0] != MODE_SENSE &&
398 SRpnt->cmd[0] != TEST_UNIT_READY) { 399 SRpnt->cmd[0] != TEST_UNIT_READY) {
399 400
400 __scsi_print_sense(name, SRpnt->sense, SCSI_SENSE_BUFFERSIZE); 401 __scsi_print_sense(STp->device, name,
402 SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
401 } 403 }
402 } 404 }
403 405
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 733e5f759518..37f5fd8ed765 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1097,7 +1097,8 @@ static void storvsc_command_completion(struct storvsc_cmd_request *cmd_request)
1097 if (scmnd->result) { 1097 if (scmnd->result) {
1098 if (scsi_normalize_sense(scmnd->sense_buffer, 1098 if (scsi_normalize_sense(scmnd->sense_buffer,
1099 SCSI_SENSE_BUFFERSIZE, &sense_hdr)) 1099 SCSI_SENSE_BUFFERSIZE, &sense_hdr))
1100 scsi_print_sense_hdr("storvsc", &sense_hdr); 1100 scsi_print_sense_hdr(scmnd->device, "storvsc",
1101 &sense_hdr);
1101 } 1102 }
1102 1103
1103 if (vm_srb->srb_status != SRB_STATUS_SUCCESS) 1104 if (vm_srb->srb_status != SRB_STATUS_SUCCESS)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 497c38a4a866..eb3997ed8e73 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -4710,8 +4710,8 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
4710 "START_STOP failed for power mode: %d\n", pwr_mode); 4710 "START_STOP failed for power mode: %d\n", pwr_mode);
4711 scsi_show_result(ret); 4711 scsi_show_result(ret);
4712 if (driver_byte(ret) & DRIVER_SENSE) { 4712 if (driver_byte(ret) & DRIVER_SENSE) {
4713 scsi_show_sense_hdr(&sshdr); 4713 scsi_show_sense_hdr(sdp, NULL, &sshdr);
4714 scsi_show_extd_sense(sshdr.asc, sshdr.ascq); 4714 scsi_show_extd_sense(sdp, NULL, sshdr.asc, sshdr.ascq);
4715 } 4715 }
4716 } 4716 }
4717 4717
diff --git a/drivers/usb/storage/debug.c b/drivers/usb/storage/debug.c
index e08f64780e30..66a684a29938 100644
--- a/drivers/usb/storage/debug.c
+++ b/drivers/usb/storage/debug.c
@@ -164,10 +164,10 @@ void usb_stor_show_sense(const struct us_data *us,
164 unsigned char asc, 164 unsigned char asc,
165 unsigned char ascq) 165 unsigned char ascq)
166{ 166{
167 const char *what, *keystr; 167 const char *what, *keystr, *fmt;
168 168
169 keystr = scsi_sense_key_string(key); 169 keystr = scsi_sense_key_string(key);
170 what = scsi_extd_sense_format(asc, ascq); 170 what = scsi_extd_sense_format(asc, ascq, &fmt);
171 171
172 if (keystr == NULL) 172 if (keystr == NULL)
173 keystr = "(Unknown Key)"; 173 keystr = "(Unknown Key)";
@@ -175,8 +175,10 @@ void usb_stor_show_sense(const struct us_data *us,
175 what = "(unknown ASC/ASCQ)"; 175 what = "(unknown ASC/ASCQ)";
176 176
177 usb_stor_dbg(us, "%s: ", keystr); 177 usb_stor_dbg(us, "%s: ", keystr);
178 US_DEBUGPX(what, ascq); 178 if (fmt)
179 US_DEBUGPX("\n"); 179 US_DEBUGPX("%s (%s%x)\n", what, fmt, ascq);
180 else
181 US_DEBUGPX("%s\n", what);
180} 182}
181 183
182int usb_stor_dbg(const struct us_data *us, const char *fmt, ...) 184int usb_stor_dbg(const struct us_data *us, const char *fmt, ...)
diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index 3e32146472a5..50610a6acf3d 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -274,10 +274,6 @@ static void scsiback_print_status(char *sense_buffer, int errors,
274 tpg->tport->tport_name, pending_req->v2p->lun, 274 tpg->tport->tport_name, pending_req->v2p->lun,
275 pending_req->cmnd[0], status_byte(errors), msg_byte(errors), 275 pending_req->cmnd[0], status_byte(errors), msg_byte(errors),
276 host_byte(errors), driver_byte(errors)); 276 host_byte(errors), driver_byte(errors));
277
278 if (CHECK_CONDITION & status_byte(errors))
279 __scsi_print_sense("xen-pvscsi", sense_buffer,
280 SCSI_SENSE_BUFFERSIZE);
281} 277}
282 278
283static void scsiback_fast_flush_area(struct vscsibk_pend *req) 279static void scsiback_fast_flush_area(struct vscsibk_pend *req)
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index 5a43a4cd96c6..6cbd179a17cc 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -2,21 +2,26 @@
2#define _SCSI_SCSI_DBG_H 2#define _SCSI_SCSI_DBG_H
3 3
4struct scsi_cmnd; 4struct scsi_cmnd;
5struct scsi_device;
5struct scsi_sense_hdr; 6struct scsi_sense_hdr;
6 7
7extern void scsi_print_command(struct scsi_cmnd *); 8extern void scsi_print_command(struct scsi_cmnd *);
8extern void __scsi_print_command(unsigned char *); 9extern void __scsi_print_command(unsigned char *);
9extern void scsi_show_extd_sense(unsigned char, unsigned char); 10extern void scsi_show_extd_sense(const struct scsi_device *, const char *,
10extern void scsi_show_sense_hdr(struct scsi_sense_hdr *); 11 unsigned char, unsigned char);
11extern void scsi_print_sense_hdr(const char *, struct scsi_sense_hdr *); 12extern void scsi_show_sense_hdr(const struct scsi_device *, const char *,
12extern void scsi_print_sense(char *, struct scsi_cmnd *); 13 const struct scsi_sense_hdr *);
13extern void __scsi_print_sense(const char *name, 14extern void scsi_print_sense_hdr(const struct scsi_device *, const char *,
15 const struct scsi_sense_hdr *);
16extern void scsi_print_sense(const struct scsi_cmnd *);
17extern void __scsi_print_sense(const struct scsi_device *, const char *name,
14 const unsigned char *sense_buffer, 18 const unsigned char *sense_buffer,
15 int sense_len); 19 int sense_len);
16extern void scsi_show_result(int); 20extern void scsi_show_result(int);
17extern void scsi_print_result(struct scsi_cmnd *); 21extern void scsi_print_result(struct scsi_cmnd *);
18extern void scsi_print_status(unsigned char); 22extern void scsi_print_status(unsigned char);
19extern const char *scsi_sense_key_string(unsigned char); 23extern const char *scsi_sense_key_string(unsigned char);
20extern const char *scsi_extd_sense_format(unsigned char, unsigned char); 24extern const char *scsi_extd_sense_format(unsigned char, unsigned char,
25 const char **);
21 26
22#endif /* _SCSI_SCSI_DBG_H */ 27#endif /* _SCSI_SCSI_DBG_H */
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index 49af14ad5288..5e598f01143c 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -47,7 +47,7 @@ extern int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
47extern int scsi_command_normalize_sense(struct scsi_cmnd *cmd, 47extern int scsi_command_normalize_sense(struct scsi_cmnd *cmd,
48 struct scsi_sense_hdr *sshdr); 48 struct scsi_sense_hdr *sshdr);
49 49
50static inline int scsi_sense_is_deferred(struct scsi_sense_hdr *sshdr) 50static inline int scsi_sense_is_deferred(const struct scsi_sense_hdr *sshdr)
51{ 51{
52 return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1)); 52 return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1));
53} 53}