aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-generic
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-07-30 13:11:31 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-30 13:11:31 -0400
commit6f51f51582e793ea13e7de7ed6b138f71c51784b (patch)
tree211ecbf88cdf2f183e23da3f8f23153ac6133410 /include/asm-generic
parent76159c20c0bcf5b38178fbfb61049eeb6380bb54 (diff)
parent97ef952a20853fad72087a53fa556fbec45edd8f (diff)
Merge branch 'for-linus-for-3.6-rc1' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping
Pull DMA-mapping updates from Marek Szyprowski: "Those patches are continuation of my earlier work. They contains extensions to DMA-mapping framework to remove limitation of the current ARM implementation (like limited total size of DMA coherent/write combine buffers), improve performance of buffer sharing between devices (attributes to skip cpu cache operations or creation of additional kernel mapping for some specific use cases) as well as some unification of the common code for dma_mmap_attrs() and dma_mmap_coherent() functions. All extensions have been implemented and tested for ARM architecture." * 'for-linus-for-3.6-rc1' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping: ARM: dma-mapping: add support for DMA_ATTR_SKIP_CPU_SYNC attribute common: DMA-mapping: add DMA_ATTR_SKIP_CPU_SYNC attribute ARM: dma-mapping: add support for dma_get_sgtable() common: dma-mapping: introduce dma_get_sgtable() function ARM: dma-mapping: add support for DMA_ATTR_NO_KERNEL_MAPPING attribute common: DMA-mapping: add DMA_ATTR_NO_KERNEL_MAPPING attribute common: dma-mapping: add support for generic dma_mmap_* calls ARM: dma-mapping: fix error path for memory allocation failure ARM: dma-mapping: add more sanity checks in arm_dma_mmap() ARM: dma-mapping: remove custom consistent dma region mm: vmalloc: use const void * for caller argument scatterlist: add sg_alloc_table_from_pages function
Diffstat (limited to 'include/asm-generic')
-rw-r--r--include/asm-generic/dma-coherent.h1
-rw-r--r--include/asm-generic/dma-mapping-common.h55
2 files changed, 56 insertions, 0 deletions
diff --git a/include/asm-generic/dma-coherent.h b/include/asm-generic/dma-coherent.h
index abfb2682de7f..2be8a2dbc868 100644
--- a/include/asm-generic/dma-coherent.h
+++ b/include/asm-generic/dma-coherent.h
@@ -29,6 +29,7 @@ dma_mark_declared_memory_occupied(struct device *dev,
29#else 29#else
30#define dma_alloc_from_coherent(dev, size, handle, ret) (0) 30#define dma_alloc_from_coherent(dev, size, handle, ret) (0)
31#define dma_release_from_coherent(dev, order, vaddr) (0) 31#define dma_release_from_coherent(dev, order, vaddr) (0)
32#define dma_mmap_from_coherent(dev, vma, vaddr, order, ret) (0)
32#endif 33#endif
33 34
34#endif 35#endif
diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h
index 2e248d8924dc..de8bf89940f8 100644
--- a/include/asm-generic/dma-mapping-common.h
+++ b/include/asm-generic/dma-mapping-common.h
@@ -176,4 +176,59 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
176#define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, NULL) 176#define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, NULL)
177#define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, NULL) 177#define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, NULL)
178 178
179extern int dma_common_mmap(struct device *dev, struct vm_area_struct *vma,
180 void *cpu_addr, dma_addr_t dma_addr, size_t size);
181
182/**
183 * dma_mmap_attrs - map a coherent DMA allocation into user space
184 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
185 * @vma: vm_area_struct describing requested user mapping
186 * @cpu_addr: kernel CPU-view address returned from dma_alloc_attrs
187 * @handle: device-view address returned from dma_alloc_attrs
188 * @size: size of memory originally requested in dma_alloc_attrs
189 * @attrs: attributes of mapping properties requested in dma_alloc_attrs
190 *
191 * Map a coherent DMA buffer previously allocated by dma_alloc_attrs
192 * into user space. The coherent DMA buffer must not be freed by the
193 * driver until the user space mapping has been released.
194 */
195static inline int
196dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void *cpu_addr,
197 dma_addr_t dma_addr, size_t size, struct dma_attrs *attrs)
198{
199 struct dma_map_ops *ops = get_dma_ops(dev);
200 BUG_ON(!ops);
201 if (ops->mmap)
202 return ops->mmap(dev, vma, cpu_addr, dma_addr, size, attrs);
203 return dma_common_mmap(dev, vma, cpu_addr, dma_addr, size);
204}
205
206#define dma_mmap_coherent(d, v, c, h, s) dma_mmap_attrs(d, v, c, h, s, NULL)
207
208static inline int dma_mmap_writecombine(struct device *dev, struct vm_area_struct *vma,
209 void *cpu_addr, dma_addr_t dma_addr, size_t size)
210{
211 DEFINE_DMA_ATTRS(attrs);
212 dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
213 return dma_mmap_attrs(dev, vma, cpu_addr, dma_addr, size, &attrs);
214}
215
216int
217dma_common_get_sgtable(struct device *dev, struct sg_table *sgt,
218 void *cpu_addr, dma_addr_t dma_addr, size_t size);
219
220static inline int
221dma_get_sgtable_attrs(struct device *dev, struct sg_table *sgt, void *cpu_addr,
222 dma_addr_t dma_addr, size_t size, struct dma_attrs *attrs)
223{
224 struct dma_map_ops *ops = get_dma_ops(dev);
225 BUG_ON(!ops);
226 if (ops->get_sgtable)
227 return ops->get_sgtable(dev, sgt, cpu_addr, dma_addr, size,
228 attrs);
229 return dma_common_get_sgtable(dev, sgt, cpu_addr, dma_addr, size);
230}
231
232#define dma_get_sgtable(d, t, v, h, s) dma_get_sgtable_attrs(d, t, v, h, s, NULL)
233
179#endif 234#endif