aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/dma-coherent.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/dma-coherent.c')
-rw-r--r--kernel/dma-coherent.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/kernel/dma-coherent.c b/kernel/dma-coherent.c
index 56dff5cb0f29..7517115a8cce 100644
--- a/kernel/dma-coherent.c
+++ b/kernel/dma-coherent.c
@@ -92,6 +92,21 @@ void *dma_mark_declared_memory_occupied(struct device *dev,
92} 92}
93EXPORT_SYMBOL(dma_mark_declared_memory_occupied); 93EXPORT_SYMBOL(dma_mark_declared_memory_occupied);
94 94
95/**
96 * Try to allocate memory from the per-device coherent area.
97 *
98 * @dev: device from which we allocate memory
99 * @size: size of requested memory area
100 * @dma_handle: This will be filled with the correct dma handle
101 * @ret: This pointer will be filled with the virtual address
102 * to allocated area.
103 *
104 * This function should be only called from per-arch %dma_alloc_coherent()
105 * to support allocation from per-device coherent memory pools.
106 *
107 * Returns 0 if dma_alloc_coherent should continue with allocating from
108 * generic memory areas, or !0 if dma_alloc_coherent should return %ret.
109 */
95int dma_alloc_from_coherent(struct device *dev, ssize_t size, 110int dma_alloc_from_coherent(struct device *dev, ssize_t size,
96 dma_addr_t *dma_handle, void **ret) 111 dma_addr_t *dma_handle, void **ret)
97{ 112{
@@ -111,6 +126,19 @@ int dma_alloc_from_coherent(struct device *dev, ssize_t size,
111 return (mem != NULL); 126 return (mem != NULL);
112} 127}
113 128
129/**
130 * Try to free the memory allocated from per-device coherent memory pool.
131 * @dev: device from which the memory was allocated
132 * @order: the order of pages allocated
133 * @vaddr: virtual address of allocated pages
134 *
135 * This checks whether the memory was allocated from the per-device
136 * coherent memory pool and if so, releases that memory.
137 *
138 * Returns 1 if we correctly released the memory, or 0 if
139 * %dma_release_coherent() should proceed with releasing memory from
140 * generic pools.
141 */
114int dma_release_from_coherent(struct device *dev, int order, void *vaddr) 142int dma_release_from_coherent(struct device *dev, int order, void *vaddr)
115{ 143{
116 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL; 144 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;