diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2008-08-19 10:32:45 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-08-22 02:34:51 -0400 |
commit | 6c505ce3930c6a6b455cda53fab3e88ae44f8221 (patch) | |
tree | 5b6254c6589f458ad0af21d7f6fbc998ebfd3714 /include/asm-x86/dma-mapping.h | |
parent | c647c3bb2d16246a87f49035985ddb7c1eb030df (diff) |
x86: move dma_*_coherent functions to include file
All the x86 DMA-API functions are defined in asm/dma-mapping.h. This patch
moves the dma_*_coherent functions also to this header file because they are
now small enough to do so.
This is done as a separate patch because it also includes some renaming and
restructuring of the dma-mapping.h file.
Signed-off-by: Joerg Roedel <joerg.roede@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/asm-x86/dma-mapping.h')
-rw-r--r-- | include/asm-x86/dma-mapping.h | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h index ad9cd6d49bfc..8e16095d1fa9 100644 --- a/include/asm-x86/dma-mapping.h +++ b/include/asm-x86/dma-mapping.h | |||
@@ -9,10 +9,11 @@ | |||
9 | #include <linux/scatterlist.h> | 9 | #include <linux/scatterlist.h> |
10 | #include <asm/io.h> | 10 | #include <asm/io.h> |
11 | #include <asm/swiotlb.h> | 11 | #include <asm/swiotlb.h> |
12 | #include <asm-generic/dma-coherent.h> | ||
12 | 13 | ||
13 | extern dma_addr_t bad_dma_address; | 14 | extern dma_addr_t bad_dma_address; |
14 | extern int iommu_merge; | 15 | extern int iommu_merge; |
15 | extern struct device fallback_dev; | 16 | extern struct device x86_dma_fallback_dev; |
16 | extern int panic_on_overflow; | 17 | extern int panic_on_overflow; |
17 | extern int force_iommu; | 18 | extern int force_iommu; |
18 | 19 | ||
@@ -87,13 +88,7 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) | |||
87 | 88 | ||
88 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) | 89 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) |
89 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) | 90 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) |
90 | 91 | #define dma_is_consistent(d, h) (1) | |
91 | void *dma_alloc_coherent(struct device *dev, size_t size, | ||
92 | dma_addr_t *dma_handle, gfp_t flag); | ||
93 | |||
94 | void dma_free_coherent(struct device *dev, size_t size, | ||
95 | void *vaddr, dma_addr_t dma_handle); | ||
96 | |||
97 | 92 | ||
98 | extern int dma_supported(struct device *hwdev, u64 mask); | 93 | extern int dma_supported(struct device *hwdev, u64 mask); |
99 | extern int dma_set_mask(struct device *dev, u64 mask); | 94 | extern int dma_set_mask(struct device *dev, u64 mask); |
@@ -247,7 +242,39 @@ static inline int dma_get_cache_alignment(void) | |||
247 | return boot_cpu_data.x86_clflush_size; | 242 | return boot_cpu_data.x86_clflush_size; |
248 | } | 243 | } |
249 | 244 | ||
250 | #define dma_is_consistent(d, h) (1) | 245 | static inline void * |
246 | dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, | ||
247 | gfp_t gfp) | ||
248 | { | ||
249 | struct dma_mapping_ops *ops = get_dma_ops(dev); | ||
250 | void *memory; | ||
251 | |||
252 | if (dma_alloc_from_coherent(dev, size, dma_handle, &memory)) | ||
253 | return memory; | ||
254 | |||
255 | if (!dev) { | ||
256 | dev = &x86_dma_fallback_dev; | ||
257 | gfp |= GFP_DMA; | ||
258 | } | ||
259 | |||
260 | if (ops->alloc_coherent) | ||
261 | return ops->alloc_coherent(dev, size, | ||
262 | dma_handle, gfp); | ||
263 | return NULL; | ||
264 | } | ||
265 | |||
266 | static inline void dma_free_coherent(struct device *dev, size_t size, | ||
267 | void *vaddr, dma_addr_t bus) | ||
268 | { | ||
269 | struct dma_mapping_ops *ops = get_dma_ops(dev); | ||
270 | |||
271 | WARN_ON(irqs_disabled()); /* for portability */ | ||
272 | |||
273 | if (dma_release_from_coherent(dev, get_order(size), vaddr)) | ||
274 | return; | ||
275 | |||
276 | if (ops->free_coherent) | ||
277 | ops->free_coherent(dev, size, vaddr, bus); | ||
278 | } | ||
251 | 279 | ||
252 | #include <asm-generic/dma-coherent.h> | ||
253 | #endif | 280 | #endif |