aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-generic
diff options
context:
space:
mode:
authorMarek Szyprowski <m.szyprowski@samsung.com>2012-06-13 04:05:52 -0400
committerMarek Szyprowski <m.szyprowski@samsung.com>2012-07-30 06:25:46 -0400
commitd2b7428eb0caa7c66e34b6ac869a43915b294123 (patch)
treead30d28a2078d1d9429c8f19815378c5da2c54f5 /include/asm-generic
parent955c757e090f41188764a0e488ba7036f7dbb215 (diff)
common: dma-mapping: introduce dma_get_sgtable() function
This patch adds dma_get_sgtable() function which is required to let drivers to share the buffers allocated by DMA-mapping subsystem. Right now the driver gets a dma address of the allocated buffer and the kernel virtual mapping for it. If it wants to share it with other device (= map into its dma address space) it usually hacks around kernel virtual addresses to get pointers to pages or assumes that both devices share the DMA address space. Both solutions are just hacks for the special cases, which should be avoided in the final version of buffer sharing. To solve this issue in a generic way, a new call to DMA mapping has been introduced - dma_get_sgtable(). It allocates a scatter-list which describes the allocated buffer and lets the driver(s) to use it with other device(s) by calling dma_map_sg() on it. This patch provides a generic implementation based on virt_to_page() call. Architectures which require more sophisticated translation might provide their own get_sgtable() methods. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Kyungmin Park <kyungmin.park@samsung.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'include/asm-generic')
-rw-r--r--include/asm-generic/dma-mapping-common.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h
index 9073aeb3bb1a..de8bf89940f8 100644
--- a/include/asm-generic/dma-mapping-common.h
+++ b/include/asm-generic/dma-mapping-common.h
@@ -213,4 +213,22 @@ static inline int dma_mmap_writecombine(struct device *dev, struct vm_area_struc
213 return dma_mmap_attrs(dev, vma, cpu_addr, dma_addr, size, &attrs); 213 return dma_mmap_attrs(dev, vma, cpu_addr, dma_addr, size, &attrs);
214} 214}
215 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
216#endif 234#endif