dma_declare_coherent_memory should not be in a DMA API guide aimed at driver writers (that is consumers of the API). Move it to a comment near the function instead.
Unified · Split
| @@ -586,30 +586,6 @@ the DMA_ATTR_NON_CONSISTENT flag starting at virtual address vaddr and · 585 unmodified lines | |||
| 586 | continuing on for size. Again, you *must* observe the cache line | 586 | continuing on for size. Again, you *must* observe the cache line |
| 587 | boundaries when doing this. | 587 | boundaries when doing this. |
| 588 | 588 | ||
| 589 | :: | ||
| 590 | |||
| 591 | int | ||
| 592 | dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, | ||
| 593 | dma_addr_t device_addr, size_t size); | ||
| 594 | |||
| 595 | Declare region of memory to be handed out by dma_alloc_coherent() when | ||
| 596 | it's asked for coherent memory for this device. | ||
| 597 | |||
| 598 | phys_addr is the CPU physical address to which the memory is currently | ||
| 599 | assigned (this will be ioremapped so the CPU can access the region). | ||
| 600 | |||
| 601 | device_addr is the DMA address the device needs to be programmed | ||
| 602 | with to actually address this memory (this will be handed out as the | ||
| 603 | dma_addr_t in dma_alloc_coherent()). | ||
| 604 | |||
| 605 | size is the size of the area (must be multiples of PAGE_SIZE). | ||
| 606 | |||
| 607 | As a simplification for the platforms, only *one* such region of | ||
| 608 | memory may be declared per device. | ||
| 609 | |||
| 610 | For reasons of efficiency, most platforms choose to track the declared | ||
| 611 | region only at the granularity of a page. For smaller allocations, | ||
| 612 | you should use the dma_pool() API. | ||
| 613 | 589 | ||
| 614 | Part III - Debug drivers use of the DMA-API | 590 | Part III - Debug drivers use of the DMA-API |
| 615 | ------------------------------------------- | 591 | ------------------------------------------- |
| @@ -107,6 +107,23 @@ static int dma_assign_coherent_memory(struct device *dev, · 106 unmodified lines | |||
| 107 | return 0; | 107 | return 0; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | /* | ||
| 111 | * Declare a region of memory to be handed out by dma_alloc_coherent() when it | ||
| 112 | * is asked for coherent memory for this device. This shall only be used | ||
| 113 | * from platform code, usually based on the device tree description. | ||
| 114 | * | ||
| 115 | * phys_addr is the CPU physical address to which the memory is currently | ||
| 116 | * assigned (this will be ioremapped so the CPU can access the region). | ||
| 117 | * | ||
| 118 | * device_addr is the DMA address the device needs to be programmed with to | ||
| 119 | * actually address this memory (this will be handed out as the dma_addr_t in | ||
| 120 | * dma_alloc_coherent()). | ||
| 121 | * | ||
| 122 | * size is the size of the area (must be a multiple of PAGE_SIZE). | ||
| 123 | * | ||
| 124 | * As a simplification for the platforms, only *one* such region of memory may | ||
| 125 | * be declared per device. | ||
| 126 | */ | ||
| 110 | int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, | 127 | int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, |
| 111 | dma_addr_t device_addr, size_t size) | 128 | dma_addr_t device_addr, size_t size) |
| 112 | { | 129 | { |