aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/pci-dma.c
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2008-08-19 10:32:45 -0400
committerIngo Molnar <mingo@elte.hu>2008-08-22 02:34:51 -0400
commit6c505ce3930c6a6b455cda53fab3e88ae44f8221 (patch)
tree5b6254c6589f458ad0af21d7f6fbc998ebfd3714 /arch/x86/kernel/pci-dma.c
parentc647c3bb2d16246a87f49035985ddb7c1eb030df (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 'arch/x86/kernel/pci-dma.c')
-rw-r--r--arch/x86/kernel/pci-dma.c49
1 files changed, 3 insertions, 46 deletions
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 613332b26e31..0a1408abcc62 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -41,11 +41,12 @@ EXPORT_SYMBOL(bad_dma_address);
41/* Dummy device used for NULL arguments (normally ISA). Better would 41/* Dummy device used for NULL arguments (normally ISA). Better would
42 be probably a smaller DMA mask, but this is bug-to-bug compatible 42 be probably a smaller DMA mask, but this is bug-to-bug compatible
43 to older i386. */ 43 to older i386. */
44struct device fallback_dev = { 44struct device x86_dma_fallback_dev = {
45 .bus_id = "fallback device", 45 .bus_id = "fallback device",
46 .coherent_dma_mask = DMA_32BIT_MASK, 46 .coherent_dma_mask = DMA_32BIT_MASK,
47 .dma_mask = &fallback_dev.coherent_dma_mask, 47 .dma_mask = &x86_dma_fallback_dev.coherent_dma_mask,
48}; 48};
49EXPORT_SYMBOL(x86_dma_fallback_dev);
49 50
50int dma_set_mask(struct device *dev, u64 mask) 51int dma_set_mask(struct device *dev, u64 mask)
51{ 52{
@@ -241,50 +242,6 @@ int dma_supported(struct device *dev, u64 mask)
241} 242}
242EXPORT_SYMBOL(dma_supported); 243EXPORT_SYMBOL(dma_supported);
243 244
244/*
245 * Allocate memory for a coherent mapping.
246 */
247 void *
248dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
249 gfp_t gfp)
250{
251 struct dma_mapping_ops *ops = get_dma_ops(dev);
252 void *memory;
253
254 if (dma_alloc_from_coherent(dev, size, dma_handle, &memory))
255 return memory;
256
257 if (!dev) {
258 dev = &fallback_dev;
259 gfp |= GFP_DMA;
260 }
261
262 if (ops->alloc_coherent)
263 return ops->alloc_coherent(dev, size,
264 dma_handle, gfp);
265 return NULL;
266}
267EXPORT_SYMBOL(dma_alloc_coherent);
268
269/*
270 * Unmap coherent memory.
271 * The caller must ensure that the device has finished accessing the mapping.
272 */
273void dma_free_coherent(struct device *dev, size_t size,
274 void *vaddr, dma_addr_t bus)
275{
276 struct dma_mapping_ops *ops = get_dma_ops(dev);
277
278 WARN_ON(irqs_disabled()); /* for portability */
279
280 if (dma_release_from_coherent(dev, get_order(size), vaddr))
281 return;
282
283 if (ops->free_coherent)
284 ops->free_coherent(dev, size, vaddr, bus);
285}
286EXPORT_SYMBOL(dma_free_coherent);
287
288static int __init pci_iommu_init(void) 245static int __init pci_iommu_init(void)
289{ 246{
290 calgary_iommu_init(); 247 calgary_iommu_init();