diff options
Diffstat (limited to 'arch/powerpc/mm/mem.c')
-rw-r--r-- | arch/powerpc/mm/mem.c | 77 |
1 files changed, 15 insertions, 62 deletions
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 8ebaac75c940..b7285a5870f8 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/memblock.h> | 35 | #include <linux/memblock.h> |
36 | #include <linux/hugetlb.h> | 36 | #include <linux/hugetlb.h> |
37 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
38 | #include <linux/vmalloc.h> | ||
38 | 39 | ||
39 | #include <asm/pgalloc.h> | 40 | #include <asm/pgalloc.h> |
40 | #include <asm/prom.h> | 41 | #include <asm/prom.h> |
@@ -60,7 +61,6 @@ | |||
60 | #define CPU_FTR_NOEXECUTE 0 | 61 | #define CPU_FTR_NOEXECUTE 0 |
61 | #endif | 62 | #endif |
62 | 63 | ||
63 | int init_bootmem_done; | ||
64 | int mem_init_done; | 64 | int mem_init_done; |
65 | unsigned long long memory_limit; | 65 | unsigned long long memory_limit; |
66 | 66 | ||
@@ -144,8 +144,17 @@ int arch_remove_memory(u64 start, u64 size) | |||
144 | 144 | ||
145 | zone = page_zone(pfn_to_page(start_pfn)); | 145 | zone = page_zone(pfn_to_page(start_pfn)); |
146 | ret = __remove_pages(zone, start_pfn, nr_pages); | 146 | ret = __remove_pages(zone, start_pfn, nr_pages); |
147 | if (!ret && (ppc_md.remove_memory)) | 147 | if (ret) |
148 | ret = ppc_md.remove_memory(start, size); | 148 | return ret; |
149 | |||
150 | /* Remove htab bolted mappings for this section of memory */ | ||
151 | start = (unsigned long)__va(start); | ||
152 | ret = remove_section_mapping(start, start + size); | ||
153 | |||
154 | /* Ensure all vmalloc mappings are flushed in case they also | ||
155 | * hit that section of memory | ||
156 | */ | ||
157 | vm_unmap_aliases(); | ||
149 | 158 | ||
150 | return ret; | 159 | return ret; |
151 | } | 160 | } |
@@ -180,70 +189,23 @@ walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, | |||
180 | } | 189 | } |
181 | EXPORT_SYMBOL_GPL(walk_system_ram_range); | 190 | EXPORT_SYMBOL_GPL(walk_system_ram_range); |
182 | 191 | ||
183 | /* | ||
184 | * Initialize the bootmem system and give it all the memory we | ||
185 | * have available. If we are using highmem, we only put the | ||
186 | * lowmem into the bootmem system. | ||
187 | */ | ||
188 | #ifndef CONFIG_NEED_MULTIPLE_NODES | 192 | #ifndef CONFIG_NEED_MULTIPLE_NODES |
189 | void __init do_init_bootmem(void) | 193 | void __init initmem_init(void) |
190 | { | 194 | { |
191 | unsigned long start, bootmap_pages; | ||
192 | unsigned long total_pages; | ||
193 | struct memblock_region *reg; | ||
194 | int boot_mapsize; | ||
195 | |||
196 | max_low_pfn = max_pfn = memblock_end_of_DRAM() >> PAGE_SHIFT; | 195 | max_low_pfn = max_pfn = memblock_end_of_DRAM() >> PAGE_SHIFT; |
197 | total_pages = (memblock_end_of_DRAM() - memstart_addr) >> PAGE_SHIFT; | 196 | min_low_pfn = MEMORY_START >> PAGE_SHIFT; |
198 | #ifdef CONFIG_HIGHMEM | 197 | #ifdef CONFIG_HIGHMEM |
199 | total_pages = total_lowmem >> PAGE_SHIFT; | ||
200 | max_low_pfn = lowmem_end_addr >> PAGE_SHIFT; | 198 | max_low_pfn = lowmem_end_addr >> PAGE_SHIFT; |
201 | #endif | 199 | #endif |
202 | 200 | ||
203 | /* | ||
204 | * Find an area to use for the bootmem bitmap. Calculate the size of | ||
205 | * bitmap required as (Total Memory) / PAGE_SIZE / BITS_PER_BYTE. | ||
206 | * Add 1 additional page in case the address isn't page-aligned. | ||
207 | */ | ||
208 | bootmap_pages = bootmem_bootmap_pages(total_pages); | ||
209 | |||
210 | start = memblock_alloc(bootmap_pages << PAGE_SHIFT, PAGE_SIZE); | ||
211 | |||
212 | min_low_pfn = MEMORY_START >> PAGE_SHIFT; | ||
213 | boot_mapsize = init_bootmem_node(NODE_DATA(0), start >> PAGE_SHIFT, min_low_pfn, max_low_pfn); | ||
214 | |||
215 | /* Place all memblock_regions in the same node and merge contiguous | 201 | /* Place all memblock_regions in the same node and merge contiguous |
216 | * memblock_regions | 202 | * memblock_regions |
217 | */ | 203 | */ |
218 | memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0); | 204 | memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0); |
219 | 205 | ||
220 | /* Add all physical memory to the bootmem map, mark each area | ||
221 | * present. | ||
222 | */ | ||
223 | #ifdef CONFIG_HIGHMEM | ||
224 | free_bootmem_with_active_regions(0, lowmem_end_addr >> PAGE_SHIFT); | ||
225 | |||
226 | /* reserve the sections we're already using */ | ||
227 | for_each_memblock(reserved, reg) { | ||
228 | unsigned long top = reg->base + reg->size - 1; | ||
229 | if (top < lowmem_end_addr) | ||
230 | reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT); | ||
231 | else if (reg->base < lowmem_end_addr) { | ||
232 | unsigned long trunc_size = lowmem_end_addr - reg->base; | ||
233 | reserve_bootmem(reg->base, trunc_size, BOOTMEM_DEFAULT); | ||
234 | } | ||
235 | } | ||
236 | #else | ||
237 | free_bootmem_with_active_regions(0, max_pfn); | ||
238 | |||
239 | /* reserve the sections we're already using */ | ||
240 | for_each_memblock(reserved, reg) | ||
241 | reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT); | ||
242 | #endif | ||
243 | /* XXX need to clip this if using highmem? */ | 206 | /* XXX need to clip this if using highmem? */ |
244 | sparse_memory_present_with_active_regions(0); | 207 | sparse_memory_present_with_active_regions(0); |
245 | 208 | sparse_init(); | |
246 | init_bootmem_done = 1; | ||
247 | } | 209 | } |
248 | 210 | ||
249 | /* mark pages that don't exist as nosave */ | 211 | /* mark pages that don't exist as nosave */ |
@@ -359,14 +321,6 @@ void __init paging_init(void) | |||
359 | mark_nonram_nosave(); | 321 | mark_nonram_nosave(); |
360 | } | 322 | } |
361 | 323 | ||
362 | static void __init register_page_bootmem_info(void) | ||
363 | { | ||
364 | int i; | ||
365 | |||
366 | for_each_online_node(i) | ||
367 | register_page_bootmem_info_node(NODE_DATA(i)); | ||
368 | } | ||
369 | |||
370 | void __init mem_init(void) | 324 | void __init mem_init(void) |
371 | { | 325 | { |
372 | /* | 326 | /* |
@@ -379,7 +333,6 @@ void __init mem_init(void) | |||
379 | swiotlb_init(0); | 333 | swiotlb_init(0); |
380 | #endif | 334 | #endif |
381 | 335 | ||
382 | register_page_bootmem_info(); | ||
383 | high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); | 336 | high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); |
384 | set_max_mapnr(max_pfn); | 337 | set_max_mapnr(max_pfn); |
385 | free_all_bootmem(); | 338 | free_all_bootmem(); |