diff options
Diffstat (limited to 'arch/powerpc/mm')
-rw-r--r-- | arch/powerpc/mm/40x_mmu.c | 2 | ||||
-rw-r--r-- | arch/powerpc/mm/44x_mmu.c | 2 | ||||
-rw-r--r-- | arch/powerpc/mm/Makefile | 2 | ||||
-rw-r--r-- | arch/powerpc/mm/fsl_booke_mmu.c | 48 | ||||
-rw-r--r-- | arch/powerpc/mm/hash_utils_64.c | 32 | ||||
-rw-r--r-- | arch/powerpc/mm/init_32.c | 27 | ||||
-rw-r--r-- | arch/powerpc/mm/init_64.c | 7 | ||||
-rw-r--r-- | arch/powerpc/mm/lmb.c | 357 | ||||
-rw-r--r-- | arch/powerpc/mm/mem.c | 21 | ||||
-rw-r--r-- | arch/powerpc/mm/mmu_decl.h | 4 | ||||
-rw-r--r-- | arch/powerpc/mm/numa.c | 3 | ||||
-rw-r--r-- | arch/powerpc/mm/pgtable_32.c | 5 | ||||
-rw-r--r-- | arch/powerpc/mm/ppc_mmu_32.c | 15 | ||||
-rw-r--r-- | arch/powerpc/mm/stab.c | 4 |
14 files changed, 97 insertions, 432 deletions
diff --git a/arch/powerpc/mm/40x_mmu.c b/arch/powerpc/mm/40x_mmu.c index 3899ea97fbdf..cecbbc76f624 100644 --- a/arch/powerpc/mm/40x_mmu.c +++ b/arch/powerpc/mm/40x_mmu.c | |||
@@ -97,7 +97,7 @@ unsigned long __init mmu_mapin_ram(void) | |||
97 | phys_addr_t p; | 97 | phys_addr_t p; |
98 | 98 | ||
99 | v = KERNELBASE; | 99 | v = KERNELBASE; |
100 | p = PPC_MEMSTART; | 100 | p = 0; |
101 | s = total_lowmem; | 101 | s = total_lowmem; |
102 | 102 | ||
103 | if (__map_without_ltlbs) | 103 | if (__map_without_ltlbs) |
diff --git a/arch/powerpc/mm/44x_mmu.c b/arch/powerpc/mm/44x_mmu.c index 04dc08798d3d..953fb919eb06 100644 --- a/arch/powerpc/mm/44x_mmu.c +++ b/arch/powerpc/mm/44x_mmu.c | |||
@@ -67,7 +67,7 @@ unsigned long __init mmu_mapin_ram(void) | |||
67 | 67 | ||
68 | /* Pin in enough TLBs to cover any lowmem not covered by the | 68 | /* Pin in enough TLBs to cover any lowmem not covered by the |
69 | * initial 256M mapping established in head_44x.S */ | 69 | * initial 256M mapping established in head_44x.S */ |
70 | for (addr = PPC_PIN_SIZE; addr < total_lowmem; | 70 | for (addr = PPC_PIN_SIZE; addr < lowmem_end_addr; |
71 | addr += PPC_PIN_SIZE) | 71 | addr += PPC_PIN_SIZE) |
72 | ppc44x_pin_tlb(addr + PAGE_OFFSET, addr); | 72 | ppc44x_pin_tlb(addr + PAGE_OFFSET, addr); |
73 | 73 | ||
diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile index 41649a5d3602..1c00e0196f6c 100644 --- a/arch/powerpc/mm/Makefile +++ b/arch/powerpc/mm/Makefile | |||
@@ -6,7 +6,7 @@ ifeq ($(CONFIG_PPC64),y) | |||
6 | EXTRA_CFLAGS += -mno-minimal-toc | 6 | EXTRA_CFLAGS += -mno-minimal-toc |
7 | endif | 7 | endif |
8 | 8 | ||
9 | obj-y := fault.o mem.o lmb.o \ | 9 | obj-y := fault.o mem.o \ |
10 | init_$(CONFIG_WORD_SIZE).o \ | 10 | init_$(CONFIG_WORD_SIZE).o \ |
11 | pgtable_$(CONFIG_WORD_SIZE).o \ | 11 | pgtable_$(CONFIG_WORD_SIZE).o \ |
12 | mmu_context_$(CONFIG_WORD_SIZE).o | 12 | mmu_context_$(CONFIG_WORD_SIZE).o |
diff --git a/arch/powerpc/mm/fsl_booke_mmu.c b/arch/powerpc/mm/fsl_booke_mmu.c index c93a966b7e4b..ada249bf9779 100644 --- a/arch/powerpc/mm/fsl_booke_mmu.c +++ b/arch/powerpc/mm/fsl_booke_mmu.c | |||
@@ -49,18 +49,15 @@ | |||
49 | #include <asm/mmu.h> | 49 | #include <asm/mmu.h> |
50 | #include <asm/uaccess.h> | 50 | #include <asm/uaccess.h> |
51 | #include <asm/smp.h> | 51 | #include <asm/smp.h> |
52 | #include <asm/bootx.h> | ||
53 | #include <asm/machdep.h> | 52 | #include <asm/machdep.h> |
54 | #include <asm/setup.h> | 53 | #include <asm/setup.h> |
55 | 54 | ||
55 | #include "mmu_decl.h" | ||
56 | |||
56 | extern void loadcam_entry(unsigned int index); | 57 | extern void loadcam_entry(unsigned int index); |
57 | unsigned int tlbcam_index; | 58 | unsigned int tlbcam_index; |
58 | unsigned int num_tlbcam_entries; | 59 | unsigned int num_tlbcam_entries; |
59 | static unsigned long __cam0, __cam1, __cam2; | 60 | static unsigned long __cam0, __cam1, __cam2; |
60 | extern unsigned long total_lowmem; | ||
61 | extern unsigned long __max_low_memory; | ||
62 | extern unsigned long __initial_memory_limit; | ||
63 | #define MAX_LOW_MEM CONFIG_LOWMEM_SIZE | ||
64 | 61 | ||
65 | #define NUM_TLBCAMS (16) | 62 | #define NUM_TLBCAMS (16) |
66 | 63 | ||
@@ -165,15 +162,15 @@ void invalidate_tlbcam_entry(int index) | |||
165 | void __init cam_mapin_ram(unsigned long cam0, unsigned long cam1, | 162 | void __init cam_mapin_ram(unsigned long cam0, unsigned long cam1, |
166 | unsigned long cam2) | 163 | unsigned long cam2) |
167 | { | 164 | { |
168 | settlbcam(0, PAGE_OFFSET, PPC_MEMSTART, cam0, _PAGE_KERNEL, 0); | 165 | settlbcam(0, PAGE_OFFSET, memstart_addr, cam0, _PAGE_KERNEL, 0); |
169 | tlbcam_index++; | 166 | tlbcam_index++; |
170 | if (cam1) { | 167 | if (cam1) { |
171 | tlbcam_index++; | 168 | tlbcam_index++; |
172 | settlbcam(1, PAGE_OFFSET+cam0, PPC_MEMSTART+cam0, cam1, _PAGE_KERNEL, 0); | 169 | settlbcam(1, PAGE_OFFSET+cam0, memstart_addr+cam0, cam1, _PAGE_KERNEL, 0); |
173 | } | 170 | } |
174 | if (cam2) { | 171 | if (cam2) { |
175 | tlbcam_index++; | 172 | tlbcam_index++; |
176 | settlbcam(2, PAGE_OFFSET+cam0+cam1, PPC_MEMSTART+cam0+cam1, cam2, _PAGE_KERNEL, 0); | 173 | settlbcam(2, PAGE_OFFSET+cam0+cam1, memstart_addr+cam0+cam1, cam2, _PAGE_KERNEL, 0); |
177 | } | 174 | } |
178 | } | 175 | } |
179 | 176 | ||
@@ -196,35 +193,32 @@ unsigned long __init mmu_mapin_ram(void) | |||
196 | void __init | 193 | void __init |
197 | adjust_total_lowmem(void) | 194 | adjust_total_lowmem(void) |
198 | { | 195 | { |
199 | unsigned long max_low_mem = MAX_LOW_MEM; | 196 | phys_addr_t max_lowmem_size = __max_low_memory; |
200 | unsigned long cam_max = 0x10000000; | 197 | phys_addr_t cam_max_size = 0x10000000; |
201 | unsigned long ram; | 198 | phys_addr_t ram; |
202 | 199 | ||
203 | /* adjust CAM size to max_low_mem */ | 200 | /* adjust CAM size to max_lowmem_size */ |
204 | if (max_low_mem < cam_max) | 201 | if (max_lowmem_size < cam_max_size) |
205 | cam_max = max_low_mem; | 202 | cam_max_size = max_lowmem_size; |
206 | 203 | ||
207 | /* adjust lowmem size to max_low_mem */ | 204 | /* adjust lowmem size to max_lowmem_size */ |
208 | if (max_low_mem < total_lowmem) | 205 | ram = min(max_lowmem_size, total_lowmem); |
209 | ram = max_low_mem; | ||
210 | else | ||
211 | ram = total_lowmem; | ||
212 | 206 | ||
213 | /* Calculate CAM values */ | 207 | /* Calculate CAM values */ |
214 | __cam0 = 1UL << 2 * (__ilog2(ram) / 2); | 208 | __cam0 = 1UL << 2 * (__ilog2(ram) / 2); |
215 | if (__cam0 > cam_max) | 209 | if (__cam0 > cam_max_size) |
216 | __cam0 = cam_max; | 210 | __cam0 = cam_max_size; |
217 | ram -= __cam0; | 211 | ram -= __cam0; |
218 | if (ram) { | 212 | if (ram) { |
219 | __cam1 = 1UL << 2 * (__ilog2(ram) / 2); | 213 | __cam1 = 1UL << 2 * (__ilog2(ram) / 2); |
220 | if (__cam1 > cam_max) | 214 | if (__cam1 > cam_max_size) |
221 | __cam1 = cam_max; | 215 | __cam1 = cam_max_size; |
222 | ram -= __cam1; | 216 | ram -= __cam1; |
223 | } | 217 | } |
224 | if (ram) { | 218 | if (ram) { |
225 | __cam2 = 1UL << 2 * (__ilog2(ram) / 2); | 219 | __cam2 = 1UL << 2 * (__ilog2(ram) / 2); |
226 | if (__cam2 > cam_max) | 220 | if (__cam2 > cam_max_size) |
227 | __cam2 = cam_max; | 221 | __cam2 = cam_max_size; |
228 | ram -= __cam2; | 222 | ram -= __cam2; |
229 | } | 223 | } |
230 | 224 | ||
@@ -232,6 +226,6 @@ adjust_total_lowmem(void) | |||
232 | " CAM2=%ldMb residual: %ldMb\n", | 226 | " CAM2=%ldMb residual: %ldMb\n", |
233 | __cam0 >> 20, __cam1 >> 20, __cam2 >> 20, | 227 | __cam0 >> 20, __cam1 >> 20, __cam2 >> 20, |
234 | (total_lowmem - __cam0 - __cam1 - __cam2) >> 20); | 228 | (total_lowmem - __cam0 - __cam1 - __cam2) >> 20); |
235 | __max_low_memory = max_low_mem = __cam0 + __cam1 + __cam2; | 229 | __max_low_memory = __cam0 + __cam1 + __cam2; |
236 | __initial_memory_limit = __max_low_memory; | 230 | __initial_memory_limit_addr = memstart_addr + __max_low_memory; |
237 | } | 231 | } |
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c index a83dfa3cf40c..2b5a399f6fa6 100644 --- a/arch/powerpc/mm/hash_utils_64.c +++ b/arch/powerpc/mm/hash_utils_64.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/cache.h> | 31 | #include <linux/cache.h> |
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/signal.h> | 33 | #include <linux/signal.h> |
34 | #include <linux/lmb.h> | ||
34 | 35 | ||
35 | #include <asm/processor.h> | 36 | #include <asm/processor.h> |
36 | #include <asm/pgtable.h> | 37 | #include <asm/pgtable.h> |
@@ -41,7 +42,7 @@ | |||
41 | #include <asm/system.h> | 42 | #include <asm/system.h> |
42 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
43 | #include <asm/machdep.h> | 44 | #include <asm/machdep.h> |
44 | #include <asm/lmb.h> | 45 | #include <asm/prom.h> |
45 | #include <asm/abs_addr.h> | 46 | #include <asm/abs_addr.h> |
46 | #include <asm/tlbflush.h> | 47 | #include <asm/tlbflush.h> |
47 | #include <asm/io.h> | 48 | #include <asm/io.h> |
@@ -191,6 +192,29 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend, | |||
191 | return ret < 0 ? ret : 0; | 192 | return ret < 0 ? ret : 0; |
192 | } | 193 | } |
193 | 194 | ||
195 | #ifdef CONFIG_MEMORY_HOTPLUG | ||
196 | static int htab_remove_mapping(unsigned long vstart, unsigned long vend, | ||
197 | int psize, int ssize) | ||
198 | { | ||
199 | unsigned long vaddr; | ||
200 | unsigned int step, shift; | ||
201 | |||
202 | shift = mmu_psize_defs[psize].shift; | ||
203 | step = 1 << shift; | ||
204 | |||
205 | if (!ppc_md.hpte_removebolted) { | ||
206 | printk(KERN_WARNING "Platform doesn't implement " | ||
207 | "hpte_removebolted\n"); | ||
208 | return -EINVAL; | ||
209 | } | ||
210 | |||
211 | for (vaddr = vstart; vaddr < vend; vaddr += step) | ||
212 | ppc_md.hpte_removebolted(vaddr, psize, ssize); | ||
213 | |||
214 | return 0; | ||
215 | } | ||
216 | #endif /* CONFIG_MEMORY_HOTPLUG */ | ||
217 | |||
194 | static int __init htab_dt_scan_seg_sizes(unsigned long node, | 218 | static int __init htab_dt_scan_seg_sizes(unsigned long node, |
195 | const char *uname, int depth, | 219 | const char *uname, int depth, |
196 | void *data) | 220 | void *data) |
@@ -434,6 +458,12 @@ void create_section_mapping(unsigned long start, unsigned long end) | |||
434 | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_COHERENT | PP_RWXX, | 458 | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_COHERENT | PP_RWXX, |
435 | mmu_linear_psize, mmu_kernel_ssize)); | 459 | mmu_linear_psize, mmu_kernel_ssize)); |
436 | } | 460 | } |
461 | |||
462 | int remove_section_mapping(unsigned long start, unsigned long end) | ||
463 | { | ||
464 | return htab_remove_mapping(start, end, mmu_linear_psize, | ||
465 | mmu_kernel_ssize); | ||
466 | } | ||
437 | #endif /* CONFIG_MEMORY_HOTPLUG */ | 467 | #endif /* CONFIG_MEMORY_HOTPLUG */ |
438 | 468 | ||
439 | static inline void make_bl(unsigned int *insn_addr, void *func) | 469 | static inline void make_bl(unsigned int *insn_addr, void *func) |
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c index 977cb1ee5e72..47325f23c51f 100644 --- a/arch/powerpc/mm/init_32.c +++ b/arch/powerpc/mm/init_32.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/highmem.h> | 30 | #include <linux/highmem.h> |
31 | #include <linux/initrd.h> | 31 | #include <linux/initrd.h> |
32 | #include <linux/pagemap.h> | 32 | #include <linux/pagemap.h> |
33 | #include <linux/lmb.h> | ||
33 | 34 | ||
34 | #include <asm/pgalloc.h> | 35 | #include <asm/pgalloc.h> |
35 | #include <asm/prom.h> | 36 | #include <asm/prom.h> |
@@ -41,7 +42,6 @@ | |||
41 | #include <asm/machdep.h> | 42 | #include <asm/machdep.h> |
42 | #include <asm/btext.h> | 43 | #include <asm/btext.h> |
43 | #include <asm/tlb.h> | 44 | #include <asm/tlb.h> |
44 | #include <asm/lmb.h> | ||
45 | #include <asm/sections.h> | 45 | #include <asm/sections.h> |
46 | 46 | ||
47 | #include "mmu_decl.h" | 47 | #include "mmu_decl.h" |
@@ -59,8 +59,8 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); | |||
59 | unsigned long total_memory; | 59 | unsigned long total_memory; |
60 | unsigned long total_lowmem; | 60 | unsigned long total_lowmem; |
61 | 61 | ||
62 | unsigned long ppc_memstart; | 62 | phys_addr_t memstart_addr; |
63 | unsigned long ppc_memoffset = PAGE_OFFSET; | 63 | phys_addr_t lowmem_end_addr; |
64 | 64 | ||
65 | int boot_mapsize; | 65 | int boot_mapsize; |
66 | #ifdef CONFIG_PPC_PMAC | 66 | #ifdef CONFIG_PPC_PMAC |
@@ -95,10 +95,10 @@ int __map_without_ltlbs; | |||
95 | unsigned long __max_low_memory = MAX_LOW_MEM; | 95 | unsigned long __max_low_memory = MAX_LOW_MEM; |
96 | 96 | ||
97 | /* | 97 | /* |
98 | * limit of what is accessible with initial MMU setup - | 98 | * address of the limit of what is accessible with initial MMU setup - |
99 | * 256MB usually, but only 16MB on 601. | 99 | * 256MB usually, but only 16MB on 601. |
100 | */ | 100 | */ |
101 | unsigned long __initial_memory_limit = 0x10000000; | 101 | phys_addr_t __initial_memory_limit_addr = (phys_addr_t)0x10000000; |
102 | 102 | ||
103 | /* | 103 | /* |
104 | * Check for command-line options that affect what MMU_init will do. | 104 | * Check for command-line options that affect what MMU_init will do. |
@@ -131,10 +131,10 @@ void __init MMU_init(void) | |||
131 | 131 | ||
132 | /* 601 can only access 16MB at the moment */ | 132 | /* 601 can only access 16MB at the moment */ |
133 | if (PVR_VER(mfspr(SPRN_PVR)) == 1) | 133 | if (PVR_VER(mfspr(SPRN_PVR)) == 1) |
134 | __initial_memory_limit = 0x01000000; | 134 | __initial_memory_limit_addr = 0x01000000; |
135 | /* 8xx can only access 8MB at the moment */ | 135 | /* 8xx can only access 8MB at the moment */ |
136 | if (PVR_VER(mfspr(SPRN_PVR)) == 0x50) | 136 | if (PVR_VER(mfspr(SPRN_PVR)) == 0x50) |
137 | __initial_memory_limit = 0x00800000; | 137 | __initial_memory_limit_addr = 0x00800000; |
138 | 138 | ||
139 | /* parse args from command line */ | 139 | /* parse args from command line */ |
140 | MMU_setup(); | 140 | MMU_setup(); |
@@ -145,8 +145,8 @@ void __init MMU_init(void) | |||
145 | printk(KERN_WARNING "Only using first contiguous memory region"); | 145 | printk(KERN_WARNING "Only using first contiguous memory region"); |
146 | } | 146 | } |
147 | 147 | ||
148 | total_memory = lmb_end_of_DRAM(); | 148 | total_lowmem = total_memory = lmb_end_of_DRAM() - memstart_addr; |
149 | total_lowmem = total_memory; | 149 | lowmem_end_addr = memstart_addr + total_lowmem; |
150 | 150 | ||
151 | #ifdef CONFIG_FSL_BOOKE | 151 | #ifdef CONFIG_FSL_BOOKE |
152 | /* Freescale Book-E parts expect lowmem to be mapped by fixed TLB | 152 | /* Freescale Book-E parts expect lowmem to be mapped by fixed TLB |
@@ -157,9 +157,10 @@ void __init MMU_init(void) | |||
157 | 157 | ||
158 | if (total_lowmem > __max_low_memory) { | 158 | if (total_lowmem > __max_low_memory) { |
159 | total_lowmem = __max_low_memory; | 159 | total_lowmem = __max_low_memory; |
160 | lowmem_end_addr = memstart_addr + total_lowmem; | ||
160 | #ifndef CONFIG_HIGHMEM | 161 | #ifndef CONFIG_HIGHMEM |
161 | total_memory = total_lowmem; | 162 | total_memory = total_lowmem; |
162 | lmb_enforce_memory_limit(total_lowmem); | 163 | lmb_enforce_memory_limit(lowmem_end_addr); |
163 | lmb_analyze(); | 164 | lmb_analyze(); |
164 | #endif /* CONFIG_HIGHMEM */ | 165 | #endif /* CONFIG_HIGHMEM */ |
165 | } | 166 | } |
@@ -184,8 +185,6 @@ void __init MMU_init(void) | |||
184 | /* Map in I/O resources */ | 185 | /* Map in I/O resources */ |
185 | if (ppc_md.progress) | 186 | if (ppc_md.progress) |
186 | ppc_md.progress("MMU:setio", 0x302); | 187 | ppc_md.progress("MMU:setio", 0x302); |
187 | if (ppc_md.setup_io_mappings) | ||
188 | ppc_md.setup_io_mappings(); | ||
189 | 188 | ||
190 | /* Initialize the context management stuff */ | 189 | /* Initialize the context management stuff */ |
191 | mmu_context_init(); | 190 | mmu_context_init(); |
@@ -208,7 +207,7 @@ void __init *early_get_page(void) | |||
208 | p = alloc_bootmem_pages(PAGE_SIZE); | 207 | p = alloc_bootmem_pages(PAGE_SIZE); |
209 | } else { | 208 | } else { |
210 | p = __va(lmb_alloc_base(PAGE_SIZE, PAGE_SIZE, | 209 | p = __va(lmb_alloc_base(PAGE_SIZE, PAGE_SIZE, |
211 | __initial_memory_limit)); | 210 | __initial_memory_limit_addr)); |
212 | } | 211 | } |
213 | return p; | 212 | return p; |
214 | } | 213 | } |
@@ -276,7 +275,7 @@ static int __init setup_kcore(void) | |||
276 | 275 | ||
277 | kcore_mem = kmalloc(sizeof(struct kcore_list), GFP_ATOMIC); | 276 | kcore_mem = kmalloc(sizeof(struct kcore_list), GFP_ATOMIC); |
278 | if (!kcore_mem) | 277 | if (!kcore_mem) |
279 | panic("%s: kmalloc failed\n", __FUNCTION__); | 278 | panic("%s: kmalloc failed\n", __func__); |
280 | 279 | ||
281 | /* must stay under 32 bits */ | 280 | /* must stay under 32 bits */ |
282 | if ( 0xfffffffful - (unsigned long)__va(base) < size) { | 281 | if ( 0xfffffffful - (unsigned long)__va(base) < size) { |
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c index c0f5cff77035..698bd000f98b 100644 --- a/arch/powerpc/mm/init_64.c +++ b/arch/powerpc/mm/init_64.c | |||
@@ -38,11 +38,11 @@ | |||
38 | #include <linux/nodemask.h> | 38 | #include <linux/nodemask.h> |
39 | #include <linux/module.h> | 39 | #include <linux/module.h> |
40 | #include <linux/poison.h> | 40 | #include <linux/poison.h> |
41 | #include <linux/lmb.h> | ||
41 | 42 | ||
42 | #include <asm/pgalloc.h> | 43 | #include <asm/pgalloc.h> |
43 | #include <asm/page.h> | 44 | #include <asm/page.h> |
44 | #include <asm/prom.h> | 45 | #include <asm/prom.h> |
45 | #include <asm/lmb.h> | ||
46 | #include <asm/rtas.h> | 46 | #include <asm/rtas.h> |
47 | #include <asm/io.h> | 47 | #include <asm/io.h> |
48 | #include <asm/mmu_context.h> | 48 | #include <asm/mmu_context.h> |
@@ -72,8 +72,7 @@ | |||
72 | #warning TASK_SIZE is smaller than it needs to be. | 72 | #warning TASK_SIZE is smaller than it needs to be. |
73 | #endif | 73 | #endif |
74 | 74 | ||
75 | /* max amount of RAM to use */ | 75 | phys_addr_t memstart_addr; |
76 | unsigned long __max_memory; | ||
77 | 76 | ||
78 | void free_initmem(void) | 77 | void free_initmem(void) |
79 | { | 78 | { |
@@ -122,7 +121,7 @@ static int __init setup_kcore(void) | |||
122 | /* GFP_ATOMIC to avoid might_sleep warnings during boot */ | 121 | /* GFP_ATOMIC to avoid might_sleep warnings during boot */ |
123 | kcore_mem = kmalloc(sizeof(struct kcore_list), GFP_ATOMIC); | 122 | kcore_mem = kmalloc(sizeof(struct kcore_list), GFP_ATOMIC); |
124 | if (!kcore_mem) | 123 | if (!kcore_mem) |
125 | panic("%s: kmalloc failed\n", __FUNCTION__); | 124 | panic("%s: kmalloc failed\n", __func__); |
126 | 125 | ||
127 | kclist_add(kcore_mem, __va(base), size); | 126 | kclist_add(kcore_mem, __va(base), size); |
128 | } | 127 | } |
diff --git a/arch/powerpc/mm/lmb.c b/arch/powerpc/mm/lmb.c deleted file mode 100644 index 4ce23bcf8a57..000000000000 --- a/arch/powerpc/mm/lmb.c +++ /dev/null | |||
@@ -1,357 +0,0 @@ | |||
1 | /* | ||
2 | * Procedures for maintaining information about logical memory blocks. | ||
3 | * | ||
4 | * Peter Bergner, IBM Corp. June 2001. | ||
5 | * Copyright (C) 2001 Peter Bergner. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version | ||
10 | * 2 of the License, or (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/bitops.h> | ||
16 | #include <asm/types.h> | ||
17 | #include <asm/page.h> | ||
18 | #include <asm/prom.h> | ||
19 | #include <asm/lmb.h> | ||
20 | #ifdef CONFIG_PPC32 | ||
21 | #include "mmu_decl.h" /* for __max_low_memory */ | ||
22 | #endif | ||
23 | |||
24 | #undef DEBUG | ||
25 | |||
26 | #ifdef DEBUG | ||
27 | #include <asm/udbg.h> | ||
28 | #define DBG(fmt...) udbg_printf(fmt) | ||
29 | #else | ||
30 | #define DBG(fmt...) | ||
31 | #endif | ||
32 | |||
33 | #define LMB_ALLOC_ANYWHERE 0 | ||
34 | |||
35 | struct lmb lmb; | ||
36 | |||
37 | void lmb_dump_all(void) | ||
38 | { | ||
39 | #ifdef DEBUG | ||
40 | unsigned long i; | ||
41 | |||
42 | DBG("lmb_dump_all:\n"); | ||
43 | DBG(" memory.cnt = 0x%lx\n", lmb.memory.cnt); | ||
44 | DBG(" memory.size = 0x%lx\n", lmb.memory.size); | ||
45 | for (i=0; i < lmb.memory.cnt ;i++) { | ||
46 | DBG(" memory.region[0x%x].base = 0x%lx\n", | ||
47 | i, lmb.memory.region[i].base); | ||
48 | DBG(" .size = 0x%lx\n", | ||
49 | lmb.memory.region[i].size); | ||
50 | } | ||
51 | |||
52 | DBG("\n reserved.cnt = 0x%lx\n", lmb.reserved.cnt); | ||
53 | DBG(" reserved.size = 0x%lx\n", lmb.reserved.size); | ||
54 | for (i=0; i < lmb.reserved.cnt ;i++) { | ||
55 | DBG(" reserved.region[0x%x].base = 0x%lx\n", | ||
56 | i, lmb.reserved.region[i].base); | ||
57 | DBG(" .size = 0x%lx\n", | ||
58 | lmb.reserved.region[i].size); | ||
59 | } | ||
60 | #endif /* DEBUG */ | ||
61 | } | ||
62 | |||
63 | static unsigned long __init lmb_addrs_overlap(unsigned long base1, | ||
64 | unsigned long size1, unsigned long base2, unsigned long size2) | ||
65 | { | ||
66 | return ((base1 < (base2+size2)) && (base2 < (base1+size1))); | ||
67 | } | ||
68 | |||
69 | static long __init lmb_addrs_adjacent(unsigned long base1, unsigned long size1, | ||
70 | unsigned long base2, unsigned long size2) | ||
71 | { | ||
72 | if (base2 == base1 + size1) | ||
73 | return 1; | ||
74 | else if (base1 == base2 + size2) | ||
75 | return -1; | ||
76 | |||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | static long __init lmb_regions_adjacent(struct lmb_region *rgn, | ||
81 | unsigned long r1, unsigned long r2) | ||
82 | { | ||
83 | unsigned long base1 = rgn->region[r1].base; | ||
84 | unsigned long size1 = rgn->region[r1].size; | ||
85 | unsigned long base2 = rgn->region[r2].base; | ||
86 | unsigned long size2 = rgn->region[r2].size; | ||
87 | |||
88 | return lmb_addrs_adjacent(base1, size1, base2, size2); | ||
89 | } | ||
90 | |||
91 | static void __init lmb_remove_region(struct lmb_region *rgn, unsigned long r) | ||
92 | { | ||
93 | unsigned long i; | ||
94 | |||
95 | for (i = r; i < rgn->cnt - 1; i++) { | ||
96 | rgn->region[i].base = rgn->region[i + 1].base; | ||
97 | rgn->region[i].size = rgn->region[i + 1].size; | ||
98 | } | ||
99 | rgn->cnt--; | ||
100 | } | ||
101 | |||
102 | /* Assumption: base addr of region 1 < base addr of region 2 */ | ||
103 | static void __init lmb_coalesce_regions(struct lmb_region *rgn, | ||
104 | unsigned long r1, unsigned long r2) | ||
105 | { | ||
106 | rgn->region[r1].size += rgn->region[r2].size; | ||
107 | lmb_remove_region(rgn, r2); | ||
108 | } | ||
109 | |||
110 | /* This routine called with relocation disabled. */ | ||
111 | void __init lmb_init(void) | ||
112 | { | ||
113 | /* Create a dummy zero size LMB which will get coalesced away later. | ||
114 | * This simplifies the lmb_add() code below... | ||
115 | */ | ||
116 | lmb.memory.region[0].base = 0; | ||
117 | lmb.memory.region[0].size = 0; | ||
118 | lmb.memory.cnt = 1; | ||
119 | |||
120 | /* Ditto. */ | ||
121 | lmb.reserved.region[0].base = 0; | ||
122 | lmb.reserved.region[0].size = 0; | ||
123 | lmb.reserved.cnt = 1; | ||
124 | } | ||
125 | |||
126 | /* This routine may be called with relocation disabled. */ | ||
127 | void __init lmb_analyze(void) | ||
128 | { | ||
129 | int i; | ||
130 | |||
131 | lmb.memory.size = 0; | ||
132 | |||
133 | for (i = 0; i < lmb.memory.cnt; i++) | ||
134 | lmb.memory.size += lmb.memory.region[i].size; | ||
135 | } | ||
136 | |||
137 | /* This routine called with relocation disabled. */ | ||
138 | static long __init lmb_add_region(struct lmb_region *rgn, unsigned long base, | ||
139 | unsigned long size) | ||
140 | { | ||
141 | unsigned long coalesced = 0; | ||
142 | long adjacent, i; | ||
143 | |||
144 | /* First try and coalesce this LMB with another. */ | ||
145 | for (i=0; i < rgn->cnt; i++) { | ||
146 | unsigned long rgnbase = rgn->region[i].base; | ||
147 | unsigned long rgnsize = rgn->region[i].size; | ||
148 | |||
149 | if ((rgnbase == base) && (rgnsize == size)) | ||
150 | /* Already have this region, so we're done */ | ||
151 | return 0; | ||
152 | |||
153 | adjacent = lmb_addrs_adjacent(base,size,rgnbase,rgnsize); | ||
154 | if ( adjacent > 0 ) { | ||
155 | rgn->region[i].base -= size; | ||
156 | rgn->region[i].size += size; | ||
157 | coalesced++; | ||
158 | break; | ||
159 | } | ||
160 | else if ( adjacent < 0 ) { | ||
161 | rgn->region[i].size += size; | ||
162 | coalesced++; | ||
163 | break; | ||
164 | } | ||
165 | } | ||
166 | |||
167 | if ((i < rgn->cnt-1) && lmb_regions_adjacent(rgn, i, i+1) ) { | ||
168 | lmb_coalesce_regions(rgn, i, i+1); | ||
169 | coalesced++; | ||
170 | } | ||
171 | |||
172 | if (coalesced) | ||
173 | return coalesced; | ||
174 | if (rgn->cnt >= MAX_LMB_REGIONS) | ||
175 | return -1; | ||
176 | |||
177 | /* Couldn't coalesce the LMB, so add it to the sorted table. */ | ||
178 | for (i = rgn->cnt-1; i >= 0; i--) { | ||
179 | if (base < rgn->region[i].base) { | ||
180 | rgn->region[i+1].base = rgn->region[i].base; | ||
181 | rgn->region[i+1].size = rgn->region[i].size; | ||
182 | } else { | ||
183 | rgn->region[i+1].base = base; | ||
184 | rgn->region[i+1].size = size; | ||
185 | break; | ||
186 | } | ||
187 | } | ||
188 | rgn->cnt++; | ||
189 | |||
190 | return 0; | ||
191 | } | ||
192 | |||
193 | /* This routine may be called with relocation disabled. */ | ||
194 | long __init lmb_add(unsigned long base, unsigned long size) | ||
195 | { | ||
196 | struct lmb_region *_rgn = &(lmb.memory); | ||
197 | |||
198 | /* On pSeries LPAR systems, the first LMB is our RMO region. */ | ||
199 | if (base == 0) | ||
200 | lmb.rmo_size = size; | ||
201 | |||
202 | return lmb_add_region(_rgn, base, size); | ||
203 | |||
204 | } | ||
205 | |||
206 | long __init lmb_reserve(unsigned long base, unsigned long size) | ||
207 | { | ||
208 | struct lmb_region *_rgn = &(lmb.reserved); | ||
209 | |||
210 | BUG_ON(0 == size); | ||
211 | |||
212 | return lmb_add_region(_rgn, base, size); | ||
213 | } | ||
214 | |||
215 | long __init lmb_overlaps_region(struct lmb_region *rgn, unsigned long base, | ||
216 | unsigned long size) | ||
217 | { | ||
218 | unsigned long i; | ||
219 | |||
220 | for (i=0; i < rgn->cnt; i++) { | ||
221 | unsigned long rgnbase = rgn->region[i].base; | ||
222 | unsigned long rgnsize = rgn->region[i].size; | ||
223 | if ( lmb_addrs_overlap(base,size,rgnbase,rgnsize) ) { | ||
224 | break; | ||
225 | } | ||
226 | } | ||
227 | |||
228 | return (i < rgn->cnt) ? i : -1; | ||
229 | } | ||
230 | |||
231 | unsigned long __init lmb_alloc(unsigned long size, unsigned long align) | ||
232 | { | ||
233 | return lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE); | ||
234 | } | ||
235 | |||
236 | unsigned long __init lmb_alloc_base(unsigned long size, unsigned long align, | ||
237 | unsigned long max_addr) | ||
238 | { | ||
239 | unsigned long alloc; | ||
240 | |||
241 | alloc = __lmb_alloc_base(size, align, max_addr); | ||
242 | |||
243 | if (alloc == 0) | ||
244 | panic("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n", | ||
245 | size, max_addr); | ||
246 | |||
247 | return alloc; | ||
248 | } | ||
249 | |||
250 | unsigned long __init __lmb_alloc_base(unsigned long size, unsigned long align, | ||
251 | unsigned long max_addr) | ||
252 | { | ||
253 | long i, j; | ||
254 | unsigned long base = 0; | ||
255 | |||
256 | BUG_ON(0 == size); | ||
257 | |||
258 | #ifdef CONFIG_PPC32 | ||
259 | /* On 32-bit, make sure we allocate lowmem */ | ||
260 | if (max_addr == LMB_ALLOC_ANYWHERE) | ||
261 | max_addr = __max_low_memory; | ||
262 | #endif | ||
263 | for (i = lmb.memory.cnt-1; i >= 0; i--) { | ||
264 | unsigned long lmbbase = lmb.memory.region[i].base; | ||
265 | unsigned long lmbsize = lmb.memory.region[i].size; | ||
266 | |||
267 | if (max_addr == LMB_ALLOC_ANYWHERE) | ||
268 | base = _ALIGN_DOWN(lmbbase + lmbsize - size, align); | ||
269 | else if (lmbbase < max_addr) { | ||
270 | base = min(lmbbase + lmbsize, max_addr); | ||
271 | base = _ALIGN_DOWN(base - size, align); | ||
272 | } else | ||
273 | continue; | ||
274 | |||
275 | while ((lmbbase <= base) && | ||
276 | ((j = lmb_overlaps_region(&lmb.reserved, base, size)) >= 0) ) | ||
277 | base = _ALIGN_DOWN(lmb.reserved.region[j].base - size, | ||
278 | align); | ||
279 | |||
280 | if ((base != 0) && (lmbbase <= base)) | ||
281 | break; | ||
282 | } | ||
283 | |||
284 | if (i < 0) | ||
285 | return 0; | ||
286 | |||
287 | lmb_add_region(&lmb.reserved, base, size); | ||
288 | |||
289 | return base; | ||
290 | } | ||
291 | |||
292 | /* You must call lmb_analyze() before this. */ | ||
293 | unsigned long __init lmb_phys_mem_size(void) | ||
294 | { | ||
295 | return lmb.memory.size; | ||
296 | } | ||
297 | |||
298 | unsigned long __init lmb_end_of_DRAM(void) | ||
299 | { | ||
300 | int idx = lmb.memory.cnt - 1; | ||
301 | |||
302 | return (lmb.memory.region[idx].base + lmb.memory.region[idx].size); | ||
303 | } | ||
304 | |||
305 | /* You must call lmb_analyze() after this. */ | ||
306 | void __init lmb_enforce_memory_limit(unsigned long memory_limit) | ||
307 | { | ||
308 | unsigned long i, limit; | ||
309 | struct lmb_property *p; | ||
310 | |||
311 | if (! memory_limit) | ||
312 | return; | ||
313 | |||
314 | /* Truncate the lmb regions to satisfy the memory limit. */ | ||
315 | limit = memory_limit; | ||
316 | for (i = 0; i < lmb.memory.cnt; i++) { | ||
317 | if (limit > lmb.memory.region[i].size) { | ||
318 | limit -= lmb.memory.region[i].size; | ||
319 | continue; | ||
320 | } | ||
321 | |||
322 | lmb.memory.region[i].size = limit; | ||
323 | lmb.memory.cnt = i + 1; | ||
324 | break; | ||
325 | } | ||
326 | |||
327 | if (lmb.memory.region[0].size < lmb.rmo_size) | ||
328 | lmb.rmo_size = lmb.memory.region[0].size; | ||
329 | |||
330 | /* And truncate any reserves above the limit also. */ | ||
331 | for (i = 0; i < lmb.reserved.cnt; i++) { | ||
332 | p = &lmb.reserved.region[i]; | ||
333 | |||
334 | if (p->base > memory_limit) | ||
335 | p->size = 0; | ||
336 | else if ((p->base + p->size) > memory_limit) | ||
337 | p->size = memory_limit - p->base; | ||
338 | |||
339 | if (p->size == 0) { | ||
340 | lmb_remove_region(&lmb.reserved, i); | ||
341 | i--; | ||
342 | } | ||
343 | } | ||
344 | } | ||
345 | |||
346 | int __init lmb_is_reserved(unsigned long addr) | ||
347 | { | ||
348 | int i; | ||
349 | |||
350 | for (i = 0; i < lmb.reserved.cnt; i++) { | ||
351 | unsigned long upper = lmb.reserved.region[i].base + | ||
352 | lmb.reserved.region[i].size - 1; | ||
353 | if ((addr >= lmb.reserved.region[i].base) && (addr <= upper)) | ||
354 | return 1; | ||
355 | } | ||
356 | return 0; | ||
357 | } | ||
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index be5c506779a7..16def4dcff6d 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/initrd.h> | 31 | #include <linux/initrd.h> |
32 | #include <linux/pagemap.h> | 32 | #include <linux/pagemap.h> |
33 | #include <linux/suspend.h> | 33 | #include <linux/suspend.h> |
34 | #include <linux/lmb.h> | ||
34 | 35 | ||
35 | #include <asm/pgalloc.h> | 36 | #include <asm/pgalloc.h> |
36 | #include <asm/prom.h> | 37 | #include <asm/prom.h> |
@@ -42,7 +43,6 @@ | |||
42 | #include <asm/machdep.h> | 43 | #include <asm/machdep.h> |
43 | #include <asm/btext.h> | 44 | #include <asm/btext.h> |
44 | #include <asm/tlb.h> | 45 | #include <asm/tlb.h> |
45 | #include <asm/lmb.h> | ||
46 | #include <asm/sections.h> | 46 | #include <asm/sections.h> |
47 | #include <asm/vdso.h> | 47 | #include <asm/vdso.h> |
48 | 48 | ||
@@ -111,7 +111,7 @@ int memory_add_physaddr_to_nid(u64 start) | |||
111 | } | 111 | } |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | int __devinit arch_add_memory(int nid, u64 start, u64 size) | 114 | int arch_add_memory(int nid, u64 start, u64 size) |
115 | { | 115 | { |
116 | struct pglist_data *pgdata; | 116 | struct pglist_data *pgdata; |
117 | struct zone *zone; | 117 | struct zone *zone; |
@@ -175,7 +175,6 @@ void show_mem(void) | |||
175 | 175 | ||
176 | printk("Mem-info:\n"); | 176 | printk("Mem-info:\n"); |
177 | show_free_areas(); | 177 | show_free_areas(); |
178 | printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); | ||
179 | for_each_online_pgdat(pgdat) { | 178 | for_each_online_pgdat(pgdat) { |
180 | unsigned long flags; | 179 | unsigned long flags; |
181 | pgdat_resize_lock(pgdat, &flags); | 180 | pgdat_resize_lock(pgdat, &flags); |
@@ -217,9 +216,11 @@ void __init do_init_bootmem(void) | |||
217 | unsigned long total_pages; | 216 | unsigned long total_pages; |
218 | int boot_mapsize; | 217 | int boot_mapsize; |
219 | 218 | ||
220 | max_pfn = total_pages = lmb_end_of_DRAM() >> PAGE_SHIFT; | 219 | max_pfn = lmb_end_of_DRAM() >> PAGE_SHIFT; |
220 | total_pages = (lmb_end_of_DRAM() - memstart_addr) >> PAGE_SHIFT; | ||
221 | #ifdef CONFIG_HIGHMEM | 221 | #ifdef CONFIG_HIGHMEM |
222 | total_pages = total_lowmem >> PAGE_SHIFT; | 222 | total_pages = total_lowmem >> PAGE_SHIFT; |
223 | max_low_pfn = lowmem_end_addr >> PAGE_SHIFT; | ||
223 | #endif | 224 | #endif |
224 | 225 | ||
225 | /* | 226 | /* |
@@ -245,18 +246,18 @@ void __init do_init_bootmem(void) | |||
245 | * present. | 246 | * present. |
246 | */ | 247 | */ |
247 | #ifdef CONFIG_HIGHMEM | 248 | #ifdef CONFIG_HIGHMEM |
248 | free_bootmem_with_active_regions(0, total_lowmem >> PAGE_SHIFT); | 249 | free_bootmem_with_active_regions(0, lowmem_end_addr >> PAGE_SHIFT); |
249 | 250 | ||
250 | /* reserve the sections we're already using */ | 251 | /* reserve the sections we're already using */ |
251 | for (i = 0; i < lmb.reserved.cnt; i++) { | 252 | for (i = 0; i < lmb.reserved.cnt; i++) { |
252 | unsigned long addr = lmb.reserved.region[i].base + | 253 | unsigned long addr = lmb.reserved.region[i].base + |
253 | lmb_size_bytes(&lmb.reserved, i) - 1; | 254 | lmb_size_bytes(&lmb.reserved, i) - 1; |
254 | if (addr < total_lowmem) | 255 | if (addr < lowmem_end_addr) |
255 | reserve_bootmem(lmb.reserved.region[i].base, | 256 | reserve_bootmem(lmb.reserved.region[i].base, |
256 | lmb_size_bytes(&lmb.reserved, i), | 257 | lmb_size_bytes(&lmb.reserved, i), |
257 | BOOTMEM_DEFAULT); | 258 | BOOTMEM_DEFAULT); |
258 | else if (lmb.reserved.region[i].base < total_lowmem) { | 259 | else if (lmb.reserved.region[i].base < lowmem_end_addr) { |
259 | unsigned long adjusted_size = total_lowmem - | 260 | unsigned long adjusted_size = lowmem_end_addr - |
260 | lmb.reserved.region[i].base; | 261 | lmb.reserved.region[i].base; |
261 | reserve_bootmem(lmb.reserved.region[i].base, | 262 | reserve_bootmem(lmb.reserved.region[i].base, |
262 | adjusted_size, BOOTMEM_DEFAULT); | 263 | adjusted_size, BOOTMEM_DEFAULT); |
@@ -326,7 +327,7 @@ void __init paging_init(void) | |||
326 | (top_of_ram - total_ram) >> 20); | 327 | (top_of_ram - total_ram) >> 20); |
327 | memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); | 328 | memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); |
328 | #ifdef CONFIG_HIGHMEM | 329 | #ifdef CONFIG_HIGHMEM |
329 | max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT; | 330 | max_zone_pfns[ZONE_DMA] = lowmem_end_addr >> PAGE_SHIFT; |
330 | max_zone_pfns[ZONE_HIGHMEM] = top_of_ram >> PAGE_SHIFT; | 331 | max_zone_pfns[ZONE_HIGHMEM] = top_of_ram >> PAGE_SHIFT; |
331 | #else | 332 | #else |
332 | max_zone_pfns[ZONE_DMA] = top_of_ram >> PAGE_SHIFT; | 333 | max_zone_pfns[ZONE_DMA] = top_of_ram >> PAGE_SHIFT; |
@@ -381,7 +382,7 @@ void __init mem_init(void) | |||
381 | { | 382 | { |
382 | unsigned long pfn, highmem_mapnr; | 383 | unsigned long pfn, highmem_mapnr; |
383 | 384 | ||
384 | highmem_mapnr = total_lowmem >> PAGE_SHIFT; | 385 | highmem_mapnr = lowmem_end_addr >> PAGE_SHIFT; |
385 | for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) { | 386 | for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) { |
386 | struct page *page = pfn_to_page(pfn); | 387 | struct page *page = pfn_to_page(pfn); |
387 | if (lmb_is_reserved(pfn << PAGE_SHIFT)) | 388 | if (lmb_is_reserved(pfn << PAGE_SHIFT)) |
diff --git a/arch/powerpc/mm/mmu_decl.h b/arch/powerpc/mm/mmu_decl.h index ebfd13dc9d19..04802252a64f 100644 --- a/arch/powerpc/mm/mmu_decl.h +++ b/arch/powerpc/mm/mmu_decl.h | |||
@@ -48,9 +48,11 @@ extern unsigned int num_tlbcam_entries; | |||
48 | 48 | ||
49 | extern unsigned long ioremap_bot; | 49 | extern unsigned long ioremap_bot; |
50 | extern unsigned long __max_low_memory; | 50 | extern unsigned long __max_low_memory; |
51 | extern unsigned long __initial_memory_limit; | 51 | extern phys_addr_t __initial_memory_limit_addr; |
52 | extern unsigned long total_memory; | 52 | extern unsigned long total_memory; |
53 | extern unsigned long total_lowmem; | 53 | extern unsigned long total_lowmem; |
54 | extern phys_addr_t memstart_addr; | ||
55 | extern phys_addr_t lowmem_end_addr; | ||
54 | 56 | ||
55 | /* ...and now those things that may be slightly different between processor | 57 | /* ...and now those things that may be slightly different between processor |
56 | * architectures. -- Dan | 58 | * architectures. -- Dan |
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index a300d254aac6..1efd631211ef 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c | |||
@@ -17,8 +17,9 @@ | |||
17 | #include <linux/nodemask.h> | 17 | #include <linux/nodemask.h> |
18 | #include <linux/cpu.h> | 18 | #include <linux/cpu.h> |
19 | #include <linux/notifier.h> | 19 | #include <linux/notifier.h> |
20 | #include <linux/lmb.h> | ||
20 | #include <asm/sparsemem.h> | 21 | #include <asm/sparsemem.h> |
21 | #include <asm/lmb.h> | 22 | #include <asm/prom.h> |
22 | #include <asm/system.h> | 23 | #include <asm/system.h> |
23 | #include <asm/smp.h> | 24 | #include <asm/smp.h> |
24 | 25 | ||
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c index ac3390f81900..64c44bcc68de 100644 --- a/arch/powerpc/mm/pgtable_32.c +++ b/arch/powerpc/mm/pgtable_32.c | |||
@@ -281,12 +281,13 @@ int map_page(unsigned long va, phys_addr_t pa, int flags) | |||
281 | */ | 281 | */ |
282 | void __init mapin_ram(void) | 282 | void __init mapin_ram(void) |
283 | { | 283 | { |
284 | unsigned long v, p, s, f; | 284 | unsigned long v, s, f; |
285 | phys_addr_t p; | ||
285 | int ktext; | 286 | int ktext; |
286 | 287 | ||
287 | s = mmu_mapin_ram(); | 288 | s = mmu_mapin_ram(); |
288 | v = KERNELBASE + s; | 289 | v = KERNELBASE + s; |
289 | p = PPC_MEMSTART + s; | 290 | p = memstart_addr + s; |
290 | for (; s < total_lowmem; s += PAGE_SIZE) { | 291 | for (; s < total_lowmem; s += PAGE_SIZE) { |
291 | ktext = ((char *) v >= _stext && (char *) v < etext); | 292 | ktext = ((char *) v >= _stext && (char *) v < etext); |
292 | f = ktext ?_PAGE_RAM_TEXT : _PAGE_RAM; | 293 | f = ktext ?_PAGE_RAM_TEXT : _PAGE_RAM; |
diff --git a/arch/powerpc/mm/ppc_mmu_32.c b/arch/powerpc/mm/ppc_mmu_32.c index 5c45d474cfcc..cef9f156874b 100644 --- a/arch/powerpc/mm/ppc_mmu_32.c +++ b/arch/powerpc/mm/ppc_mmu_32.c | |||
@@ -26,11 +26,11 @@ | |||
26 | #include <linux/mm.h> | 26 | #include <linux/mm.h> |
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/highmem.h> | 28 | #include <linux/highmem.h> |
29 | #include <linux/lmb.h> | ||
29 | 30 | ||
30 | #include <asm/prom.h> | 31 | #include <asm/prom.h> |
31 | #include <asm/mmu.h> | 32 | #include <asm/mmu.h> |
32 | #include <asm/machdep.h> | 33 | #include <asm/machdep.h> |
33 | #include <asm/lmb.h> | ||
34 | 34 | ||
35 | #include "mmu_decl.h" | 35 | #include "mmu_decl.h" |
36 | 36 | ||
@@ -82,7 +82,6 @@ unsigned long __init mmu_mapin_ram(void) | |||
82 | #else | 82 | #else |
83 | unsigned long tot, bl, done; | 83 | unsigned long tot, bl, done; |
84 | unsigned long max_size = (256<<20); | 84 | unsigned long max_size = (256<<20); |
85 | unsigned long align; | ||
86 | 85 | ||
87 | if (__map_without_bats) { | 86 | if (__map_without_bats) { |
88 | printk(KERN_DEBUG "RAM mapped without BATs\n"); | 87 | printk(KERN_DEBUG "RAM mapped without BATs\n"); |
@@ -93,19 +92,13 @@ unsigned long __init mmu_mapin_ram(void) | |||
93 | 92 | ||
94 | /* Make sure we don't map a block larger than the | 93 | /* Make sure we don't map a block larger than the |
95 | smallest alignment of the physical address. */ | 94 | smallest alignment of the physical address. */ |
96 | /* alignment of PPC_MEMSTART */ | ||
97 | align = ~(PPC_MEMSTART-1) & PPC_MEMSTART; | ||
98 | /* set BAT block size to MIN(max_size, align) */ | ||
99 | if (align && align < max_size) | ||
100 | max_size = align; | ||
101 | |||
102 | tot = total_lowmem; | 95 | tot = total_lowmem; |
103 | for (bl = 128<<10; bl < max_size; bl <<= 1) { | 96 | for (bl = 128<<10; bl < max_size; bl <<= 1) { |
104 | if (bl * 2 > tot) | 97 | if (bl * 2 > tot) |
105 | break; | 98 | break; |
106 | } | 99 | } |
107 | 100 | ||
108 | setbat(2, KERNELBASE, PPC_MEMSTART, bl, _PAGE_RAM); | 101 | setbat(2, KERNELBASE, 0, bl, _PAGE_RAM); |
109 | done = (unsigned long)bat_addrs[2].limit - KERNELBASE + 1; | 102 | done = (unsigned long)bat_addrs[2].limit - KERNELBASE + 1; |
110 | if ((done < tot) && !bat_addrs[3].limit) { | 103 | if ((done < tot) && !bat_addrs[3].limit) { |
111 | /* use BAT3 to cover a bit more */ | 104 | /* use BAT3 to cover a bit more */ |
@@ -113,7 +106,7 @@ unsigned long __init mmu_mapin_ram(void) | |||
113 | for (bl = 128<<10; bl < max_size; bl <<= 1) | 106 | for (bl = 128<<10; bl < max_size; bl <<= 1) |
114 | if (bl * 2 > tot) | 107 | if (bl * 2 > tot) |
115 | break; | 108 | break; |
116 | setbat(3, KERNELBASE+done, PPC_MEMSTART+done, bl, _PAGE_RAM); | 109 | setbat(3, KERNELBASE+done, done, bl, _PAGE_RAM); |
117 | done = (unsigned long)bat_addrs[3].limit - KERNELBASE + 1; | 110 | done = (unsigned long)bat_addrs[3].limit - KERNELBASE + 1; |
118 | } | 111 | } |
119 | 112 | ||
@@ -240,7 +233,7 @@ void __init MMU_init_hw(void) | |||
240 | */ | 233 | */ |
241 | if ( ppc_md.progress ) ppc_md.progress("hash:find piece", 0x322); | 234 | if ( ppc_md.progress ) ppc_md.progress("hash:find piece", 0x322); |
242 | Hash = __va(lmb_alloc_base(Hash_size, Hash_size, | 235 | Hash = __va(lmb_alloc_base(Hash_size, Hash_size, |
243 | __initial_memory_limit)); | 236 | __initial_memory_limit_addr)); |
244 | cacheable_memzero(Hash, Hash_size); | 237 | cacheable_memzero(Hash, Hash_size); |
245 | _SDR1 = __pa(Hash) | SDR1_LOW_BITS; | 238 | _SDR1 = __pa(Hash) | SDR1_LOW_BITS; |
246 | 239 | ||
diff --git a/arch/powerpc/mm/stab.c b/arch/powerpc/mm/stab.c index 50448d5de9d2..efbbd13d93e5 100644 --- a/arch/powerpc/mm/stab.c +++ b/arch/powerpc/mm/stab.c | |||
@@ -12,12 +12,14 @@ | |||
12 | * 2 of the License, or (at your option) any later version. | 12 | * 2 of the License, or (at your option) any later version. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <linux/lmb.h> | ||
16 | |||
15 | #include <asm/pgtable.h> | 17 | #include <asm/pgtable.h> |
16 | #include <asm/mmu.h> | 18 | #include <asm/mmu.h> |
17 | #include <asm/mmu_context.h> | 19 | #include <asm/mmu_context.h> |
18 | #include <asm/paca.h> | 20 | #include <asm/paca.h> |
19 | #include <asm/cputable.h> | 21 | #include <asm/cputable.h> |
20 | #include <asm/lmb.h> | 22 | #include <asm/prom.h> |
21 | #include <asm/abs_addr.h> | 23 | #include <asm/abs_addr.h> |
22 | #include <asm/firmware.h> | 24 | #include <asm/firmware.h> |
23 | #include <asm/iseries/hv_call.h> | 25 | #include <asm/iseries/hv_call.h> |