diff options
Diffstat (limited to 'Documentation/DMA-API.txt')
-rw-r--r-- | Documentation/DMA-API.txt | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt index 364a6cb444a5..29a48fbae779 100644 --- a/Documentation/DMA-API.txt +++ b/Documentation/DMA-API.txt | |||
@@ -472,6 +472,64 @@ void whizco_dma_map_sg_attrs(struct device *dev, dma_addr_t dma_addr, | |||
472 | .... | 472 | .... |
473 | 473 | ||
474 | 474 | ||
475 | Part Ie - Optimizing Unmap State Space Consumption | ||
476 | -------------------------------- | ||
477 | |||
478 | On some platforms, dma_unmap_{single,page}() is simply a nop. | ||
479 | Therefore, keeping track of the mapping address and length is a waste | ||
480 | of space. Instead of filling your drivers up with ifdefs and the like | ||
481 | to "work around" this (which would defeat the whole purpose of a | ||
482 | portable API) the following facilities are provided. | ||
483 | |||
484 | Actually, instead of describing the macros one by one, we'll | ||
485 | transform some example code. | ||
486 | |||
487 | 1) Use DEFINE_DMA_UNMAP_{ADDR,LEN} in state saving structures. | ||
488 | Example, before: | ||
489 | |||
490 | struct ring_state { | ||
491 | struct sk_buff *skb; | ||
492 | dma_addr_t mapping; | ||
493 | __u32 len; | ||
494 | }; | ||
495 | |||
496 | after: | ||
497 | |||
498 | struct ring_state { | ||
499 | struct sk_buff *skb; | ||
500 | DEFINE_DMA_UNMAP_ADDR(mapping); | ||
501 | DEFINE_DMA_UNMAP_LEN(len); | ||
502 | }; | ||
503 | |||
504 | 2) Use dma_unmap_{addr,len}_set to set these values. | ||
505 | Example, before: | ||
506 | |||
507 | ringp->mapping = FOO; | ||
508 | ringp->len = BAR; | ||
509 | |||
510 | after: | ||
511 | |||
512 | dma_unmap_addr_set(ringp, mapping, FOO); | ||
513 | dma_unmap_len_set(ringp, len, BAR); | ||
514 | |||
515 | 3) Use dma_unmap_{addr,len} to access these values. | ||
516 | Example, before: | ||
517 | |||
518 | dma_unmap_single(dev, ringp->mapping, ringp->len, | ||
519 | DMA_FROM_DEVICE); | ||
520 | |||
521 | after: | ||
522 | |||
523 | dma_unmap_single(dev, | ||
524 | dma_unmap_addr(ringp, mapping), | ||
525 | dma_unmap_len(ringp, len), | ||
526 | DMA_FROM_DEVICE); | ||
527 | |||
528 | It really should be self-explanatory. We treat the ADDR and LEN | ||
529 | separately, because it is possible for an implementation to only | ||
530 | need the address in order to perform the unmap operation. | ||
531 | |||
532 | |||
475 | Part II - Advanced dma_ usage | 533 | Part II - Advanced dma_ usage |
476 | ----------------------------- | 534 | ----------------------------- |
477 | 535 | ||