diff options
author | Tejun Heo <htejun@gmail.com> | 2006-02-12 09:32:58 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2006-02-12 14:29:10 -0500 |
commit | 6e7846e9c548443c86cfbad9e4defb4bdcfc538b (patch) | |
tree | f92fe0c3ca0000ad7d68bb3caae10d2066a7f78e | |
parent | 8eabd02c246b808e0e27c3ee9ea17d0349efb06d (diff) |
[PATCH] libata: move cdb_len for host to device
cdb_len is per-device property. Sharing cdb_len on ap results in
inaccurate configuration on revalidation and hotplugging. This patch
makes cdb_len per-device.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
-rw-r--r-- | drivers/scsi/ahci.c | 3 | ||||
-rw-r--r-- | drivers/scsi/libata-core.c | 19 | ||||
-rw-r--r-- | drivers/scsi/libata-scsi.c | 4 | ||||
-rw-r--r-- | drivers/scsi/sata_sil24.c | 4 | ||||
-rw-r--r-- | include/linux/libata.h | 2 |
5 files changed, 19 insertions, 13 deletions
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index 24a54a5a91b8..23caa0c4019b 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c | |||
@@ -617,7 +617,8 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc) | |||
617 | ata_tf_to_fis(&qc->tf, pp->cmd_tbl, 0); | 617 | ata_tf_to_fis(&qc->tf, pp->cmd_tbl, 0); |
618 | if (is_atapi) { | 618 | if (is_atapi) { |
619 | memset(pp->cmd_tbl + AHCI_CMD_TBL_CDB, 0, 32); | 619 | memset(pp->cmd_tbl + AHCI_CMD_TBL_CDB, 0, 32); |
620 | memcpy(pp->cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, ap->cdb_len); | 620 | memcpy(pp->cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, |
621 | qc->dev->cdb_len); | ||
621 | } | 622 | } |
622 | 623 | ||
623 | n_elem = 0; | 624 | n_elem = 0; |
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 5e8a32052a1e..1a373b4d0e22 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -931,7 +931,7 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) | |||
931 | unsigned int using_edd; | 931 | unsigned int using_edd; |
932 | struct ata_taskfile tf; | 932 | struct ata_taskfile tf; |
933 | unsigned int err_mask; | 933 | unsigned int err_mask; |
934 | int rc; | 934 | int i, rc; |
935 | 935 | ||
936 | if (!ata_dev_present(dev)) { | 936 | if (!ata_dev_present(dev)) { |
937 | DPRINTK("ENTER/EXIT (host %u, dev %u) -- nodev\n", | 937 | DPRINTK("ENTER/EXIT (host %u, dev %u) -- nodev\n", |
@@ -1087,7 +1087,7 @@ retry: | |||
1087 | 1087 | ||
1088 | } | 1088 | } |
1089 | 1089 | ||
1090 | ap->host->max_cmd_len = 16; | 1090 | dev->cdb_len = 16; |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | /* ATAPI-specific feature tests */ | 1093 | /* ATAPI-specific feature tests */ |
@@ -1100,8 +1100,7 @@ retry: | |||
1100 | printk(KERN_WARNING "ata%u: unsupported CDB len\n", ap->id); | 1100 | printk(KERN_WARNING "ata%u: unsupported CDB len\n", ap->id); |
1101 | goto err_out_nosup; | 1101 | goto err_out_nosup; |
1102 | } | 1102 | } |
1103 | ap->cdb_len = (unsigned int) rc; | 1103 | dev->cdb_len = (unsigned int) rc; |
1104 | ap->host->max_cmd_len = (unsigned char) ap->cdb_len; | ||
1105 | 1104 | ||
1106 | /* print device info to dmesg */ | 1105 | /* print device info to dmesg */ |
1107 | printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n", | 1106 | printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n", |
@@ -1109,6 +1108,12 @@ retry: | |||
1109 | ata_mode_string(xfer_modes)); | 1108 | ata_mode_string(xfer_modes)); |
1110 | } | 1109 | } |
1111 | 1110 | ||
1111 | ap->host->max_cmd_len = 0; | ||
1112 | for (i = 0; i < ATA_MAX_DEVICES; i++) | ||
1113 | ap->host->max_cmd_len = max_t(unsigned int, | ||
1114 | ap->host->max_cmd_len, | ||
1115 | ap->device[i].cdb_len); | ||
1116 | |||
1112 | DPRINTK("EXIT, drv_stat = 0x%x\n", ata_chk_status(ap)); | 1117 | DPRINTK("EXIT, drv_stat = 0x%x\n", ata_chk_status(ap)); |
1113 | return; | 1118 | return; |
1114 | 1119 | ||
@@ -4203,7 +4208,7 @@ static void atapi_packet_task(void *_data) | |||
4203 | 4208 | ||
4204 | /* send SCSI cdb */ | 4209 | /* send SCSI cdb */ |
4205 | DPRINTK("send cdb\n"); | 4210 | DPRINTK("send cdb\n"); |
4206 | WARN_ON(ap->cdb_len < 12); | 4211 | WARN_ON(qc->dev->cdb_len < 12); |
4207 | 4212 | ||
4208 | if (qc->tf.protocol == ATA_PROT_ATAPI_DMA || | 4213 | if (qc->tf.protocol == ATA_PROT_ATAPI_DMA || |
4209 | qc->tf.protocol == ATA_PROT_ATAPI_NODATA) { | 4214 | qc->tf.protocol == ATA_PROT_ATAPI_NODATA) { |
@@ -4217,12 +4222,12 @@ static void atapi_packet_task(void *_data) | |||
4217 | */ | 4222 | */ |
4218 | spin_lock_irqsave(&ap->host_set->lock, flags); | 4223 | spin_lock_irqsave(&ap->host_set->lock, flags); |
4219 | ap->flags &= ~ATA_FLAG_NOINTR; | 4224 | ap->flags &= ~ATA_FLAG_NOINTR; |
4220 | ata_data_xfer(ap, qc->cdb, ap->cdb_len, 1); | 4225 | ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1); |
4221 | if (qc->tf.protocol == ATA_PROT_ATAPI_DMA) | 4226 | if (qc->tf.protocol == ATA_PROT_ATAPI_DMA) |
4222 | ap->ops->bmdma_start(qc); /* initiate bmdma */ | 4227 | ap->ops->bmdma_start(qc); /* initiate bmdma */ |
4223 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | 4228 | spin_unlock_irqrestore(&ap->host_set->lock, flags); |
4224 | } else { | 4229 | } else { |
4225 | ata_data_xfer(ap, qc->cdb, ap->cdb_len, 1); | 4230 | ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1); |
4226 | 4231 | ||
4227 | /* PIO commands are handled by polling */ | 4232 | /* PIO commands are handled by polling */ |
4228 | ap->hsm_task_state = HSM_ST; | 4233 | ap->hsm_task_state = HSM_ST; |
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index ebd7cf42550b..3628fedc9865 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -2146,7 +2146,7 @@ static void atapi_request_sense(struct ata_queued_cmd *qc) | |||
2146 | ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer)); | 2146 | ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer)); |
2147 | qc->dma_dir = DMA_FROM_DEVICE; | 2147 | qc->dma_dir = DMA_FROM_DEVICE; |
2148 | 2148 | ||
2149 | memset(&qc->cdb, 0, ap->cdb_len); | 2149 | memset(&qc->cdb, 0, qc->dev->cdb_len); |
2150 | qc->cdb[0] = REQUEST_SENSE; | 2150 | qc->cdb[0] = REQUEST_SENSE; |
2151 | qc->cdb[4] = SCSI_SENSE_BUFFERSIZE; | 2151 | qc->cdb[4] = SCSI_SENSE_BUFFERSIZE; |
2152 | 2152 | ||
@@ -2248,7 +2248,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd) | |||
2248 | if (ata_check_atapi_dma(qc)) | 2248 | if (ata_check_atapi_dma(qc)) |
2249 | using_pio = 1; | 2249 | using_pio = 1; |
2250 | 2250 | ||
2251 | memcpy(&qc->cdb, scsicmd, qc->ap->cdb_len); | 2251 | memcpy(&qc->cdb, scsicmd, dev->cdb_len); |
2252 | 2252 | ||
2253 | qc->complete_fn = atapi_qc_complete; | 2253 | qc->complete_fn = atapi_qc_complete; |
2254 | 2254 | ||
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c index 228a7fabffff..24020c68903a 100644 --- a/drivers/scsi/sata_sil24.c +++ b/drivers/scsi/sata_sil24.c | |||
@@ -371,7 +371,7 @@ static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev) | |||
371 | { | 371 | { |
372 | void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; | 372 | void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; |
373 | 373 | ||
374 | if (ap->cdb_len == 16) | 374 | if (dev->cdb_len == 16) |
375 | writel(PORT_CS_CDB16, port + PORT_CTRL_STAT); | 375 | writel(PORT_CS_CDB16, port + PORT_CTRL_STAT); |
376 | else | 376 | else |
377 | writel(PORT_CS_CDB16, port + PORT_CTRL_CLR); | 377 | writel(PORT_CS_CDB16, port + PORT_CTRL_CLR); |
@@ -543,7 +543,7 @@ static void sil24_qc_prep(struct ata_queued_cmd *qc) | |||
543 | prb = &cb->atapi.prb; | 543 | prb = &cb->atapi.prb; |
544 | sge = cb->atapi.sge; | 544 | sge = cb->atapi.sge; |
545 | memset(cb->atapi.cdb, 0, 32); | 545 | memset(cb->atapi.cdb, 0, 32); |
546 | memcpy(cb->atapi.cdb, qc->cdb, ap->cdb_len); | 546 | memcpy(cb->atapi.cdb, qc->cdb, qc->dev->cdb_len); |
547 | 547 | ||
548 | if (qc->tf.protocol != ATA_PROT_ATAPI_NODATA) { | 548 | if (qc->tf.protocol != ATA_PROT_ATAPI_NODATA) { |
549 | if (qc->tf.flags & ATA_TFLAG_WRITE) | 549 | if (qc->tf.flags & ATA_TFLAG_WRITE) |
diff --git a/include/linux/libata.h b/include/linux/libata.h index 0853032673b7..853c98859a9f 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -348,6 +348,7 @@ struct ata_device { | |||
348 | 348 | ||
349 | unsigned int multi_count; /* sectors count for | 349 | unsigned int multi_count; /* sectors count for |
350 | READ/WRITE MULTIPLE */ | 350 | READ/WRITE MULTIPLE */ |
351 | unsigned int cdb_len; | ||
351 | 352 | ||
352 | /* for CHS addressing */ | 353 | /* for CHS addressing */ |
353 | u16 cylinders; /* Number of cylinders */ | 354 | u16 cylinders; /* Number of cylinders */ |
@@ -377,7 +378,6 @@ struct ata_port { | |||
377 | unsigned int mwdma_mask; | 378 | unsigned int mwdma_mask; |
378 | unsigned int udma_mask; | 379 | unsigned int udma_mask; |
379 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ | 380 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ |
380 | unsigned int cdb_len; | ||
381 | 381 | ||
382 | struct ata_device device[ATA_MAX_DEVICES]; | 382 | struct ata_device device[ATA_MAX_DEVICES]; |
383 | 383 | ||