Skip to content

Commit

Permalink
libata: increase 128 KB / cmd limit for ATAPI tape drives
Browse files Browse the repository at this point in the history
Commands sent to ATAPI tape drives via the SCSI generic (sg) driver are
limited in the amount of data that they can transfer by the max_sectors
value.  The max_sectors value is currently calculated according to the
command set for disk drives, which doesn't apply to tape drives.  The
default max_sectors value of 256 limits ATAPI tape drive commands to
128 KB.  This patch against 2.6.24-rc1 increases the max_sectors value
for tape drives to 65535, which permits tape drive commands to transfer
just under 32 MB.

Tested with a SuperMicro PDSME motherboard, AHCI, and a Sony SDX-570V
SATA tape drive.

Note that some of the chipset drivers also set their own max_sectors
value, which may override the value set in libata-core.  I don't have
any of these chipsets to test, so I didn't go messing with them.  Also,
ATAPI devices other than tape drives may benefit from similar changes,
but I have only tape drives and disk drives to test.

Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
  • Loading branch information
Tony Battersby authored and Jeff Garzik committed Nov 3, 2007
1 parent 03116d6 commit f8d8e57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/ata/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2304,6 +2304,10 @@ int ata_dev_configure(struct ata_device *dev)
dev->max_sectors = ATA_MAX_SECTORS;
}

if ((dev->class == ATA_DEV_ATAPI) &&
(atapi_command_packet_set(id) == TYPE_TAPE))
dev->max_sectors = ATA_MAX_SECTORS_TAPE;

if (dev->horkage & ATA_HORKAGE_MAX_SEC_128)
dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128,
dev->max_sectors);
Expand Down
6 changes: 6 additions & 0 deletions include/linux/ata.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ enum {
ATA_MAX_SECTORS_128 = 128,
ATA_MAX_SECTORS = 256,
ATA_MAX_SECTORS_LBA48 = 65535,/* TODO: 65536? */
ATA_MAX_SECTORS_TAPE = 65535,

ATA_ID_WORDS = 256,
ATA_ID_SERNO = 10,
Expand Down Expand Up @@ -544,6 +545,11 @@ static inline int atapi_cdb_len(const u16 *dev_id)
}
}

static inline int atapi_command_packet_set(const u16 *dev_id)
{
return (dev_id[0] >> 8) & 0x1f;
}

static inline int is_atapi_taskfile(const struct ata_taskfile *tf)
{
return (tf->protocol == ATA_PROT_ATAPI) ||
Expand Down

0 comments on commit f8d8e57

Please sign in to comment.