]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm/MIPS: use common help functions to free reserved pages
authorJiang Liu <liuj97@gmail.com>
Wed, 20 Mar 2013 04:07:13 +0000 (15:07 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 21 Mar 2013 05:28:28 +0000 (16:28 +1100)
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>
arch/mips/mm/init.c
arch/mips/sgi-ip27/ip27-memory.c

index 67929251286c983597492db0cb5ca08ceb944ee0..60f7c6122d6e00eeae2053a8a86d4f954b88a099 100644 (file)
@@ -77,10 +77,9 @@ EXPORT_SYMBOL_GPL(empty_zero_page);
 /*
  * Not static inline because used by IP27 special magic initialization code
  */
-unsigned long setup_zero_pages(void)
+void setup_zero_pages(void)
 {
-       unsigned int order;
-       unsigned long size;
+       unsigned int order, i;
        struct page *page;
 
        if (cpu_has_vce)
@@ -94,15 +93,10 @@ unsigned long setup_zero_pages(void)
 
        page = virt_to_page((void *)empty_zero_page);
        split_page(page, order);
-       while (page < virt_to_page((void *)(empty_zero_page + (PAGE_SIZE << order)))) {
-               SetPageReserved(page);
-               page++;
-       }
-
-       size = PAGE_SIZE << order;
-       zero_page_mask = (size - 1) & PAGE_MASK;
+       for (i = 0; i < (1 << order); i++, page++)
+               mark_page_reserved(page);
 
-       return 1UL << order;
+       zero_page_mask = ((PAGE_SIZE << order) - 1) & PAGE_MASK;
 }
 
 #ifdef CONFIG_MIPS_MT_SMTC
@@ -380,7 +374,7 @@ void __init mem_init(void)
        high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
 
        totalram_pages += free_all_bootmem();
-       totalram_pages -= setup_zero_pages();   /* Setup zeroed pages.  */
+       setup_zero_pages();     /* Setup zeroed pages.  */
 
        reservedpages = ram = 0;
        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)
                struct page *page = pfn_to_page(pfn);
                void *addr = phys_to_virt(PFN_PHYS(pfn));
 
-               ClearPageReserved(page);
-               init_page_count(page);
                memset(addr, POISON_FREE_INITMEM, PAGE_SIZE);
-               __free_page(page);
-               totalram_pages++;
+               free_reserved_page(page);
        }
        printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
 }
@@ -452,18 +443,14 @@ void free_init_pages(const char *what, unsigned long begin, unsigned long end)
 #ifdef CONFIG_BLK_DEV_INITRD
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
-       free_init_pages("initrd memory",
-                       virt_to_phys((void *)start),
-                       virt_to_phys((void *)end));
+       free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd");
 }
 #endif
 
 void __init_refok free_initmem(void)
 {
        prom_free_prom_memory();
-       free_init_pages("unused kernel memory",
-                       __pa_symbol(&__init_begin),
-                       __pa_symbol(&__init_end));
+       free_initmem_default(POISON_FREE_INITMEM);
 }
 
 #ifndef CONFIG_MIPS_PGD_C0_CONTEXT
index 3505d08ff2fdd8297848f823b068466331bf9b0a..5f2bddb1860e11c1b32035593b3376b758c37570 100644 (file)
@@ -457,7 +457,7 @@ void __init prom_free_prom_memory(void)
        /* We got nothing to free here ...  */
 }
 
-extern unsigned long setup_zero_pages(void);
+extern void setup_zero_pages(void);
 
 void __init paging_init(void)
 {
@@ -492,7 +492,7 @@ void __init mem_init(void)
                totalram_pages += free_all_bootmem_node(NODE_DATA(node));
        }
 
-       totalram_pages -= setup_zero_pages();   /* This comes from node 0 */
+       setup_zero_pages();     /* This comes from node 0 */
 
        codesize =  (unsigned long) &_etext - (unsigned long) &_text;
        datasize =  (unsigned long) &_edata - (unsigned long) &_etext;