aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/libata.h
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@HansenPartnership.com>2008-02-19 05:36:56 -0500
committerJens Axboe <jens.axboe@oracle.com>2008-02-19 05:36:56 -0500
commitdde2020754aeb14e17052d61784dcb37f252aac2 (patch)
tree1b6d57c6eff2024fd13e4b3b115d0a6770d8cb80 /include/linux/libata.h
parentdb0a2e0099be3a1cff55879225881465f16c67d3 (diff)
libata: eliminate the home grown dma padding in favour of
that provided by the block layer ATA requires that all DMA transfers begin and end on word boundaries. Because of this, a large amount of machinery grew up in ide to adjust scatterlists on this basis. However, as of 2.5, the block layer has a dma_alignment variable which ensures both the beginning and length of a DMA transfer are aligned on the dma_alignment boundary. Although the block layer does adjust the beginning of the transfer to ensure this happens, it doesn't actually adjust the length, it merely makes sure that space is allocated for transfers beyond the declared length. The upshot of this is that scatterlists may be padded to any size between the actual length and the length adjusted to the dma_alignment safely knowing that memory is allocated in this region. Right at the moment, SCSI takes the default dma_aligment which is on a 512 byte boundary. Note that this aligment only applies to transfers coming in from user space. However, since all kernel allocations are automatically aligned on a minimum of 32 byte boundaries, it is safe to adjust them in this manner as well. tj: * Adjusting sg after padding is done in block layer. Make libata set queue alignment correctly for ATAPI devices and drop broken sg mangling from ata_sg_setup(). * Use request->raw_data_len for ATAPI transfer chunk size. * Killed qc->raw_nbytes. * Separated out killing qc->n_iter. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'include/linux/libata.h')
-rw-r--r--include/linux/libata.h28
1 files changed, 1 insertions, 27 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h
index bc5a8d0c7090..2e098f940cec 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -278,7 +278,6 @@ enum {
278 278
279 /* size of buffer to pad xfers ending on unaligned boundaries */ 279 /* size of buffer to pad xfers ending on unaligned boundaries */
280 ATA_DMA_PAD_SZ = 4, 280 ATA_DMA_PAD_SZ = 4,
281 ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE,
282 281
283 /* ering size */ 282 /* ering size */
284 ATA_ERING_SIZE = 32, 283 ATA_ERING_SIZE = 32,
@@ -457,24 +456,18 @@ struct ata_queued_cmd {
457 unsigned long flags; /* ATA_QCFLAG_xxx */ 456 unsigned long flags; /* ATA_QCFLAG_xxx */
458 unsigned int tag; 457 unsigned int tag;
459 unsigned int n_elem; 458 unsigned int n_elem;
460 unsigned int mapped_n_elem;
461 459
462 int dma_dir; 460 int dma_dir;
463 461
464 unsigned int pad_len;
465 unsigned int sect_size; 462 unsigned int sect_size;
466 463
467 unsigned int nbytes; 464 unsigned int nbytes;
468 unsigned int raw_nbytes;
469 unsigned int curbytes; 465 unsigned int curbytes;
470 466
471 struct scatterlist *cursg; 467 struct scatterlist *cursg;
472 unsigned int cursg_ofs; 468 unsigned int cursg_ofs;
473 469
474 struct scatterlist *last_sg;
475 struct scatterlist saved_last_sg;
476 struct scatterlist sgent; 470 struct scatterlist sgent;
477 struct scatterlist extra_sg[2];
478 471
479 struct scatterlist *sg; 472 struct scatterlist *sg;
480 473
@@ -619,9 +612,6 @@ struct ata_port {
619 struct ata_prd *prd; /* our SG list */ 612 struct ata_prd *prd; /* our SG list */
620 dma_addr_t prd_dma; /* and its DMA mapping */ 613 dma_addr_t prd_dma; /* and its DMA mapping */
621 614
622 void *pad; /* array of DMA pad buffers */
623 dma_addr_t pad_dma;
624
625 struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */ 615 struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */
626 616
627 u8 ctl; /* cache of ATA control register */ 617 u8 ctl; /* cache of ATA control register */
@@ -1363,12 +1353,9 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc)
1363 qc->flags = 0; 1353 qc->flags = 0;
1364 qc->cursg = NULL; 1354 qc->cursg = NULL;
1365 qc->cursg_ofs = 0; 1355 qc->cursg_ofs = 0;
1366 qc->nbytes = qc->raw_nbytes = qc->curbytes = 0; 1356 qc->nbytes = qc->curbytes = 0;
1367 qc->n_elem = 0; 1357 qc->n_elem = 0;
1368 qc->mapped_n_elem = 0;
1369 qc->err_mask = 0; 1358 qc->err_mask = 0;
1370 qc->pad_len = 0;
1371 qc->last_sg = NULL;
1372 qc->sect_size = ATA_SECT_SIZE; 1359 qc->sect_size = ATA_SECT_SIZE;
1373 1360
1374 ata_tf_init(qc->dev, &qc->tf); 1361 ata_tf_init(qc->dev, &qc->tf);
@@ -1423,19 +1410,6 @@ static inline unsigned int __ac_err_mask(u8 status)
1423 return mask; 1410 return mask;
1424} 1411}
1425 1412
1426static inline int ata_pad_alloc(struct ata_port *ap, struct device *dev)
1427{
1428 ap->pad_dma = 0;
1429 ap->pad = dmam_alloc_coherent(dev, ATA_DMA_PAD_BUF_SZ,
1430 &ap->pad_dma, GFP_KERNEL);
1431 return (ap->pad == NULL) ? -ENOMEM : 0;
1432}
1433
1434static inline void ata_pad_free(struct ata_port *ap, struct device *dev)
1435{
1436 dmam_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma);
1437}
1438
1439static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host) 1413static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)
1440{ 1414{
1441 return *(struct ata_port **)&host->hostdata[0]; 1415 return *(struct ata_port **)&host->hostdata[0];