diff options
author | Mark Lord <liml@rtr.ca> | 2007-02-02 12:36:25 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-04-28 14:15:55 -0400 |
commit | f0ef88ed413232daebfe675c7b1bbf100d604d4b (patch) | |
tree | fc235d7aede0d6c4d2e500ef5d0446122eaa611a | |
parent | cd0d3bbcdd650651b7ccfaf55d107e3fc237d95a (diff) |
RESEND: libata: check cdb len per dev instead of per host
Resending, with s/printk/DPRINTK/ as pointed out by Alan.
Fix libata to perform CDB len validation per device
rather than per host. This way, validation still works
when we have a mix of 12-byte and 16-byte devices on
a common host interface.
Signed-off-by: Mark Lord <mlord@pobox.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r-- | drivers/ata/libata-core.c | 18 | ||||
-rw-r--r-- | drivers/ata/libata-scsi.c | 5 |
2 files changed, 4 insertions, 19 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 2b998b321881..99a881558e8d 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -1560,20 +1560,6 @@ static void ata_dev_config_ncq(struct ata_device *dev, | |||
1560 | snprintf(desc, desc_sz, "NCQ (depth %d/%d)", hdepth, ddepth); | 1560 | snprintf(desc, desc_sz, "NCQ (depth %d/%d)", hdepth, ddepth); |
1561 | } | 1561 | } |
1562 | 1562 | ||
1563 | static void ata_set_port_max_cmd_len(struct ata_port *ap) | ||
1564 | { | ||
1565 | int i; | ||
1566 | |||
1567 | if (ap->scsi_host) { | ||
1568 | unsigned int len = 0; | ||
1569 | |||
1570 | for (i = 0; i < ATA_MAX_DEVICES; i++) | ||
1571 | len = max(len, ap->device[i].cdb_len); | ||
1572 | |||
1573 | ap->scsi_host->max_cmd_len = len; | ||
1574 | } | ||
1575 | } | ||
1576 | |||
1577 | /** | 1563 | /** |
1578 | * ata_dev_configure - Configure the specified ATA/ATAPI device | 1564 | * ata_dev_configure - Configure the specified ATA/ATAPI device |
1579 | * @dev: Target device to configure | 1565 | * @dev: Target device to configure |
@@ -1773,8 +1759,6 @@ int ata_dev_configure(struct ata_device *dev) | |||
1773 | } | 1759 | } |
1774 | } | 1760 | } |
1775 | 1761 | ||
1776 | ata_set_port_max_cmd_len(ap); | ||
1777 | |||
1778 | /* limit bridge transfers to udma5, 200 sectors */ | 1762 | /* limit bridge transfers to udma5, 200 sectors */ |
1779 | if (ata_dev_knobble(dev)) { | 1763 | if (ata_dev_knobble(dev)) { |
1780 | if (ata_msg_drv(ap) && print_info) | 1764 | if (ata_msg_drv(ap) && print_info) |
@@ -5670,7 +5654,7 @@ static void ata_port_init_shost(struct ata_port *ap, struct Scsi_Host *shost) | |||
5670 | shost->max_id = 16; | 5654 | shost->max_id = 16; |
5671 | shost->max_lun = 1; | 5655 | shost->max_lun = 1; |
5672 | shost->max_channel = 1; | 5656 | shost->max_channel = 1; |
5673 | shost->max_cmd_len = 12; | 5657 | shost->max_cmd_len = 16; |
5674 | } | 5658 | } |
5675 | 5659 | ||
5676 | /** | 5660 | /** |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index e9364434182c..7d41afe8ccbc 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -2792,8 +2792,9 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, | |||
2792 | { | 2792 | { |
2793 | int rc = 0; | 2793 | int rc = 0; |
2794 | 2794 | ||
2795 | if (unlikely(!scmd->cmd_len)) { | 2795 | if (unlikely(!scmd->cmd_len || scmd->cmd_len > dev->cdb_len)) { |
2796 | ata_dev_printk(dev, KERN_WARNING, "WARNING: zero len CDB\n"); | 2796 | DPRINTK("bad CDB len=%u, max=%u\n", |
2797 | scmd->cmd_len, dev->cdb_len); | ||
2797 | scmd->result = DID_ERROR << 16; | 2798 | scmd->result = DID_ERROR << 16; |
2798 | done(scmd); | 2799 | done(scmd); |
2799 | return 0; | 2800 | return 0; |