diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-04-04 20:13:43 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-04-04 20:13:43 -0400 |
commit | 58bca4a8fa90fcf9069379653b396b2cec642f7f (patch) | |
tree | 483c535136b5b168f36326956453e80ce5aa6543 /arch/hexagon | |
parent | 64ebe987311853ea857a244439de5b947a4b1b07 (diff) | |
parent | 64d70fe5d3640e1a89790ed21120921278f8cb86 (diff) |
Merge branch 'for-linus' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping
Pull DMA mapping branch from Marek Szyprowski:
"Short summary for the whole series:
A few limitations have been identified in the current dma-mapping
design and its implementations for various architectures. There exist
more than one function for allocating and freeing the buffers:
currently these 3 are used dma_{alloc, free}_coherent,
dma_{alloc,free}_writecombine, dma_{alloc,free}_noncoherent.
For most of the systems these calls are almost equivalent and can be
interchanged. For others, especially the truly non-coherent ones
(like ARM), the difference can be easily noticed in overall driver
performance. Sadly not all architectures provide implementations for
all of them, so the drivers might need to be adapted and cannot be
easily shared between different architectures. The provided patches
unify all these functions and hide the differences under the already
existing dma attributes concept. The thread with more references is
available here:
http://www.spinics.net/lists/linux-sh/msg09777.html
These patches are also a prerequisite for unifying DMA-mapping
implementation on ARM architecture with the common one provided by
dma_map_ops structure and extending it with IOMMU support. More
information is available in the following thread:
http://thread.gmane.org/gmane.linux.kernel.cross-arch/12819
More works on dma-mapping framework are planned, especially in the
area of buffer sharing and managing the shared mappings (together with
the recently introduced dma_buf interface: commit d15bd7ee445d
"dma-buf: Introduce dma buffer sharing mechanism").
The patches in the current set introduce a new alloc/free methods
(with support for memory attributes) in dma_map_ops structure, which
will later replace dma_alloc_coherent and dma_alloc_writecombine
functions."
People finally started piping up with support for merging this, so I'm
merging it as the last of the pending stuff from the merge window.
Looks like pohmelfs is going to wait for 3.5 and more external support
for merging.
* 'for-linus' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping:
common: DMA-mapping: add NON-CONSISTENT attribute
common: DMA-mapping: add WRITE_COMBINE attribute
common: dma-mapping: introduce mmap method
common: dma-mapping: remove old alloc_coherent and free_coherent methods
Hexagon: adapt for dma_map_ops changes
Unicore32: adapt for dma_map_ops changes
Microblaze: adapt for dma_map_ops changes
SH: adapt for dma_map_ops changes
Alpha: adapt for dma_map_ops changes
SPARC: adapt for dma_map_ops changes
PowerPC: adapt for dma_map_ops changes
MIPS: adapt for dma_map_ops changes
X86 & IA64: adapt for dma_map_ops changes
common: dma-mapping: introduce generic alloc() and free() methods
Diffstat (limited to 'arch/hexagon')
-rw-r--r-- | arch/hexagon/include/asm/dma-mapping.h | 18 | ||||
-rw-r--r-- | arch/hexagon/kernel/dma.c | 9 |
2 files changed, 17 insertions, 10 deletions
diff --git a/arch/hexagon/include/asm/dma-mapping.h b/arch/hexagon/include/asm/dma-mapping.h index 448b224ba4ef..233ed3d2d25e 100644 --- a/arch/hexagon/include/asm/dma-mapping.h +++ b/arch/hexagon/include/asm/dma-mapping.h | |||
@@ -71,29 +71,35 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) | |||
71 | return (dma_addr == bad_dma_address); | 71 | return (dma_addr == bad_dma_address); |
72 | } | 72 | } |
73 | 73 | ||
74 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, | 74 | #define dma_alloc_coherent(d,s,h,f) dma_alloc_attrs(d,s,h,f,NULL) |
75 | dma_addr_t *dma_handle, gfp_t flag) | 75 | |
76 | static inline void *dma_alloc_attrs(struct device *dev, size_t size, | ||
77 | dma_addr_t *dma_handle, gfp_t flag, | ||
78 | struct dma_attrs *attrs) | ||
76 | { | 79 | { |
77 | void *ret; | 80 | void *ret; |
78 | struct dma_map_ops *ops = get_dma_ops(dev); | 81 | struct dma_map_ops *ops = get_dma_ops(dev); |
79 | 82 | ||
80 | BUG_ON(!dma_ops); | 83 | BUG_ON(!dma_ops); |
81 | 84 | ||
82 | ret = ops->alloc_coherent(dev, size, dma_handle, flag); | 85 | ret = ops->alloc(dev, size, dma_handle, flag, attrs); |
83 | 86 | ||
84 | debug_dma_alloc_coherent(dev, size, *dma_handle, ret); | 87 | debug_dma_alloc_coherent(dev, size, *dma_handle, ret); |
85 | 88 | ||
86 | return ret; | 89 | return ret; |
87 | } | 90 | } |
88 | 91 | ||
89 | static inline void dma_free_coherent(struct device *dev, size_t size, | 92 | #define dma_free_coherent(d,s,c,h) dma_free_attrs(d,s,c,h,NULL) |
90 | void *cpu_addr, dma_addr_t dma_handle) | 93 | |
94 | static inline void dma_free_attrs(struct device *dev, size_t size, | ||
95 | void *cpu_addr, dma_addr_t dma_handle, | ||
96 | struct dma_attrs *attrs) | ||
91 | { | 97 | { |
92 | struct dma_map_ops *dma_ops = get_dma_ops(dev); | 98 | struct dma_map_ops *dma_ops = get_dma_ops(dev); |
93 | 99 | ||
94 | BUG_ON(!dma_ops); | 100 | BUG_ON(!dma_ops); |
95 | 101 | ||
96 | dma_ops->free_coherent(dev, size, cpu_addr, dma_handle); | 102 | dma_ops->free(dev, size, cpu_addr, dma_handle, attrs); |
97 | 103 | ||
98 | debug_dma_free_coherent(dev, size, cpu_addr, dma_handle); | 104 | debug_dma_free_coherent(dev, size, cpu_addr, dma_handle); |
99 | } | 105 | } |
diff --git a/arch/hexagon/kernel/dma.c b/arch/hexagon/kernel/dma.c index e711ace62fdf..37302218ca4a 100644 --- a/arch/hexagon/kernel/dma.c +++ b/arch/hexagon/kernel/dma.c | |||
@@ -54,7 +54,8 @@ static struct gen_pool *coherent_pool; | |||
54 | /* Allocates from a pool of uncached memory that was reserved at boot time */ | 54 | /* Allocates from a pool of uncached memory that was reserved at boot time */ |
55 | 55 | ||
56 | void *hexagon_dma_alloc_coherent(struct device *dev, size_t size, | 56 | void *hexagon_dma_alloc_coherent(struct device *dev, size_t size, |
57 | dma_addr_t *dma_addr, gfp_t flag) | 57 | dma_addr_t *dma_addr, gfp_t flag, |
58 | struct dma_attrs *attrs) | ||
58 | { | 59 | { |
59 | void *ret; | 60 | void *ret; |
60 | 61 | ||
@@ -81,7 +82,7 @@ void *hexagon_dma_alloc_coherent(struct device *dev, size_t size, | |||
81 | } | 82 | } |
82 | 83 | ||
83 | static void hexagon_free_coherent(struct device *dev, size_t size, void *vaddr, | 84 | static void hexagon_free_coherent(struct device *dev, size_t size, void *vaddr, |
84 | dma_addr_t dma_addr) | 85 | dma_addr_t dma_addr, struct dma_attrs *attrs) |
85 | { | 86 | { |
86 | gen_pool_free(coherent_pool, (unsigned long) vaddr, size); | 87 | gen_pool_free(coherent_pool, (unsigned long) vaddr, size); |
87 | } | 88 | } |
@@ -202,8 +203,8 @@ static void hexagon_sync_single_for_device(struct device *dev, | |||
202 | } | 203 | } |
203 | 204 | ||
204 | struct dma_map_ops hexagon_dma_ops = { | 205 | struct dma_map_ops hexagon_dma_ops = { |
205 | .alloc_coherent = hexagon_dma_alloc_coherent, | 206 | .alloc = hexagon_dma_alloc_coherent, |
206 | .free_coherent = hexagon_free_coherent, | 207 | .free = hexagon_free_coherent, |
207 | .map_sg = hexagon_map_sg, | 208 | .map_sg = hexagon_map_sg, |
208 | .map_page = hexagon_map_page, | 209 | .map_page = hexagon_map_page, |
209 | .sync_single_for_cpu = hexagon_sync_single_for_cpu, | 210 | .sync_single_for_cpu = hexagon_sync_single_for_cpu, |