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.c48
1 files changed, 21 insertions, 27 deletions
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index cfbceb504718..0e65bfe92e6f 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -985,9 +985,13 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc
985 if (dev->flags & ATA_DFLAG_LBA) { 985 if (dev->flags & ATA_DFLAG_LBA) {
986 tf->flags |= ATA_TFLAG_LBA; 986 tf->flags |= ATA_TFLAG_LBA;
987 987
988 if (dev->flags & ATA_DFLAG_LBA48) { 988 if (lba_28_ok(block, n_block)) {
989 if (n_block > (64 * 1024)) 989 /* use LBA28 */
990 goto invalid_fld; 990 tf->command = ATA_CMD_VERIFY;
991 tf->device |= (block >> 24) & 0xf;
992 } else if (lba_48_ok(block, n_block)) {
993 if (!(dev->flags & ATA_DFLAG_LBA48))
994 goto out_of_range;
991 995
992 /* use LBA48 */ 996 /* use LBA48 */
993 tf->flags |= ATA_TFLAG_LBA48; 997 tf->flags |= ATA_TFLAG_LBA48;
@@ -998,15 +1002,9 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc
998 tf->hob_lbah = (block >> 40) & 0xff; 1002 tf->hob_lbah = (block >> 40) & 0xff;
999 tf->hob_lbam = (block >> 32) & 0xff; 1003 tf->hob_lbam = (block >> 32) & 0xff;
1000 tf->hob_lbal = (block >> 24) & 0xff; 1004 tf->hob_lbal = (block >> 24) & 0xff;
1001 } else { 1005 } else
1002 if (n_block > 256) 1006 /* request too large even for LBA48 */
1003 goto invalid_fld; 1007 goto out_of_range;
1004
1005 /* use LBA28 */
1006 tf->command = ATA_CMD_VERIFY;
1007
1008 tf->device |= (block >> 24) & 0xf;
1009 }
1010 1008
1011 tf->nsect = n_block & 0xff; 1009 tf->nsect = n_block & 0xff;
1012 1010
@@ -1019,8 +1017,8 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc
1019 /* CHS */ 1017 /* CHS */
1020 u32 sect, head, cyl, track; 1018 u32 sect, head, cyl, track;
1021 1019
1022 if (n_block > 256) 1020 if (!lba_28_ok(block, n_block))
1023 goto invalid_fld; 1021 goto out_of_range;
1024 1022
1025 /* Convert LBA to CHS */ 1023 /* Convert LBA to CHS */
1026 track = (u32)block / dev->sectors; 1024 track = (u32)block / dev->sectors;
@@ -1139,9 +1137,11 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1139 if (dev->flags & ATA_DFLAG_LBA) { 1137 if (dev->flags & ATA_DFLAG_LBA) {
1140 tf->flags |= ATA_TFLAG_LBA; 1138 tf->flags |= ATA_TFLAG_LBA;
1141 1139
1142 if (dev->flags & ATA_DFLAG_LBA48) { 1140 if (lba_28_ok(block, n_block)) {
1143 /* The request -may- be too large for LBA48. */ 1141 /* use LBA28 */
1144 if ((block >> 48) || (n_block > 65536)) 1142 tf->device |= (block >> 24) & 0xf;
1143 } else if (lba_48_ok(block, n_block)) {
1144 if (!(dev->flags & ATA_DFLAG_LBA48))
1145 goto out_of_range; 1145 goto out_of_range;
1146 1146
1147 /* use LBA48 */ 1147 /* use LBA48 */
@@ -1152,15 +1152,9 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1152 tf->hob_lbah = (block >> 40) & 0xff; 1152 tf->hob_lbah = (block >> 40) & 0xff;
1153 tf->hob_lbam = (block >> 32) & 0xff; 1153 tf->hob_lbam = (block >> 32) & 0xff;
1154 tf->hob_lbal = (block >> 24) & 0xff; 1154 tf->hob_lbal = (block >> 24) & 0xff;
1155 } else { 1155 } else
1156 /* use LBA28 */ 1156 /* request too large even for LBA48 */
1157 1157 goto out_of_range;
1158 /* The request -may- be too large for LBA28. */
1159 if ((block >> 28) || (n_block > 256))
1160 goto out_of_range;
1161
1162 tf->device |= (block >> 24) & 0xf;
1163 }
1164 1158
1165 if (unlikely(ata_rwcmd_protocol(qc) < 0)) 1159 if (unlikely(ata_rwcmd_protocol(qc) < 0))
1166 goto invalid_fld; 1160 goto invalid_fld;
@@ -1178,7 +1172,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1178 u32 sect, head, cyl, track; 1172 u32 sect, head, cyl, track;
1179 1173
1180 /* The request -may- be too large for CHS addressing. */ 1174 /* The request -may- be too large for CHS addressing. */
1181 if ((block >> 28) || (n_block > 256)) 1175 if (!lba_28_ok(block, n_block))
1182 goto out_of_range; 1176 goto out_of_range;
1183 1177
1184 if (unlikely(ata_rwcmd_protocol(qc) < 0)) 1178 if (unlikely(ata_rwcmd_protocol(qc) < 0))