aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/DMA-API.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/DMA-API.txt')
-rw-r--r--Documentation/DMA-API.txt69
1 files changed, 67 insertions, 2 deletions
diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index b939ebb62871..80d150458c80 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -145,7 +145,7 @@ Part Ic - DMA addressing limitations
145int 145int
146dma_supported(struct device *dev, u64 mask) 146dma_supported(struct device *dev, u64 mask)
147int 147int
148pci_dma_supported(struct device *dev, u64 mask) 148pci_dma_supported(struct pci_dev *hwdev, u64 mask)
149 149
150Checks to see if the device can support DMA to the memory described by 150Checks to see if the device can support DMA to the memory described by
151mask. 151mask.
@@ -189,7 +189,7 @@ dma_addr_t
189dma_map_single(struct device *dev, void *cpu_addr, size_t size, 189dma_map_single(struct device *dev, void *cpu_addr, size_t size,
190 enum dma_data_direction direction) 190 enum dma_data_direction direction)
191dma_addr_t 191dma_addr_t
192pci_map_single(struct device *dev, void *cpu_addr, size_t size, 192pci_map_single(struct pci_dev *hwdev, void *cpu_addr, size_t size,
193 int direction) 193 int direction)
194 194
195Maps a piece of processor virtual memory so it can be accessed by the 195Maps a piece of processor virtual memory so it can be accessed by the
@@ -395,6 +395,71 @@ Notes: You must do this:
395 395
396See also dma_map_single(). 396See also dma_map_single().
397 397
398dma_addr_t
399dma_map_single_attrs(struct device *dev, void *cpu_addr, size_t size,
400 enum dma_data_direction dir,
401 struct dma_attrs *attrs)
402
403void
404dma_unmap_single_attrs(struct device *dev, dma_addr_t dma_addr,
405 size_t size, enum dma_data_direction dir,
406 struct dma_attrs *attrs)
407
408int
409dma_map_sg_attrs(struct device *dev, struct scatterlist *sgl,
410 int nents, enum dma_data_direction dir,
411 struct dma_attrs *attrs)
412
413void
414dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sgl,
415 int nents, enum dma_data_direction dir,
416 struct dma_attrs *attrs)
417
418The four functions above are just like the counterpart functions
419without the _attrs suffixes, except that they pass an optional
420struct dma_attrs*.
421
422struct dma_attrs encapsulates a set of "dma attributes". For the
423definition of struct dma_attrs see linux/dma-attrs.h.
424
425The interpretation of dma attributes is architecture-specific, and
426each attribute should be documented in Documentation/DMA-attributes.txt.
427
428If struct dma_attrs* is NULL, the semantics of each of these
429functions is identical to those of the corresponding function
430without the _attrs suffix. As a result dma_map_single_attrs()
431can generally replace dma_map_single(), etc.
432
433As an example of the use of the *_attrs functions, here's how
434you could pass an attribute DMA_ATTR_FOO when mapping memory
435for DMA:
436
437#include <linux/dma-attrs.h>
438/* DMA_ATTR_FOO should be defined in linux/dma-attrs.h and
439 * documented in Documentation/DMA-attributes.txt */
440...
441
442 DEFINE_DMA_ATTRS(attrs);
443 dma_set_attr(DMA_ATTR_FOO, &attrs);
444 ....
445 n = dma_map_sg_attrs(dev, sg, nents, DMA_TO_DEVICE, &attr);
446 ....
447
448Architectures that care about DMA_ATTR_FOO would check for its
449presence in their implementations of the mapping and unmapping
450routines, e.g.:
451
452void whizco_dma_map_sg_attrs(struct device *dev, dma_addr_t dma_addr,
453 size_t size, enum dma_data_direction dir,
454 struct dma_attrs *attrs)
455{
456 ....
457 int foo = dma_get_attr(DMA_ATTR_FOO, attrs);
458 ....
459 if (foo)
460 /* twizzle the frobnozzle */
461 ....
462
398 463
399Part II - Advanced dma_ usage 464Part II - Advanced dma_ usage
400----------------------------- 465-----------------------------