forked from Minki/linux
[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>
This commit is contained in:
parent
8eabd02c24
commit
6e7846e9c5
@ -617,7 +617,8 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
|
||||
ata_tf_to_fis(&qc->tf, pp->cmd_tbl, 0);
|
||||
if (is_atapi) {
|
||||
memset(pp->cmd_tbl + AHCI_CMD_TBL_CDB, 0, 32);
|
||||
memcpy(pp->cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, ap->cdb_len);
|
||||
memcpy(pp->cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb,
|
||||
qc->dev->cdb_len);
|
||||
}
|
||||
|
||||
n_elem = 0;
|
||||
|
@ -931,7 +931,7 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
|
||||
unsigned int using_edd;
|
||||
struct ata_taskfile tf;
|
||||
unsigned int err_mask;
|
||||
int rc;
|
||||
int i, rc;
|
||||
|
||||
if (!ata_dev_present(dev)) {
|
||||
DPRINTK("ENTER/EXIT (host %u, dev %u) -- nodev\n",
|
||||
@ -1087,7 +1087,7 @@ retry:
|
||||
|
||||
}
|
||||
|
||||
ap->host->max_cmd_len = 16;
|
||||
dev->cdb_len = 16;
|
||||
}
|
||||
|
||||
/* ATAPI-specific feature tests */
|
||||
@ -1100,8 +1100,7 @@ retry:
|
||||
printk(KERN_WARNING "ata%u: unsupported CDB len\n", ap->id);
|
||||
goto err_out_nosup;
|
||||
}
|
||||
ap->cdb_len = (unsigned int) rc;
|
||||
ap->host->max_cmd_len = (unsigned char) ap->cdb_len;
|
||||
dev->cdb_len = (unsigned int) rc;
|
||||
|
||||
/* print device info to dmesg */
|
||||
printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n",
|
||||
@ -1109,6 +1108,12 @@ retry:
|
||||
ata_mode_string(xfer_modes));
|
||||
}
|
||||
|
||||
ap->host->max_cmd_len = 0;
|
||||
for (i = 0; i < ATA_MAX_DEVICES; i++)
|
||||
ap->host->max_cmd_len = max_t(unsigned int,
|
||||
ap->host->max_cmd_len,
|
||||
ap->device[i].cdb_len);
|
||||
|
||||
DPRINTK("EXIT, drv_stat = 0x%x\n", ata_chk_status(ap));
|
||||
return;
|
||||
|
||||
@ -4203,7 +4208,7 @@ static void atapi_packet_task(void *_data)
|
||||
|
||||
/* send SCSI cdb */
|
||||
DPRINTK("send cdb\n");
|
||||
WARN_ON(ap->cdb_len < 12);
|
||||
WARN_ON(qc->dev->cdb_len < 12);
|
||||
|
||||
if (qc->tf.protocol == ATA_PROT_ATAPI_DMA ||
|
||||
qc->tf.protocol == ATA_PROT_ATAPI_NODATA) {
|
||||
@ -4217,12 +4222,12 @@ static void atapi_packet_task(void *_data)
|
||||
*/
|
||||
spin_lock_irqsave(&ap->host_set->lock, flags);
|
||||
ap->flags &= ~ATA_FLAG_NOINTR;
|
||||
ata_data_xfer(ap, qc->cdb, ap->cdb_len, 1);
|
||||
ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1);
|
||||
if (qc->tf.protocol == ATA_PROT_ATAPI_DMA)
|
||||
ap->ops->bmdma_start(qc); /* initiate bmdma */
|
||||
spin_unlock_irqrestore(&ap->host_set->lock, flags);
|
||||
} else {
|
||||
ata_data_xfer(ap, qc->cdb, ap->cdb_len, 1);
|
||||
ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1);
|
||||
|
||||
/* PIO commands are handled by polling */
|
||||
ap->hsm_task_state = HSM_ST;
|
||||
|
@ -2146,7 +2146,7 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)
|
||||
ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer));
|
||||
qc->dma_dir = DMA_FROM_DEVICE;
|
||||
|
||||
memset(&qc->cdb, 0, ap->cdb_len);
|
||||
memset(&qc->cdb, 0, qc->dev->cdb_len);
|
||||
qc->cdb[0] = REQUEST_SENSE;
|
||||
qc->cdb[4] = SCSI_SENSE_BUFFERSIZE;
|
||||
|
||||
@ -2248,7 +2248,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
|
||||
if (ata_check_atapi_dma(qc))
|
||||
using_pio = 1;
|
||||
|
||||
memcpy(&qc->cdb, scsicmd, qc->ap->cdb_len);
|
||||
memcpy(&qc->cdb, scsicmd, dev->cdb_len);
|
||||
|
||||
qc->complete_fn = atapi_qc_complete;
|
||||
|
||||
|
@ -371,7 +371,7 @@ static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev)
|
||||
{
|
||||
void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
|
||||
|
||||
if (ap->cdb_len == 16)
|
||||
if (dev->cdb_len == 16)
|
||||
writel(PORT_CS_CDB16, port + PORT_CTRL_STAT);
|
||||
else
|
||||
writel(PORT_CS_CDB16, port + PORT_CTRL_CLR);
|
||||
@ -543,7 +543,7 @@ static void sil24_qc_prep(struct ata_queued_cmd *qc)
|
||||
prb = &cb->atapi.prb;
|
||||
sge = cb->atapi.sge;
|
||||
memset(cb->atapi.cdb, 0, 32);
|
||||
memcpy(cb->atapi.cdb, qc->cdb, ap->cdb_len);
|
||||
memcpy(cb->atapi.cdb, qc->cdb, qc->dev->cdb_len);
|
||||
|
||||
if (qc->tf.protocol != ATA_PROT_ATAPI_NODATA) {
|
||||
if (qc->tf.flags & ATA_TFLAG_WRITE)
|
||||
|
@ -348,6 +348,7 @@ struct ata_device {
|
||||
|
||||
unsigned int multi_count; /* sectors count for
|
||||
READ/WRITE MULTIPLE */
|
||||
unsigned int cdb_len;
|
||||
|
||||
/* for CHS addressing */
|
||||
u16 cylinders; /* Number of cylinders */
|
||||
@ -377,7 +378,6 @@ struct ata_port {
|
||||
unsigned int mwdma_mask;
|
||||
unsigned int udma_mask;
|
||||
unsigned int cbl; /* cable type; ATA_CBL_xxx */
|
||||
unsigned int cdb_len;
|
||||
|
||||
struct ata_device device[ATA_MAX_DEVICES];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user