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)
}
#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));
}
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