diff options
author | Jiang Liu <liuj97@gmail.com> | 2013-07-03 18:04:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-03 19:07:36 -0400 |
commit | 1132137e87898d0b6786d85a99de35ce196ecbfb (patch) | |
tree | e601ac94250ca358ea397832fd1f425d3d2bf1bc | |
parent | 6879ea83c6d14e4f21bf48b5780ed549197c668b (diff) |
mm/MIPS: prepare for removing num_physpages and simplify mem_init()
Prepare for removing num_physpages and simplify mem_init().
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: David Daney <david.daney@cavium.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: John Crispin <blogic@openwrt.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/mips/mm/init.c | 57 | ||||
-rw-r--r-- | arch/mips/pci/pci-lantiq.c | 2 | ||||
-rw-r--r-- | arch/mips/sgi-ip27/ip27-memory.c | 21 |
3 files changed, 21 insertions, 59 deletions
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index e7333f15b1b7..4e73f10a7519 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c | |||
@@ -359,11 +359,24 @@ void __init paging_init(void) | |||
359 | static struct kcore_list kcore_kseg0; | 359 | static struct kcore_list kcore_kseg0; |
360 | #endif | 360 | #endif |
361 | 361 | ||
362 | void __init mem_init(void) | 362 | static inline void mem_init_free_highmem(void) |
363 | { | 363 | { |
364 | unsigned long codesize, reservedpages, datasize, initsize; | 364 | #ifdef CONFIG_HIGHMEM |
365 | unsigned long tmp, ram; | 365 | unsigned long tmp; |
366 | 366 | ||
367 | for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) { | ||
368 | struct page *page = pfn_to_page(tmp); | ||
369 | |||
370 | if (!page_is_ram(tmp)) | ||
371 | SetPageReserved(page); | ||
372 | else | ||
373 | free_highmem_page(page); | ||
374 | } | ||
375 | #endif | ||
376 | } | ||
377 | |||
378 | void __init mem_init(void) | ||
379 | { | ||
367 | #ifdef CONFIG_HIGHMEM | 380 | #ifdef CONFIG_HIGHMEM |
368 | #ifdef CONFIG_DISCONTIGMEM | 381 | #ifdef CONFIG_DISCONTIGMEM |
369 | #error "CONFIG_HIGHMEM and CONFIG_DISCONTIGMEM dont work together yet" | 382 | #error "CONFIG_HIGHMEM and CONFIG_DISCONTIGMEM dont work together yet" |
@@ -376,32 +389,8 @@ void __init mem_init(void) | |||
376 | 389 | ||
377 | free_all_bootmem(); | 390 | free_all_bootmem(); |
378 | setup_zero_pages(); /* Setup zeroed pages. */ | 391 | setup_zero_pages(); /* Setup zeroed pages. */ |
379 | 392 | mem_init_free_highmem(); | |
380 | reservedpages = ram = 0; | 393 | mem_init_print_info(NULL); |
381 | for (tmp = 0; tmp < max_low_pfn; tmp++) | ||
382 | if (page_is_ram(tmp) && pfn_valid(tmp)) { | ||
383 | ram++; | ||
384 | if (PageReserved(pfn_to_page(tmp))) | ||
385 | reservedpages++; | ||
386 | } | ||
387 | num_physpages = ram; | ||
388 | |||
389 | #ifdef CONFIG_HIGHMEM | ||
390 | for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) { | ||
391 | struct page *page = pfn_to_page(tmp); | ||
392 | |||
393 | if (!page_is_ram(tmp)) { | ||
394 | SetPageReserved(page); | ||
395 | continue; | ||
396 | } | ||
397 | free_highmem_page(page); | ||
398 | } | ||
399 | num_physpages += totalhigh_pages; | ||
400 | #endif | ||
401 | |||
402 | codesize = (unsigned long) &_etext - (unsigned long) &_text; | ||
403 | datasize = (unsigned long) &_edata - (unsigned long) &_etext; | ||
404 | initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin; | ||
405 | 394 | ||
406 | #ifdef CONFIG_64BIT | 395 | #ifdef CONFIG_64BIT |
407 | if ((unsigned long) &_text > (unsigned long) CKSEG0) | 396 | if ((unsigned long) &_text > (unsigned long) CKSEG0) |
@@ -410,16 +399,6 @@ void __init mem_init(void) | |||
410 | kclist_add(&kcore_kseg0, (void *) CKSEG0, | 399 | kclist_add(&kcore_kseg0, (void *) CKSEG0, |
411 | 0x80000000 - 4, KCORE_TEXT); | 400 | 0x80000000 - 4, KCORE_TEXT); |
412 | #endif | 401 | #endif |
413 | |||
414 | printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, " | ||
415 | "%ldk reserved, %ldk data, %ldk init, %ldk highmem)\n", | ||
416 | nr_free_pages() << (PAGE_SHIFT-10), | ||
417 | ram << (PAGE_SHIFT-10), | ||
418 | codesize >> 10, | ||
419 | reservedpages << (PAGE_SHIFT-10), | ||
420 | datasize >> 10, | ||
421 | initsize >> 10, | ||
422 | totalhigh_pages << (PAGE_SHIFT-10)); | ||
423 | } | 402 | } |
424 | #endif /* !CONFIG_NEED_MULTIPLE_NODES */ | 403 | #endif /* !CONFIG_NEED_MULTIPLE_NODES */ |
425 | 404 | ||
diff --git a/arch/mips/pci/pci-lantiq.c b/arch/mips/pci/pci-lantiq.c index 879077b01155..cb1ef9984069 100644 --- a/arch/mips/pci/pci-lantiq.c +++ b/arch/mips/pci/pci-lantiq.c | |||
@@ -89,7 +89,7 @@ static inline u32 ltq_calc_bar11mask(void) | |||
89 | u32 mem, bar11mask; | 89 | u32 mem, bar11mask; |
90 | 90 | ||
91 | /* BAR11MASK value depends on available memory on system. */ | 91 | /* BAR11MASK value depends on available memory on system. */ |
92 | mem = num_physpages * PAGE_SIZE; | 92 | mem = get_num_physpages() * PAGE_SIZE; |
93 | bar11mask = (0x0ffffff0 & ~((1 << (fls(mem) - 1)) - 1)) | 8; | 93 | bar11mask = (0x0ffffff0 & ~((1 << (fls(mem) - 1)) - 1)) | 8; |
94 | 94 | ||
95 | return bar11mask; | 95 | return bar11mask; |
diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c index aecac4a08360..a0c9e34147c2 100644 --- a/arch/mips/sgi-ip27/ip27-memory.c +++ b/arch/mips/sgi-ip27/ip27-memory.c | |||
@@ -357,8 +357,6 @@ static void __init szmem(void) | |||
357 | int slot; | 357 | int slot; |
358 | cnodeid_t node; | 358 | cnodeid_t node; |
359 | 359 | ||
360 | num_physpages = 0; | ||
361 | |||
362 | for_each_online_node(node) { | 360 | for_each_online_node(node) { |
363 | nodebytes = 0; | 361 | nodebytes = 0; |
364 | for (slot = 0; slot < MAX_MEM_SLOTS; slot++) { | 362 | for (slot = 0; slot < MAX_MEM_SLOTS; slot++) { |
@@ -381,7 +379,6 @@ static void __init szmem(void) | |||
381 | slot = MAX_MEM_SLOTS; | 379 | slot = MAX_MEM_SLOTS; |
382 | continue; | 380 | continue; |
383 | } | 381 | } |
384 | num_physpages += slot_psize; | ||
385 | memblock_add_node(PFN_PHYS(slot_getbasepfn(node, slot)), | 382 | memblock_add_node(PFN_PHYS(slot_getbasepfn(node, slot)), |
386 | PFN_PHYS(slot_psize), node); | 383 | PFN_PHYS(slot_psize), node); |
387 | } | 384 | } |
@@ -480,10 +477,9 @@ void __init paging_init(void) | |||
480 | 477 | ||
481 | void __init mem_init(void) | 478 | void __init mem_init(void) |
482 | { | 479 | { |
483 | unsigned long codesize, datasize, initsize, tmp; | ||
484 | unsigned node; | 480 | unsigned node; |
485 | 481 | ||
486 | high_memory = (void *) __va(num_physpages << PAGE_SHIFT); | 482 | high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT); |
487 | 483 | ||
488 | for_each_online_node(node) { | 484 | for_each_online_node(node) { |
489 | /* | 485 | /* |
@@ -494,18 +490,5 @@ void __init mem_init(void) | |||
494 | 490 | ||
495 | setup_zero_pages(); /* This comes from node 0 */ | 491 | setup_zero_pages(); /* This comes from node 0 */ |
496 | 492 | ||
497 | codesize = (unsigned long) &_etext - (unsigned long) &_text; | 493 | mem_init_print_info(NULL); |
498 | datasize = (unsigned long) &_edata - (unsigned long) &_etext; | ||
499 | initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin; | ||
500 | |||
501 | tmp = nr_free_pages(); | ||
502 | printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, " | ||
503 | "%ldk reserved, %ldk data, %ldk init, %ldk highmem)\n", | ||
504 | tmp << (PAGE_SHIFT-10), | ||
505 | num_physpages << (PAGE_SHIFT-10), | ||
506 | codesize >> 10, | ||
507 | (num_physpages - tmp) << (PAGE_SHIFT-10), | ||
508 | datasize >> 10, | ||
509 | initsize >> 10, | ||
510 | totalhigh_pages << (PAGE_SHIFT-10)); | ||
511 | } | 494 | } |