diff options
Diffstat (limited to 'arch/arm/mm')
-rw-r--r-- | arch/arm/mm/dma-mapping.c | 45 | ||||
-rw-r--r-- | arch/arm/mm/init.c | 9 |
2 files changed, 34 insertions, 20 deletions
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index c3ff82f92d9c..01f5987eb1ad 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c | |||
@@ -18,12 +18,14 @@ | |||
18 | #include <linux/device.h> | 18 | #include <linux/device.h> |
19 | #include <linux/dma-mapping.h> | 19 | #include <linux/dma-mapping.h> |
20 | #include <linux/highmem.h> | 20 | #include <linux/highmem.h> |
21 | #include <linux/slab.h> | ||
21 | 22 | ||
22 | #include <asm/memory.h> | 23 | #include <asm/memory.h> |
23 | #include <asm/highmem.h> | 24 | #include <asm/highmem.h> |
24 | #include <asm/cacheflush.h> | 25 | #include <asm/cacheflush.h> |
25 | #include <asm/tlbflush.h> | 26 | #include <asm/tlbflush.h> |
26 | #include <asm/sizes.h> | 27 | #include <asm/sizes.h> |
28 | #include <asm/mach/arch.h> | ||
27 | 29 | ||
28 | #include "mm.h" | 30 | #include "mm.h" |
29 | 31 | ||
@@ -117,26 +119,37 @@ static void __dma_free_buffer(struct page *page, size_t size) | |||
117 | } | 119 | } |
118 | 120 | ||
119 | #ifdef CONFIG_MMU | 121 | #ifdef CONFIG_MMU |
120 | /* Sanity check size */ | ||
121 | #if (CONSISTENT_DMA_SIZE % SZ_2M) | ||
122 | #error "CONSISTENT_DMA_SIZE must be multiple of 2MiB" | ||
123 | #endif | ||
124 | 122 | ||
125 | #define CONSISTENT_OFFSET(x) (((unsigned long)(x) - CONSISTENT_BASE) >> PAGE_SHIFT) | 123 | |
126 | #define CONSISTENT_PTE_INDEX(x) (((unsigned long)(x) - CONSISTENT_BASE) >> PGDIR_SHIFT) | 124 | #define CONSISTENT_OFFSET(x) (((unsigned long)(x) - consistent_base) >> PAGE_SHIFT) |
127 | #define NUM_CONSISTENT_PTES (CONSISTENT_DMA_SIZE >> PGDIR_SHIFT) | 125 | #define CONSISTENT_PTE_INDEX(x) (((unsigned long)(x) - consistent_base) >> PGDIR_SHIFT) |
128 | 126 | ||
129 | /* | 127 | /* |
130 | * These are the page tables (2MB each) covering uncached, DMA consistent allocations | 128 | * These are the page tables (2MB each) covering uncached, DMA consistent allocations |
131 | */ | 129 | */ |
132 | static pte_t *consistent_pte[NUM_CONSISTENT_PTES]; | 130 | static pte_t **consistent_pte; |
131 | |||
132 | #define DEFAULT_CONSISTENT_DMA_SIZE SZ_2M | ||
133 | |||
134 | unsigned long consistent_base = CONSISTENT_END - DEFAULT_CONSISTENT_DMA_SIZE; | ||
135 | |||
136 | void __init init_consistent_dma_size(unsigned long size) | ||
137 | { | ||
138 | unsigned long base = CONSISTENT_END - ALIGN(size, SZ_2M); | ||
139 | |||
140 | BUG_ON(consistent_pte); /* Check we're called before DMA region init */ | ||
141 | BUG_ON(base < VMALLOC_END); | ||
142 | |||
143 | /* Grow region to accommodate specified size */ | ||
144 | if (base < consistent_base) | ||
145 | consistent_base = base; | ||
146 | } | ||
133 | 147 | ||
134 | #include "vmregion.h" | 148 | #include "vmregion.h" |
135 | 149 | ||
136 | static struct arm_vmregion_head consistent_head = { | 150 | static struct arm_vmregion_head consistent_head = { |
137 | .vm_lock = __SPIN_LOCK_UNLOCKED(&consistent_head.vm_lock), | 151 | .vm_lock = __SPIN_LOCK_UNLOCKED(&consistent_head.vm_lock), |
138 | .vm_list = LIST_HEAD_INIT(consistent_head.vm_list), | 152 | .vm_list = LIST_HEAD_INIT(consistent_head.vm_list), |
139 | .vm_start = CONSISTENT_BASE, | ||
140 | .vm_end = CONSISTENT_END, | 153 | .vm_end = CONSISTENT_END, |
141 | }; | 154 | }; |
142 | 155 | ||
@@ -155,7 +168,17 @@ static int __init consistent_init(void) | |||
155 | pmd_t *pmd; | 168 | pmd_t *pmd; |
156 | pte_t *pte; | 169 | pte_t *pte; |
157 | int i = 0; | 170 | int i = 0; |
158 | u32 base = CONSISTENT_BASE; | 171 | unsigned long base = consistent_base; |
172 | unsigned long num_ptes = (CONSISTENT_END - base) >> PGDIR_SHIFT; | ||
173 | |||
174 | consistent_pte = kmalloc(num_ptes * sizeof(pte_t), GFP_KERNEL); | ||
175 | if (!consistent_pte) { | ||
176 | pr_err("%s: no memory\n", __func__); | ||
177 | return -ENOMEM; | ||
178 | } | ||
179 | |||
180 | pr_debug("DMA memory: 0x%08lx - 0x%08lx:\n", base, CONSISTENT_END); | ||
181 | consistent_head.vm_start = base; | ||
159 | 182 | ||
160 | do { | 183 | do { |
161 | pgd = pgd_offset(&init_mm, base); | 184 | pgd = pgd_offset(&init_mm, base); |
@@ -198,7 +221,7 @@ __dma_alloc_remap(struct page *page, size_t size, gfp_t gfp, pgprot_t prot) | |||
198 | size_t align; | 221 | size_t align; |
199 | int bit; | 222 | int bit; |
200 | 223 | ||
201 | if (!consistent_pte[0]) { | 224 | if (!consistent_pte) { |
202 | printk(KERN_ERR "%s: not initialised\n", __func__); | 225 | printk(KERN_ERR "%s: not initialised\n", __func__); |
203 | dump_stack(); | 226 | dump_stack(); |
204 | return NULL; | 227 | return NULL; |
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index cc7e2d8be9aa..34409a08ba0d 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c | |||
@@ -653,9 +653,6 @@ void __init mem_init(void) | |||
653 | " ITCM : 0x%08lx - 0x%08lx (%4ld kB)\n" | 653 | " ITCM : 0x%08lx - 0x%08lx (%4ld kB)\n" |
654 | #endif | 654 | #endif |
655 | " fixmap : 0x%08lx - 0x%08lx (%4ld kB)\n" | 655 | " fixmap : 0x%08lx - 0x%08lx (%4ld kB)\n" |
656 | #ifdef CONFIG_MMU | ||
657 | " DMA : 0x%08lx - 0x%08lx (%4ld MB)\n" | ||
658 | #endif | ||
659 | " vmalloc : 0x%08lx - 0x%08lx (%4ld MB)\n" | 656 | " vmalloc : 0x%08lx - 0x%08lx (%4ld MB)\n" |
660 | " lowmem : 0x%08lx - 0x%08lx (%4ld MB)\n" | 657 | " lowmem : 0x%08lx - 0x%08lx (%4ld MB)\n" |
661 | #ifdef CONFIG_HIGHMEM | 658 | #ifdef CONFIG_HIGHMEM |
@@ -674,9 +671,6 @@ void __init mem_init(void) | |||
674 | MLK(ITCM_OFFSET, (unsigned long) itcm_end), | 671 | MLK(ITCM_OFFSET, (unsigned long) itcm_end), |
675 | #endif | 672 | #endif |
676 | MLK(FIXADDR_START, FIXADDR_TOP), | 673 | MLK(FIXADDR_START, FIXADDR_TOP), |
677 | #ifdef CONFIG_MMU | ||
678 | MLM(CONSISTENT_BASE, CONSISTENT_END), | ||
679 | #endif | ||
680 | MLM(VMALLOC_START, VMALLOC_END), | 674 | MLM(VMALLOC_START, VMALLOC_END), |
681 | MLM(PAGE_OFFSET, (unsigned long)high_memory), | 675 | MLM(PAGE_OFFSET, (unsigned long)high_memory), |
682 | #ifdef CONFIG_HIGHMEM | 676 | #ifdef CONFIG_HIGHMEM |
@@ -699,9 +693,6 @@ void __init mem_init(void) | |||
699 | * be detected at build time already. | 693 | * be detected at build time already. |
700 | */ | 694 | */ |
701 | #ifdef CONFIG_MMU | 695 | #ifdef CONFIG_MMU |
702 | BUILD_BUG_ON(VMALLOC_END > CONSISTENT_BASE); | ||
703 | BUG_ON(VMALLOC_END > CONSISTENT_BASE); | ||
704 | |||
705 | BUILD_BUG_ON(TASK_SIZE > MODULES_VADDR); | 696 | BUILD_BUG_ON(TASK_SIZE > MODULES_VADDR); |
706 | BUG_ON(TASK_SIZE > MODULES_VADDR); | 697 | BUG_ON(TASK_SIZE > MODULES_VADDR); |
707 | #endif | 698 | #endif |