diff options
author | Matt Fleming <matt@console-pimps.org> | 2009-07-03 03:16:54 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-07-03 03:16:54 -0400 |
commit | c601a51af10f714292f42eab45fa8c9154dc1414 (patch) | |
tree | 3b3aeba10f7883578ac8dfd765804594eea8e9f1 /arch/sh | |
parent | 47220f623c3216ca276bad517ed208ea2ffceaa2 (diff) |
sh: Use bootmem ontop of lmb
Rework the bootmem allocator to use the lmb framework.
Signed-off-by: Matt Fleming <matt@console-pimps.org>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh')
-rw-r--r-- | arch/sh/Kconfig | 1 | ||||
-rw-r--r-- | arch/sh/include/asm/lmb.h | 6 | ||||
-rw-r--r-- | arch/sh/kernel/setup.c | 71 |
3 files changed, 59 insertions, 19 deletions
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index e2bdd7b94fd9..0fb99b0eac5b 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig | |||
@@ -10,6 +10,7 @@ config SUPERH | |||
10 | select EMBEDDED | 10 | select EMBEDDED |
11 | select HAVE_CLK | 11 | select HAVE_CLK |
12 | select HAVE_IDE | 12 | select HAVE_IDE |
13 | select HAVE_LMB | ||
13 | select HAVE_OPROFILE | 14 | select HAVE_OPROFILE |
14 | select HAVE_GENERIC_DMA_COHERENT | 15 | select HAVE_GENERIC_DMA_COHERENT |
15 | select HAVE_IOREMAP_PROT if MMU | 16 | select HAVE_IOREMAP_PROT if MMU |
diff --git a/arch/sh/include/asm/lmb.h b/arch/sh/include/asm/lmb.h new file mode 100644 index 000000000000..9b437f657ffa --- /dev/null +++ b/arch/sh/include/asm/lmb.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __ASM_SH_LMB_H | ||
2 | #define __ASM_SH_LMB_H | ||
3 | |||
4 | #define LMB_REAL_LIMIT 0 | ||
5 | |||
6 | #endif /* __ASM_SH_LMB_H */ | ||
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index dd38338553ef..ceb409bf7741 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/clk.h> | 30 | #include <linux/clk.h> |
31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
32 | #include <linux/platform_device.h> | 32 | #include <linux/platform_device.h> |
33 | #include <linux/lmb.h> | ||
33 | #include <asm/uaccess.h> | 34 | #include <asm/uaccess.h> |
34 | #include <asm/io.h> | 35 | #include <asm/io.h> |
35 | #include <asm/page.h> | 36 | #include <asm/page.h> |
@@ -233,39 +234,45 @@ void __init __add_active_range(unsigned int nid, unsigned long start_pfn, | |||
233 | void __init setup_bootmem_allocator(unsigned long free_pfn) | 234 | void __init setup_bootmem_allocator(unsigned long free_pfn) |
234 | { | 235 | { |
235 | unsigned long bootmap_size; | 236 | unsigned long bootmap_size; |
237 | unsigned long bootmap_pages, bootmem_paddr; | ||
238 | u64 total_pages = (lmb_end_of_DRAM() - __MEMORY_START) >> PAGE_SHIFT; | ||
239 | int i; | ||
240 | |||
241 | bootmap_pages = bootmem_bootmap_pages(total_pages); | ||
242 | |||
243 | bootmem_paddr = lmb_alloc(bootmap_pages << PAGE_SHIFT, PAGE_SIZE); | ||
236 | 244 | ||
237 | /* | 245 | /* |
238 | * Find a proper area for the bootmem bitmap. After this | 246 | * Find a proper area for the bootmem bitmap. After this |
239 | * bootstrap step all allocations (until the page allocator | 247 | * bootstrap step all allocations (until the page allocator |
240 | * is intact) must be done via bootmem_alloc(). | 248 | * is intact) must be done via bootmem_alloc(). |
241 | */ | 249 | */ |
242 | bootmap_size = init_bootmem_node(NODE_DATA(0), free_pfn, | 250 | bootmap_size = init_bootmem_node(NODE_DATA(0), |
251 | bootmem_paddr >> PAGE_SHIFT, | ||
243 | min_low_pfn, max_low_pfn); | 252 | min_low_pfn, max_low_pfn); |
244 | 253 | ||
245 | __add_active_range(0, min_low_pfn, max_low_pfn); | 254 | /* Add active regions with valid PFNs. */ |
246 | register_bootmem_low_pages(); | 255 | for (i = 0; i < lmb.memory.cnt; i++) { |
247 | 256 | unsigned long start_pfn, end_pfn; | |
248 | node_set_online(0); | 257 | start_pfn = lmb.memory.region[i].base >> PAGE_SHIFT; |
258 | end_pfn = start_pfn + lmb_size_pages(&lmb.memory, i); | ||
259 | __add_active_range(0, start_pfn, end_pfn); | ||
260 | } | ||
249 | 261 | ||
250 | /* | 262 | /* |
251 | * Reserve the kernel text and | 263 | * Add all physical memory to the bootmem map and mark each |
252 | * Reserve the bootmem bitmap. We do this in two steps (first step | 264 | * area as present. |
253 | * was init_bootmem()), because this catches the (definitely buggy) | ||
254 | * case of us accidentally initializing the bootmem allocator with | ||
255 | * an invalid RAM area. | ||
256 | */ | 265 | */ |
257 | reserve_bootmem(__MEMORY_START + CONFIG_ZERO_PAGE_OFFSET, | 266 | register_bootmem_low_pages(); |
258 | (PFN_PHYS(free_pfn) + bootmap_size + PAGE_SIZE - 1) - | ||
259 | (__MEMORY_START + CONFIG_ZERO_PAGE_OFFSET), | ||
260 | BOOTMEM_DEFAULT); | ||
261 | 267 | ||
262 | /* | 268 | /* Reserve the sections we're already using. */ |
263 | * Reserve physical pages below CONFIG_ZERO_PAGE_OFFSET. | 269 | for (i = 0; i < lmb.reserved.cnt; i++) |
264 | */ | 270 | reserve_bootmem(lmb.reserved.region[i].base, |
265 | if (CONFIG_ZERO_PAGE_OFFSET != 0) | 271 | lmb_size_bytes(&lmb.reserved, i), |
266 | reserve_bootmem(__MEMORY_START, CONFIG_ZERO_PAGE_OFFSET, | ||
267 | BOOTMEM_DEFAULT); | 272 | BOOTMEM_DEFAULT); |
268 | 273 | ||
274 | node_set_online(0); | ||
275 | |||
269 | sparse_memory_present_with_active_regions(0); | 276 | sparse_memory_present_with_active_regions(0); |
270 | 277 | ||
271 | #ifdef CONFIG_BLK_DEV_INITRD | 278 | #ifdef CONFIG_BLK_DEV_INITRD |
@@ -296,12 +303,37 @@ void __init setup_bootmem_allocator(unsigned long free_pfn) | |||
296 | static void __init setup_memory(void) | 303 | static void __init setup_memory(void) |
297 | { | 304 | { |
298 | unsigned long start_pfn; | 305 | unsigned long start_pfn; |
306 | u64 base = min_low_pfn << PAGE_SHIFT; | ||
307 | u64 size = (max_low_pfn << PAGE_SHIFT) - base; | ||
299 | 308 | ||
300 | /* | 309 | /* |
301 | * Partially used pages are not usable - thus | 310 | * Partially used pages are not usable - thus |
302 | * we are rounding upwards: | 311 | * we are rounding upwards: |
303 | */ | 312 | */ |
304 | start_pfn = PFN_UP(__pa(_end)); | 313 | start_pfn = PFN_UP(__pa(_end)); |
314 | |||
315 | lmb_add(base, size); | ||
316 | |||
317 | /* | ||
318 | * Reserve the kernel text and | ||
319 | * Reserve the bootmem bitmap. We do this in two steps (first step | ||
320 | * was init_bootmem()), because this catches the (definitely buggy) | ||
321 | * case of us accidentally initializing the bootmem allocator with | ||
322 | * an invalid RAM area. | ||
323 | */ | ||
324 | lmb_reserve(__MEMORY_START + CONFIG_ZERO_PAGE_OFFSET, | ||
325 | (PFN_PHYS(start_pfn) + PAGE_SIZE - 1) - | ||
326 | (__MEMORY_START + CONFIG_ZERO_PAGE_OFFSET)); | ||
327 | |||
328 | /* | ||
329 | * Reserve physical pages below CONFIG_ZERO_PAGE_OFFSET. | ||
330 | */ | ||
331 | if (CONFIG_ZERO_PAGE_OFFSET != 0) | ||
332 | lmb_reserve(__MEMORY_START, CONFIG_ZERO_PAGE_OFFSET); | ||
333 | |||
334 | lmb_analyze(); | ||
335 | lmb_dump_all(); | ||
336 | |||
305 | setup_bootmem_allocator(start_pfn); | 337 | setup_bootmem_allocator(start_pfn); |
306 | } | 338 | } |
307 | #else | 339 | #else |
@@ -402,6 +434,7 @@ void __init setup_arch(char **cmdline_p) | |||
402 | nodes_clear(node_online_map); | 434 | nodes_clear(node_online_map); |
403 | 435 | ||
404 | /* Setup bootmem with available RAM */ | 436 | /* Setup bootmem with available RAM */ |
437 | lmb_init(); | ||
405 | setup_memory(); | 438 | setup_memory(); |
406 | sparse_init(); | 439 | sparse_init(); |
407 | 440 | ||