aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/libata-scsi.c48
1 files changed, 37 insertions, 11 deletions
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index fd7064b9697d..e61cc357ae4a 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -415,6 +415,7 @@ int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t state)
415 * @sk: the sense key we'll fill out 415 * @sk: the sense key we'll fill out
416 * @asc: the additional sense code we'll fill out 416 * @asc: the additional sense code we'll fill out
417 * @ascq: the additional sense code qualifier we'll fill out 417 * @ascq: the additional sense code qualifier we'll fill out
418 * @verbose: be verbose
418 * 419 *
419 * Converts an ATA error into a SCSI error. Fill out pointers to 420 * Converts an ATA error into a SCSI error. Fill out pointers to
420 * SK, ASC, and ASCQ bytes for later use in fixed or descriptor 421 * SK, ASC, and ASCQ bytes for later use in fixed or descriptor
@@ -424,7 +425,7 @@ int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t state)
424 * spin_lock_irqsave(host_set lock) 425 * spin_lock_irqsave(host_set lock)
425 */ 426 */
426void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, 427void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
427 u8 *ascq) 428 u8 *ascq, int verbose)
428{ 429{
429 int i; 430 int i;
430 431
@@ -489,8 +490,9 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
489 } 490 }
490 } 491 }
491 /* No immediate match */ 492 /* No immediate match */
492 printk(KERN_WARNING "ata%u: no sense translation for " 493 if (verbose)
493 "error 0x%02x\n", id, drv_err); 494 printk(KERN_WARNING "ata%u: no sense translation for "
495 "error 0x%02x\n", id, drv_err);
494 } 496 }
495 497
496 /* Fall back to interpreting status bits */ 498 /* Fall back to interpreting status bits */
@@ -503,8 +505,9 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
503 } 505 }
504 } 506 }
505 /* No error? Undecoded? */ 507 /* No error? Undecoded? */
506 printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n", 508 if (verbose)
507 id, drv_stat); 509 printk(KERN_WARNING "ata%u: no sense translation for "
510 "status: 0x%02x\n", id, drv_stat);
508 511
509 /* We need a sensible error return here, which is tricky, and one 512 /* We need a sensible error return here, which is tricky, and one
510 that won't cause people to do things like return a disk wrongly */ 513 that won't cause people to do things like return a disk wrongly */
@@ -513,9 +516,10 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
513 *ascq = 0x00; 516 *ascq = 0x00;
514 517
515 translate_done: 518 translate_done:
516 printk(KERN_ERR "ata%u: translated ATA stat/err 0x%02x/%02x to " 519 if (verbose)
517 "SCSI SK/ASC/ASCQ 0x%x/%02x/%02x\n", id, drv_stat, drv_err, 520 printk(KERN_ERR "ata%u: translated ATA stat/err 0x%02x/%02x "
518 *sk, *asc, *ascq); 521 "to SCSI SK/ASC/ASCQ 0x%x/%02x/%02x\n",
522 id, drv_stat, drv_err, *sk, *asc, *ascq);
519 return; 523 return;
520} 524}
521 525
@@ -538,6 +542,7 @@ void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc)
538 struct ata_taskfile *tf = &qc->result_tf; 542 struct ata_taskfile *tf = &qc->result_tf;
539 unsigned char *sb = cmd->sense_buffer; 543 unsigned char *sb = cmd->sense_buffer;
540 unsigned char *desc = sb + 8; 544 unsigned char *desc = sb + 8;
545 int verbose = qc->ap->ops->error_handler == NULL;
541 546
542 memset(sb, 0, SCSI_SENSE_BUFFERSIZE); 547 memset(sb, 0, SCSI_SENSE_BUFFERSIZE);
543 548
@@ -550,7 +555,7 @@ void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc)
550 if (qc->err_mask || 555 if (qc->err_mask ||
551 tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { 556 tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) {
552 ata_to_sense_error(qc->ap->id, tf->command, tf->feature, 557 ata_to_sense_error(qc->ap->id, tf->command, tf->feature,
553 &sb[1], &sb[2], &sb[3]); 558 &sb[1], &sb[2], &sb[3], verbose);
554 sb[1] &= 0x0f; 559 sb[1] &= 0x0f;
555 } 560 }
556 561
@@ -608,6 +613,7 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
608 struct scsi_cmnd *cmd = qc->scsicmd; 613 struct scsi_cmnd *cmd = qc->scsicmd;
609 struct ata_taskfile *tf = &qc->result_tf; 614 struct ata_taskfile *tf = &qc->result_tf;
610 unsigned char *sb = cmd->sense_buffer; 615 unsigned char *sb = cmd->sense_buffer;
616 int verbose = qc->ap->ops->error_handler == NULL;
611 617
612 memset(sb, 0, SCSI_SENSE_BUFFERSIZE); 618 memset(sb, 0, SCSI_SENSE_BUFFERSIZE);
613 619
@@ -620,7 +626,7 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
620 if (qc->err_mask || 626 if (qc->err_mask ||
621 tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { 627 tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) {
622 ata_to_sense_error(qc->ap->id, tf->command, tf->feature, 628 ata_to_sense_error(qc->ap->id, tf->command, tf->feature,
623 &sb[2], &sb[12], &sb[13]); 629 &sb[2], &sb[12], &sb[13], verbose);
624 sb[2] &= 0x0f; 630 sb[2] &= 0x0f;
625 } 631 }
626 632
@@ -1212,7 +1218,7 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1212 } 1218 }
1213 } 1219 }
1214 1220
1215 if (need_sense) 1221 if (need_sense && !qc->ap->ops->error_handler)
1216 ata_dump_status(qc->ap->id, &qc->result_tf); 1222 ata_dump_status(qc->ap->id, &qc->result_tf);
1217 1223
1218 qc->scsidone(cmd); 1224 qc->scsidone(cmd);
@@ -2060,6 +2066,26 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
2060 2066
2061 VPRINTK("ENTER, err_mask 0x%X\n", err_mask); 2067 VPRINTK("ENTER, err_mask 0x%X\n", err_mask);
2062 2068
2069 /* handle completion from new EH */
2070 if (unlikely(qc->ap->ops->error_handler &&
2071 (err_mask || qc->flags & ATA_QCFLAG_SENSE_VALID))) {
2072
2073 if (!(qc->flags & ATA_QCFLAG_SENSE_VALID)) {
2074 /* FIXME: not quite right; we don't want the
2075 * translation of taskfile registers into a
2076 * sense descriptors, since that's only
2077 * correct for ATA, not ATAPI
2078 */
2079 ata_gen_ata_desc_sense(qc);
2080 }
2081
2082 qc->scsicmd->result = SAM_STAT_CHECK_CONDITION;
2083 qc->scsidone(cmd);
2084 ata_qc_free(qc);
2085 return;
2086 }
2087
2088 /* successful completion or old EH failure path */
2063 if (unlikely(err_mask & AC_ERR_DEV)) { 2089 if (unlikely(err_mask & AC_ERR_DEV)) {
2064 cmd->result = SAM_STAT_CHECK_CONDITION; 2090 cmd->result = SAM_STAT_CHECK_CONDITION;
2065 atapi_request_sense(qc); 2091 atapi_request_sense(qc);