diff options
Diffstat (limited to 'arch/sh/mm/consistent.c')
-rw-r--r-- | arch/sh/mm/consistent.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c index edcd5fbf9651..e098ec158ddb 100644 --- a/arch/sh/mm/consistent.c +++ b/arch/sh/mm/consistent.c | |||
@@ -10,11 +10,22 @@ | |||
10 | * for more details. | 10 | * for more details. |
11 | */ | 11 | */ |
12 | #include <linux/mm.h> | 12 | #include <linux/mm.h> |
13 | #include <linux/init.h> | ||
13 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
14 | #include <linux/dma-mapping.h> | 15 | #include <linux/dma-mapping.h> |
16 | #include <linux/dma-debug.h> | ||
17 | #include <linux/io.h> | ||
15 | #include <asm/cacheflush.h> | 18 | #include <asm/cacheflush.h> |
16 | #include <asm/addrspace.h> | 19 | #include <asm/addrspace.h> |
17 | #include <asm/io.h> | 20 | |
21 | #define PREALLOC_DMA_DEBUG_ENTRIES 4096 | ||
22 | |||
23 | static int __init dma_init(void) | ||
24 | { | ||
25 | dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); | ||
26 | return 0; | ||
27 | } | ||
28 | fs_initcall(dma_init); | ||
18 | 29 | ||
19 | void *dma_alloc_coherent(struct device *dev, size_t size, | 30 | void *dma_alloc_coherent(struct device *dev, size_t size, |
20 | dma_addr_t *dma_handle, gfp_t gfp) | 31 | dma_addr_t *dma_handle, gfp_t gfp) |
@@ -45,6 +56,9 @@ void *dma_alloc_coherent(struct device *dev, size_t size, | |||
45 | split_page(pfn_to_page(virt_to_phys(ret) >> PAGE_SHIFT), order); | 56 | split_page(pfn_to_page(virt_to_phys(ret) >> PAGE_SHIFT), order); |
46 | 57 | ||
47 | *dma_handle = virt_to_phys(ret); | 58 | *dma_handle = virt_to_phys(ret); |
59 | |||
60 | debug_dma_alloc_coherent(dev, size, *dma_handle, ret_nocache); | ||
61 | |||
48 | return ret_nocache; | 62 | return ret_nocache; |
49 | } | 63 | } |
50 | EXPORT_SYMBOL(dma_alloc_coherent); | 64 | EXPORT_SYMBOL(dma_alloc_coherent); |
@@ -56,12 +70,15 @@ void dma_free_coherent(struct device *dev, size_t size, | |||
56 | unsigned long pfn = dma_handle >> PAGE_SHIFT; | 70 | unsigned long pfn = dma_handle >> PAGE_SHIFT; |
57 | int k; | 71 | int k; |
58 | 72 | ||
59 | if (!dma_release_from_coherent(dev, order, vaddr)) { | 73 | WARN_ON(irqs_disabled()); /* for portability */ |
60 | WARN_ON(irqs_disabled()); /* for portability */ | 74 | |
61 | for (k = 0; k < (1 << order); k++) | 75 | if (dma_release_from_coherent(dev, order, vaddr)) |
62 | __free_pages(pfn_to_page(pfn + k), 0); | 76 | return; |
63 | iounmap(vaddr); | 77 | |
64 | } | 78 | debug_dma_free_coherent(dev, size, vaddr, dma_handle); |
79 | for (k = 0; k < (1 << order); k++) | ||
80 | __free_pages(pfn_to_page(pfn + k), 0); | ||
81 | iounmap(vaddr); | ||
65 | } | 82 | } |
66 | EXPORT_SYMBOL(dma_free_coherent); | 83 | EXPORT_SYMBOL(dma_free_coherent); |
67 | 84 | ||