aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libata-scsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/libata-scsi.c')
-rw-r--r--drivers/scsi/libata-scsi.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 6a75ec2187fd..4074e7877ba3 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -392,6 +392,60 @@ int ata_scsi_error(struct Scsi_Host *host)
392} 392}
393 393
394/** 394/**
395 * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command
396 * @qc: Storage for translated ATA taskfile
397 * @scsicmd: SCSI command to translate
398 *
399 * Sets up an ATA taskfile to issue STANDBY (to stop) or READ VERIFY
400 * (to start). Perhaps these commands should be preceded by
401 * CHECK POWER MODE to see what power mode the device is already in.
402 * [See SAT revision 5 at www.t10.org]
403 *
404 * LOCKING:
405 * spin_lock_irqsave(host_set lock)
406 *
407 * RETURNS:
408 * Zero on success, non-zero on error.
409 */
410
411static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc,
412 u8 *scsicmd)
413{
414 struct ata_taskfile *tf = &qc->tf;
415
416 tf->flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR;
417 tf->protocol = ATA_PROT_NODATA;
418 if (scsicmd[1] & 0x1) {
419 ; /* ignore IMMED bit, violates sat-r05 */
420 }
421 if (scsicmd[4] & 0x2)
422 return 1; /* LOEJ bit set not supported */
423 if (((scsicmd[4] >> 4) & 0xf) != 0)
424 return 1; /* power conditions not supported */
425 if (scsicmd[4] & 0x1) {
426 tf->nsect = 1; /* 1 sector, lba=0 */
427 tf->lbah = 0x0;
428 tf->lbam = 0x0;
429 tf->lbal = 0x0;
430 tf->device |= ATA_LBA;
431 tf->command = ATA_CMD_VERIFY; /* READ VERIFY */
432 } else {
433 tf->nsect = 0; /* time period value (0 implies now) */
434 tf->command = ATA_CMD_STANDBY;
435 /* Consider: ATA STANDBY IMMEDIATE command */
436 }
437 /*
438 * Standby and Idle condition timers could be implemented but that
439 * would require libata to implement the Power condition mode page
440 * and allow the user to change it. Changing mode pages requires
441 * MODE SELECT to be implemented.
442 */
443
444 return 0;
445}
446
447
448/**
395 * ata_scsi_flush_xlat - Translate SCSI SYNCHRONIZE CACHE command 449 * ata_scsi_flush_xlat - Translate SCSI SYNCHRONIZE CACHE command
396 * @qc: Storage for translated ATA taskfile 450 * @qc: Storage for translated ATA taskfile
397 * @scsicmd: SCSI command to translate (ignored) 451 * @scsicmd: SCSI command to translate (ignored)
@@ -576,11 +630,19 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd)
576 tf->lbah = scsicmd[3]; 630 tf->lbah = scsicmd[3];
577 631
578 VPRINTK("ten-byte command\n"); 632 VPRINTK("ten-byte command\n");
633 if (qc->nsect == 0) /* we don't support length==0 cmds */
634 return 1;
579 return 0; 635 return 0;
580 } 636 }
581 637
582 if (scsicmd[0] == READ_6 || scsicmd[0] == WRITE_6) { 638 if (scsicmd[0] == READ_6 || scsicmd[0] == WRITE_6) {
583 qc->nsect = tf->nsect = scsicmd[4]; 639 qc->nsect = tf->nsect = scsicmd[4];
640 if (!qc->nsect) {
641 qc->nsect = 256;
642 if (lba48)
643 tf->hob_nsect = 1;
644 }
645
584 tf->lbal = scsicmd[3]; 646 tf->lbal = scsicmd[3];
585 tf->lbam = scsicmd[2]; 647 tf->lbam = scsicmd[2];
586 tf->lbah = scsicmd[1] & 0x1f; /* mask out reserved bits */ 648 tf->lbah = scsicmd[1] & 0x1f; /* mask out reserved bits */
@@ -620,6 +682,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd)
620 tf->lbah = scsicmd[7]; 682 tf->lbah = scsicmd[7];
621 683
622 VPRINTK("sixteen-byte command\n"); 684 VPRINTK("sixteen-byte command\n");
685 if (qc->nsect == 0) /* we don't support length==0 cmds */
686 return 1;
623 return 0; 687 return 0;
624 } 688 }
625 689
@@ -1435,6 +1499,8 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)
1435 case VERIFY: 1499 case VERIFY:
1436 case VERIFY_16: 1500 case VERIFY_16:
1437 return ata_scsi_verify_xlat; 1501 return ata_scsi_verify_xlat;
1502 case START_STOP:
1503 return ata_scsi_start_stop_xlat;
1438 } 1504 }
1439 1505
1440 return NULL; 1506 return NULL;