]> err.no Git - linux-2.6/commitdiff
[MIPS] Make free_init_pages() arguments to be physical addresses
authorFranck Bui-Huu <vagabon.xyz@gmail.com>
Thu, 19 Oct 2006 11:20:05 +0000 (13:20 +0200)
committerRalf Baechle <ralf@linux-mips.org>
Thu, 30 Nov 2006 01:14:42 +0000 (01:14 +0000)
It allows caller of this function to not care about CKSEG0/XKPHYS
address mixes. It's now automatically done by free_init_pages().

We can now safely remove hack needed by 64 bit kernels with
CONFIG_BUILD_ELF64=n in free_initmem().

Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/mm/init.c

index 4076963c601e20cd629a7c4fceb53e063b1bbb74..9e29ba9205f0c187925edd51214849f4567d89f5 100644 (file)
@@ -443,15 +443,18 @@ void __init mem_init(void)
 }
 #endif /* !CONFIG_NEED_MULTIPLE_NODES */
 
-void free_init_pages(char *what, unsigned long begin, unsigned long end)
+static void free_init_pages(char *what, unsigned long begin, unsigned long end)
 {
-       unsigned long addr;
+       unsigned long pfn;
 
-       for (addr = begin; addr < end; addr += PAGE_SIZE) {
-               ClearPageReserved(virt_to_page((void *)addr));
-               init_page_count(virt_to_page((void *)addr));
-               memset((void *)addr, 0xcc, PAGE_SIZE);
-               free_page(addr);
+       for (pfn = PFN_UP(begin); pfn < PFN_DOWN(end); pfn++) {
+               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++;
        }
        printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
@@ -460,7 +463,9 @@ void free_init_pages(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", start, end);
+       free_init_pages("initrd memory",
+                       virt_to_phys((void *)start),
+                       virt_to_phys((void *)end));
 }
 #endif
 
@@ -468,17 +473,13 @@ extern unsigned long prom_free_prom_memory(void);
 
 void free_initmem(void)
 {
-       unsigned long start, end, freed;
+       unsigned long freed;
 
        freed = prom_free_prom_memory();
        if (freed)
                printk(KERN_INFO "Freeing firmware memory: %ldk freed\n",freed);
 
-       start = (unsigned long)(&__init_begin);
-       end = (unsigned long)(&__init_end);
-#ifdef CONFIG_64BIT
-       start = PAGE_OFFSET | CPHYSADDR(start);
-       end = PAGE_OFFSET | CPHYSADDR(end);
-#endif
-       free_init_pages("unused kernel memory", start, end);
+       free_init_pages("unused kernel memory",
+                       __pa_symbol(&__init_begin),
+                       __pa_symbol(&__init_end));
 }