Commit 83db0384 authored by Jiang Liu's avatar Jiang Liu Committed by Linus Torvalds

mm/ARM: use common help functions to free reserved pages

Use common help functions to free reserved pages.
Signed-off-by: default avatarJiang Liu <jiang.liu@huawei.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f3beeb4a
...@@ -427,24 +427,6 @@ void __init bootmem_init(void) ...@@ -427,24 +427,6 @@ void __init bootmem_init(void)
max_pfn = max_high - PHYS_PFN_OFFSET; max_pfn = max_high - PHYS_PFN_OFFSET;
} }
static inline int free_area(unsigned long pfn, unsigned long end, char *s)
{
unsigned int pages = 0, size = (end - pfn) << (PAGE_SHIFT - 10);
for (; pfn < end; pfn++) {
struct page *page = pfn_to_page(pfn);
ClearPageReserved(page);
init_page_count(page);
__free_page(page);
pages++;
}
if (size && s)
printk(KERN_INFO "Freeing %s memory: %dK\n", s, size);
return pages;
}
/* /*
* Poison init memory with an undefined instruction (ARM) or a branch to an * Poison init memory with an undefined instruction (ARM) or a branch to an
* undefined instruction (Thumb). * undefined instruction (Thumb).
...@@ -537,6 +519,16 @@ static void __init free_unused_memmap(struct meminfo *mi) ...@@ -537,6 +519,16 @@ static void __init free_unused_memmap(struct meminfo *mi)
#endif #endif
} }
#ifdef CONFIG_HIGHMEM
static inline void free_area_high(unsigned long pfn, unsigned long end)
{
for (; pfn < end; pfn++) {
__free_reserved_page(pfn_to_page(pfn));
totalhigh_pages++;
}
}
#endif
static void __init free_highpages(void) static void __init free_highpages(void)
{ {
#ifdef CONFIG_HIGHMEM #ifdef CONFIG_HIGHMEM
...@@ -572,8 +564,7 @@ static void __init free_highpages(void) ...@@ -572,8 +564,7 @@ static void __init free_highpages(void)
if (res_end > end) if (res_end > end)
res_end = end; res_end = end;
if (res_start != start) if (res_start != start)
totalhigh_pages += free_area(start, res_start, free_area_high(start, res_start);
NULL);
start = res_end; start = res_end;
if (start == end) if (start == end)
break; break;
...@@ -581,7 +572,7 @@ static void __init free_highpages(void) ...@@ -581,7 +572,7 @@ static void __init free_highpages(void)
/* And now free anything which remains */ /* And now free anything which remains */
if (start < end) if (start < end)
totalhigh_pages += free_area(start, end, NULL); free_area_high(start, end);
} }
totalram_pages += totalhigh_pages; totalram_pages += totalhigh_pages;
#endif #endif
...@@ -612,8 +603,7 @@ void __init mem_init(void) ...@@ -612,8 +603,7 @@ void __init mem_init(void)
#ifdef CONFIG_SA1111 #ifdef CONFIG_SA1111
/* now that our DMA memory is actually so designated, we can free it */ /* now that our DMA memory is actually so designated, we can free it */
totalram_pages += free_area(PHYS_PFN_OFFSET, free_reserved_area(__va(PHYS_PFN_OFFSET), swapper_pg_dir, 0, NULL);
__phys_to_pfn(__pa(swapper_pg_dir)), NULL);
#endif #endif
free_highpages(); free_highpages();
...@@ -741,16 +731,12 @@ void free_initmem(void) ...@@ -741,16 +731,12 @@ void free_initmem(void)
extern char __tcm_start, __tcm_end; extern char __tcm_start, __tcm_end;
poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start); poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)), free_reserved_area(&__tcm_start, &__tcm_end, 0, "TCM link");
__phys_to_pfn(__pa(&__tcm_end)),
"TCM link");
#endif #endif
poison_init_mem(__init_begin, __init_end - __init_begin); poison_init_mem(__init_begin, __init_end - __init_begin);
if (!machine_is_integrator() && !machine_is_cintegrator()) if (!machine_is_integrator() && !machine_is_cintegrator())
totalram_pages += free_area(__phys_to_pfn(__pa(__init_begin)), free_initmem_default(0);
__phys_to_pfn(__pa(__init_end)),
"init");
} }
#ifdef CONFIG_BLK_DEV_INITRD #ifdef CONFIG_BLK_DEV_INITRD
...@@ -761,9 +747,7 @@ void free_initrd_mem(unsigned long start, unsigned long end) ...@@ -761,9 +747,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
{ {
if (!keep_initrd) { if (!keep_initrd) {
poison_init_mem((void *)start, PAGE_ALIGN(end) - start); poison_init_mem((void *)start, PAGE_ALIGN(end) - start);
totalram_pages += free_area(__phys_to_pfn(__pa(start)), free_reserved_area(start, end, 0, "initrd");
__phys_to_pfn(__pa(end)),
"initrd");
} }
} }
......
...@@ -197,24 +197,6 @@ void __init bootmem_init(void) ...@@ -197,24 +197,6 @@ void __init bootmem_init(void)
max_pfn = max_low_pfn = max; max_pfn = max_low_pfn = max;
} }
static inline int free_area(unsigned long pfn, unsigned long end, char *s)
{
unsigned int pages = 0, size = (end - pfn) << (PAGE_SHIFT - 10);
for (; pfn < end; pfn++) {
struct page *page = pfn_to_page(pfn);
ClearPageReserved(page);
init_page_count(page);
__free_page(page);
pages++;
}
if (size && s)
pr_info("Freeing %s memory: %dK\n", s, size);
return pages;
}
/* /*
* Poison init memory with an undefined instruction (0x0). * Poison init memory with an undefined instruction (0x0).
*/ */
...@@ -405,9 +387,7 @@ void __init mem_init(void) ...@@ -405,9 +387,7 @@ void __init mem_init(void)
void free_initmem(void) void free_initmem(void)
{ {
poison_init_mem(__init_begin, __init_end - __init_begin); poison_init_mem(__init_begin, __init_end - __init_begin);
totalram_pages += free_area(__phys_to_pfn(__pa(__init_begin)), free_initmem_default(0);
__phys_to_pfn(__pa(__init_end)),
"init");
} }
#ifdef CONFIG_BLK_DEV_INITRD #ifdef CONFIG_BLK_DEV_INITRD
...@@ -418,9 +398,7 @@ void free_initrd_mem(unsigned long start, unsigned long end) ...@@ -418,9 +398,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
{ {
if (!keep_initrd) { if (!keep_initrd) {
poison_init_mem((void *)start, PAGE_ALIGN(end) - start); poison_init_mem((void *)start, PAGE_ALIGN(end) - start);
totalram_pages += free_area(__phys_to_pfn(__pa(start)), free_reserved_area(start, end, 0, "initrd");
__phys_to_pfn(__pa(end)),
"initrd");
} }
} }
......
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