Commit acd86b86 authored by Franck Bui-Huu's avatar Franck Bui-Huu Committed by Ralf Baechle

[MIPS] Make free_init_pages() arguments to be physical addresses

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: default avatarFranck Bui-Huu <fbuihuu@gmail.com>
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent a7837b76
...@@ -443,15 +443,18 @@ void __init mem_init(void) ...@@ -443,15 +443,18 @@ void __init mem_init(void)
} }
#endif /* !CONFIG_NEED_MULTIPLE_NODES */ #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) { for (pfn = PFN_UP(begin); pfn < PFN_DOWN(end); pfn++) {
ClearPageReserved(virt_to_page((void *)addr)); struct page *page = pfn_to_page(pfn);
init_page_count(virt_to_page((void *)addr)); void *addr = phys_to_virt(PFN_PHYS(pfn));
memset((void *)addr, 0xcc, PAGE_SIZE);
free_page(addr); ClearPageReserved(page);
init_page_count(page);
memset(addr, POISON_FREE_INITMEM, PAGE_SIZE);
__free_page(page);
totalram_pages++; totalram_pages++;
} }
printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10); 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) ...@@ -460,7 +463,9 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
#ifdef CONFIG_BLK_DEV_INITRD #ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end) 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 #endif
...@@ -468,17 +473,13 @@ extern unsigned long prom_free_prom_memory(void); ...@@ -468,17 +473,13 @@ extern unsigned long prom_free_prom_memory(void);
void free_initmem(void) void free_initmem(void)
{ {
unsigned long start, end, freed; unsigned long freed;
freed = prom_free_prom_memory(); freed = prom_free_prom_memory();
if (freed) if (freed)
printk(KERN_INFO "Freeing firmware memory: %ldk freed\n",freed); printk(KERN_INFO "Freeing firmware memory: %ldk freed\n",freed);
start = (unsigned long)(&__init_begin); free_init_pages("unused kernel memory",
end = (unsigned long)(&__init_end); __pa_symbol(&__init_begin),
#ifdef CONFIG_64BIT __pa_symbol(&__init_end));
start = PAGE_OFFSET | CPHYSADDR(start);
end = PAGE_OFFSET | CPHYSADDR(end);
#endif
free_init_pages("unused kernel memory", start, end);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment