diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-11-05 15:44:02 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-11-05 15:44:02 -0500 |
commit | 8cedcfd43a0b00741fff43d6a4c1a8b7748db3b0 (patch) | |
tree | 41758e4da78f94a20813554ef9f5ed9b323a4f8c /include/linux/libata.h | |
parent | cd8200e6d4f9f05e6ea48f7c000be890337396ac (diff) | |
parent | 70d9d825e0a5a78ec1dacaaaf5c72ff5b0206fab (diff) |
Merge branch 'master'
Diffstat (limited to 'include/linux/libata.h')
-rw-r--r-- | include/linux/libata.h | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h index 457bdc44e4b1..4b4cf6cf4acc 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -156,6 +156,10 @@ enum { | |||
156 | ATA_SHIFT_UDMA = 0, | 156 | ATA_SHIFT_UDMA = 0, |
157 | ATA_SHIFT_MWDMA = 8, | 157 | ATA_SHIFT_MWDMA = 8, |
158 | ATA_SHIFT_PIO = 11, | 158 | ATA_SHIFT_PIO = 11, |
159 | |||
160 | /* size of buffer to pad xfers ending on unaligned boundaries */ | ||
161 | ATA_DMA_PAD_SZ = 4, | ||
162 | ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE, | ||
159 | 163 | ||
160 | /* Masks for port functions */ | 164 | /* Masks for port functions */ |
161 | ATA_PORT_PRIMARY = (1 << 0), | 165 | ATA_PORT_PRIMARY = (1 << 0), |
@@ -252,9 +256,12 @@ struct ata_queued_cmd { | |||
252 | unsigned long flags; /* ATA_QCFLAG_xxx */ | 256 | unsigned long flags; /* ATA_QCFLAG_xxx */ |
253 | unsigned int tag; | 257 | unsigned int tag; |
254 | unsigned int n_elem; | 258 | unsigned int n_elem; |
259 | unsigned int orig_n_elem; | ||
255 | 260 | ||
256 | int dma_dir; | 261 | int dma_dir; |
257 | 262 | ||
263 | unsigned int pad_len; | ||
264 | |||
258 | unsigned int nsect; | 265 | unsigned int nsect; |
259 | unsigned int cursect; | 266 | unsigned int cursect; |
260 | 267 | ||
@@ -265,9 +272,11 @@ struct ata_queued_cmd { | |||
265 | unsigned int cursg_ofs; | 272 | unsigned int cursg_ofs; |
266 | 273 | ||
267 | struct scatterlist sgent; | 274 | struct scatterlist sgent; |
275 | struct scatterlist pad_sgent; | ||
268 | void *buf_virt; | 276 | void *buf_virt; |
269 | 277 | ||
270 | struct scatterlist *sg; | 278 | /* DO NOT iterate over __sg manually, use ata_for_each_sg() */ |
279 | struct scatterlist *__sg; | ||
271 | 280 | ||
272 | ata_qc_cb_t complete_fn; | 281 | ata_qc_cb_t complete_fn; |
273 | 282 | ||
@@ -313,6 +322,9 @@ struct ata_port { | |||
313 | struct ata_prd *prd; /* our SG list */ | 322 | struct ata_prd *prd; /* our SG list */ |
314 | dma_addr_t prd_dma; /* and its DMA mapping */ | 323 | dma_addr_t prd_dma; /* and its DMA mapping */ |
315 | 324 | ||
325 | void *pad; /* array of DMA pad buffers */ | ||
326 | dma_addr_t pad_dma; | ||
327 | |||
316 | struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */ | 328 | struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */ |
317 | 329 | ||
318 | u8 ctl; /* cache of ATA control register */ | 330 | u8 ctl; /* cache of ATA control register */ |
@@ -515,6 +527,31 @@ extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bit | |||
515 | #endif /* CONFIG_PCI */ | 527 | #endif /* CONFIG_PCI */ |
516 | 528 | ||
517 | 529 | ||
530 | static inline int | ||
531 | ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) | ||
532 | { | ||
533 | if (sg == &qc->pad_sgent) | ||
534 | return 1; | ||
535 | if (qc->pad_len) | ||
536 | return 0; | ||
537 | if (((sg - qc->__sg) + 1) == qc->n_elem) | ||
538 | return 1; | ||
539 | return 0; | ||
540 | } | ||
541 | |||
542 | static inline struct scatterlist * | ||
543 | ata_qc_next_sg(struct scatterlist *sg, struct ata_queued_cmd *qc) | ||
544 | { | ||
545 | if (sg == &qc->pad_sgent) | ||
546 | return NULL; | ||
547 | if (++sg - qc->__sg < qc->n_elem) | ||
548 | return sg; | ||
549 | return qc->pad_len ? &qc->pad_sgent : NULL; | ||
550 | } | ||
551 | |||
552 | #define ata_for_each_sg(sg, qc) \ | ||
553 | for (sg = qc->__sg; sg; sg = ata_qc_next_sg(sg, qc)) | ||
554 | |||
518 | static inline unsigned int ata_tag_valid(unsigned int tag) | 555 | static inline unsigned int ata_tag_valid(unsigned int tag) |
519 | { | 556 | { |
520 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; | 557 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; |
@@ -743,4 +780,17 @@ static inline unsigned int __ac_err_mask(u8 status) | |||
743 | return mask; | 780 | return mask; |
744 | } | 781 | } |
745 | 782 | ||
783 | static inline int ata_pad_alloc(struct ata_port *ap, struct device *dev) | ||
784 | { | ||
785 | ap->pad_dma = 0; | ||
786 | ap->pad = dma_alloc_coherent(dev, ATA_DMA_PAD_BUF_SZ, | ||
787 | &ap->pad_dma, GFP_KERNEL); | ||
788 | return (ap->pad == NULL) ? -ENOMEM : 0; | ||
789 | } | ||
790 | |||
791 | static inline void ata_pad_free(struct ata_port *ap, struct device *dev) | ||
792 | { | ||
793 | dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); | ||
794 | } | ||
795 | |||
746 | #endif /* __LINUX_LIBATA_H__ */ | 796 | #endif /* __LINUX_LIBATA_H__ */ |