diff options
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/libata-scsi.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 03b7a6dd95fe..d67c3fc98f7b 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -589,7 +589,8 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) | |||
589 | head = track % dev->heads; | 589 | head = track % dev->heads; |
590 | sect = (u32)block % dev->sectors + 1; | 590 | sect = (u32)block % dev->sectors + 1; |
591 | 591 | ||
592 | DPRINTK("block[%u] track[%u] cyl[%u] head[%u] sect[%u] \n", (u32)block, track, cyl, head, sect); | 592 | DPRINTK("block %u track %u cyl %u head %u sect %u\n", |
593 | (u32)block, track, cyl, head, sect); | ||
593 | 594 | ||
594 | /* Check whether the converted CHS can fit. | 595 | /* Check whether the converted CHS can fit. |
595 | Cylinder: 0-65535 | 596 | Cylinder: 0-65535 |
@@ -665,6 +666,10 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) | |||
665 | block |= ((u64)scsicmd[3]); | 666 | block |= ((u64)scsicmd[3]); |
666 | 667 | ||
667 | n_block |= ((u32)scsicmd[4]); | 668 | n_block |= ((u32)scsicmd[4]); |
669 | |||
670 | /* for 6-byte r/w commands, transfer length 0 | ||
671 | * means 256 blocks of data, not 0 block. | ||
672 | */ | ||
668 | if (!n_block) | 673 | if (!n_block) |
669 | n_block = 256; | 674 | n_block = 256; |
670 | 675 | ||
@@ -692,7 +697,11 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) | |||
692 | 697 | ||
693 | /* Check and compose ATA command */ | 698 | /* Check and compose ATA command */ |
694 | if (!n_block) | 699 | if (!n_block) |
695 | /* In ATA, sector count 0 means 256 or 65536 sectors, not 0 sectors. */ | 700 | /* For 10-byte and 16-byte SCSI R/W commands, transfer |
701 | * length 0 means transfer 0 block of data. | ||
702 | * However, for ATA R/W commands, sector count 0 means | ||
703 | * 256 or 65536 sectors, not 0 sectors as in SCSI. | ||
704 | */ | ||
696 | return 1; | 705 | return 1; |
697 | 706 | ||
698 | if (lba) { | 707 | if (lba) { |
@@ -715,7 +724,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) | |||
715 | 724 | ||
716 | tf->device |= (block >> 24) & 0xf; | 725 | tf->device |= (block >> 24) & 0xf; |
717 | } | 726 | } |
718 | 727 | ||
719 | qc->nsect = n_block; | 728 | qc->nsect = n_block; |
720 | tf->nsect = n_block & 0xff; | 729 | tf->nsect = n_block & 0xff; |
721 | 730 | ||
@@ -731,23 +740,23 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) | |||
731 | /* The request -may- be too large for CHS addressing. */ | 740 | /* The request -may- be too large for CHS addressing. */ |
732 | if ((block >> 28) || (n_block > 256)) | 741 | if ((block >> 28) || (n_block > 256)) |
733 | return 1; | 742 | return 1; |
734 | 743 | ||
735 | /* Convert LBA to CHS */ | 744 | /* Convert LBA to CHS */ |
736 | track = (u32)block / dev->sectors; | 745 | track = (u32)block / dev->sectors; |
737 | cyl = track / dev->heads; | 746 | cyl = track / dev->heads; |
738 | head = track % dev->heads; | 747 | head = track % dev->heads; |
739 | sect = (u32)block % dev->sectors + 1; | 748 | sect = (u32)block % dev->sectors + 1; |
740 | 749 | ||
741 | DPRINTK("block[%u] track[%u] cyl[%u] head[%u] sect[%u] \n", | 750 | DPRINTK("block %u track %u cyl %u head %u sect %u\n", |
742 | (u32)block, track, cyl, head, sect); | 751 | (u32)block, track, cyl, head, sect); |
743 | 752 | ||
744 | /* Check whether the converted CHS can fit. | 753 | /* Check whether the converted CHS can fit. |
745 | Cylinder: 0-65535 | 754 | Cylinder: 0-65535 |
746 | Head: 0-15 | 755 | Head: 0-15 |
747 | Sector: 1-255*/ | 756 | Sector: 1-255*/ |
748 | if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect)) | 757 | if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect)) |
749 | return 1; | 758 | return 1; |
750 | 759 | ||
751 | qc->nsect = n_block; | 760 | qc->nsect = n_block; |
752 | tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */ | 761 | tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */ |
753 | tf->lbal = sect; | 762 | tf->lbal = sect; |