Thread (66 messages) 66 messages, 12 authors, 2011-07-26

[Linaro-mm-sig] [PATCH 8/8] ARM: dma-mapping: use alloc, mmap, free from dma_ops

From: KyongHo Cho <hidden>
Date: 2011-06-22 06:54:02
Also in: linux-arch, linux-mm

Hi.

On Mon, Jun 20, 2011 at 4:50 PM, Marek Szyprowski
[off-list ref] wrote:
-extern void *dma_alloc_coherent(struct device *, size_t, dma_addr_t *, gfp_t);
+extern void *arm_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
+ ? ? ? ? ? ? ? ? ? ? ? ? ?gfp_t gfp, struct dma_attrs *attrs);
+
+#define dma_alloc_coherent(d,s,h,f) dma_alloc_attrs(d,s,h,f,NULL)
+
+static inline void *dma_alloc_attrs(struct device *dev, size_t size,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?dma_addr_t *dma_handle, gfp_t flag,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?struct dma_attrs *attrs)
+{
+ ? ? ? struct dma_map_ops *ops = get_dma_ops(dev);
+ ? ? ? void *cpu_addr;
+ ? ? ? BUG_ON(!ops);
+
+ ? ? ? cpu_addr = ops->alloc(dev, size, dma_handle, flag, attrs);
+ ? ? ? debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr);
+ ? ? ? return cpu_addr;
+}
Apart from the necessity of alloc_attr,
I hope the callback implementations to check if a function pointer is NULL.
Suppose that a system want to use default ARM implementation of dma_alloc_*()
while it uses its own implementations of dma_map_*().


With your suggestion,
we have only one option:

void *my_alloc(...) {
return dma_alloc_coherent(NULL, ...);
}

struct dma_map_ops ops = {
.alloc_coherent = &my_alloc,
...
};



I think the following method is simpler:

struct dma_map_ops ops = {
.alloc_coherent = NULL,
...
};
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help