diff options
author | Magnus Damm <magnus.damm@gmail.com> | 2008-01-24 04:35:10 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-01-27 23:19:04 -0500 |
commit | f93e97eaead5c50af35d73cca7301ebbfdff116c (patch) | |
tree | 108a0b968123bb00a9453189fe93ad467d265cbf /include/asm-sh/dma-mapping.h | |
parent | 4862ec073975e28f432f164405e60fa6f5c9d071 (diff) |
sh: declared coherent memory support V2
This patch adds declared coherent memory support to the sh architecture. All
functions are based on the x86 implementation. Header files are adjusted to
use the new functions instead of the former consistent_alloc() code.
This version includes the few changes what were included in the fix patch
together with modifications based on feedback from Paul.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'include/asm-sh/dma-mapping.h')
-rw-r--r-- | include/asm-sh/dma-mapping.h | 56 |
1 files changed, 20 insertions, 36 deletions
diff --git a/include/asm-sh/dma-mapping.h b/include/asm-sh/dma-mapping.h index 20ae762e5258..22cc419389fe 100644 --- a/include/asm-sh/dma-mapping.h +++ b/include/asm-sh/dma-mapping.h | |||
@@ -8,11 +8,6 @@ | |||
8 | 8 | ||
9 | extern struct bus_type pci_bus_type; | 9 | extern struct bus_type pci_bus_type; |
10 | 10 | ||
11 | /* arch/sh/mm/consistent.c */ | ||
12 | extern void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *handle); | ||
13 | extern void consistent_free(void *vaddr, size_t size, dma_addr_t handle); | ||
14 | extern void consistent_sync(void *vaddr, size_t size, int direction); | ||
15 | |||
16 | #define dma_supported(dev, mask) (1) | 11 | #define dma_supported(dev, mask) (1) |
17 | 12 | ||
18 | static inline int dma_set_mask(struct device *dev, u64 mask) | 13 | static inline int dma_set_mask(struct device *dev, u64 mask) |
@@ -25,44 +20,19 @@ static inline int dma_set_mask(struct device *dev, u64 mask) | |||
25 | return 0; | 20 | return 0; |
26 | } | 21 | } |
27 | 22 | ||
28 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, | 23 | void *dma_alloc_coherent(struct device *dev, size_t size, |
29 | dma_addr_t *dma_handle, gfp_t flag) | 24 | dma_addr_t *dma_handle, gfp_t flag); |
30 | { | ||
31 | if (sh_mv.mv_consistent_alloc) { | ||
32 | void *ret; | ||
33 | 25 | ||
34 | ret = sh_mv.mv_consistent_alloc(dev, size, dma_handle, flag); | 26 | void dma_free_coherent(struct device *dev, size_t size, |
35 | if (ret != NULL) | 27 | void *vaddr, dma_addr_t dma_handle); |
36 | return ret; | ||
37 | } | ||
38 | |||
39 | return consistent_alloc(flag, size, dma_handle); | ||
40 | } | ||
41 | |||
42 | static inline void dma_free_coherent(struct device *dev, size_t size, | ||
43 | void *vaddr, dma_addr_t dma_handle) | ||
44 | { | ||
45 | if (sh_mv.mv_consistent_free) { | ||
46 | int ret; | ||
47 | |||
48 | ret = sh_mv.mv_consistent_free(dev, size, vaddr, dma_handle); | ||
49 | if (ret == 0) | ||
50 | return; | ||
51 | } | ||
52 | 28 | ||
53 | consistent_free(vaddr, size, dma_handle); | 29 | void dma_cache_sync(struct device *dev, void *vaddr, size_t size, |
54 | } | 30 | enum dma_data_direction dir); |
55 | 31 | ||
56 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) | 32 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) |
57 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) | 33 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) |
58 | #define dma_is_consistent(d, h) (1) | 34 | #define dma_is_consistent(d, h) (1) |
59 | 35 | ||
60 | static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size, | ||
61 | enum dma_data_direction dir) | ||
62 | { | ||
63 | consistent_sync(vaddr, size, (int)dir); | ||
64 | } | ||
65 | |||
66 | static inline dma_addr_t dma_map_single(struct device *dev, | 36 | static inline dma_addr_t dma_map_single(struct device *dev, |
67 | void *ptr, size_t size, | 37 | void *ptr, size_t size, |
68 | enum dma_data_direction dir) | 38 | enum dma_data_direction dir) |
@@ -205,4 +175,18 @@ static inline int dma_mapping_error(dma_addr_t dma_addr) | |||
205 | { | 175 | { |
206 | return dma_addr == 0; | 176 | return dma_addr == 0; |
207 | } | 177 | } |
178 | |||
179 | #define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY | ||
180 | |||
181 | extern int | ||
182 | dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr, | ||
183 | dma_addr_t device_addr, size_t size, int flags); | ||
184 | |||
185 | extern void | ||
186 | dma_release_declared_memory(struct device *dev); | ||
187 | |||
188 | extern void * | ||
189 | dma_mark_declared_memory_occupied(struct device *dev, | ||
190 | dma_addr_t device_addr, size_t size); | ||
191 | |||
208 | #endif /* __ASM_SH_DMA_MAPPING_H */ | 192 | #endif /* __ASM_SH_DMA_MAPPING_H */ |