aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/mm
diff options
context:
space:
mode:
authorJiang Liu <liuj97@gmail.com>2013-04-29 18:06:43 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 18:54:30 -0400
commit31605922613dfc59402cd6f3a1b019bc2138ff47 (patch)
tree275da534acbd774675b52debe39c34e82154b24e /arch/mips/mm
parent7beb5987875bd633c0e10162fbdd4e35d266a9e1 (diff)
mm/MIPS: use common help functions to free reserved pages
Use common help functions to free reserved pages. Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Cc: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/mips/mm')
-rw-r--r--arch/mips/mm/init.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 67929251286c..60f7c6122d6e 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -77,10 +77,9 @@ EXPORT_SYMBOL_GPL(empty_zero_page);
77/* 77/*
78 * Not static inline because used by IP27 special magic initialization code 78 * Not static inline because used by IP27 special magic initialization code
79 */ 79 */
80unsigned long setup_zero_pages(void) 80void setup_zero_pages(void)
81{ 81{
82 unsigned int order; 82 unsigned int order, i;
83 unsigned long size;
84 struct page *page; 83 struct page *page;
85 84
86 if (cpu_has_vce) 85 if (cpu_has_vce)
@@ -94,15 +93,10 @@ unsigned long setup_zero_pages(void)
94 93
95 page = virt_to_page((void *)empty_zero_page); 94 page = virt_to_page((void *)empty_zero_page);
96 split_page(page, order); 95 split_page(page, order);
97 while (page < virt_to_page((void *)(empty_zero_page + (PAGE_SIZE << order)))) { 96 for (i = 0; i < (1 << order); i++, page++)
98 SetPageReserved(page); 97 mark_page_reserved(page);
99 page++;
100 }
101
102 size = PAGE_SIZE << order;
103 zero_page_mask = (size - 1) & PAGE_MASK;
104 98
105 return 1UL << order; 99 zero_page_mask = ((PAGE_SIZE << order) - 1) & PAGE_MASK;
106} 100}
107 101
108#ifdef CONFIG_MIPS_MT_SMTC 102#ifdef CONFIG_MIPS_MT_SMTC
@@ -380,7 +374,7 @@ void __init mem_init(void)
380 high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT); 374 high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
381 375
382 totalram_pages += free_all_bootmem(); 376 totalram_pages += free_all_bootmem();
383 totalram_pages -= setup_zero_pages(); /* Setup zeroed pages. */ 377 setup_zero_pages(); /* Setup zeroed pages. */
384 378
385 reservedpages = ram = 0; 379 reservedpages = ram = 0;
386 for (tmp = 0; tmp < max_low_pfn; tmp++) 380 for (tmp = 0; tmp < max_low_pfn; tmp++)
@@ -440,11 +434,8 @@ void free_init_pages(const char *what, unsigned long begin, unsigned long end)
440 struct page *page = pfn_to_page(pfn); 434 struct page *page = pfn_to_page(pfn);
441 void *addr = phys_to_virt(PFN_PHYS(pfn)); 435 void *addr = phys_to_virt(PFN_PHYS(pfn));
442 436
443 ClearPageReserved(page);
444 init_page_count(page);
445 memset(addr, POISON_FREE_INITMEM, PAGE_SIZE); 437 memset(addr, POISON_FREE_INITMEM, PAGE_SIZE);
446 __free_page(page); 438 free_reserved_page(page);
447 totalram_pages++;
448 } 439 }
449 printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10); 440 printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
450} 441}
@@ -452,18 +443,14 @@ void free_init_pages(const char *what, unsigned long begin, unsigned long end)
452#ifdef CONFIG_BLK_DEV_INITRD 443#ifdef CONFIG_BLK_DEV_INITRD
453void free_initrd_mem(unsigned long start, unsigned long end) 444void free_initrd_mem(unsigned long start, unsigned long end)
454{ 445{
455 free_init_pages("initrd memory", 446 free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd");
456 virt_to_phys((void *)start),
457 virt_to_phys((void *)end));
458} 447}
459#endif 448#endif
460 449
461void __init_refok free_initmem(void) 450void __init_refok free_initmem(void)
462{ 451{
463 prom_free_prom_memory(); 452 prom_free_prom_memory();
464 free_init_pages("unused kernel memory", 453 free_initmem_default(POISON_FREE_INITMEM);
465 __pa_symbol(&__init_begin),
466 __pa_symbol(&__init_end));
467} 454}
468 455
469#ifndef CONFIG_MIPS_PGD_C0_CONTEXT 456#ifndef CONFIG_MIPS_PGD_C0_CONTEXT