aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiang Liu <liuj97@gmail.com>2013-04-29 18:06:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 18:54:30 -0400
commit5d585e5c4840381112011aa257c7a94b2b66f9de (patch)
tree422355e70292d7bba3a0246365bcf03ef19ef2f5
parentd3e5351b8562ac72f0bd639f778098793f80ffa8 (diff)
mm/ppc: use common help functions to free reserved pages
Use common help functions to free reserved pages. Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Anatolij Gustschin <agust@denx.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/powerpc/kernel/crash_dump.c5
-rw-r--r--arch/powerpc/kernel/fadump.c5
-rw-r--r--arch/powerpc/kernel/kvm.c7
-rw-r--r--arch/powerpc/mm/mem.c29
-rw-r--r--arch/powerpc/platforms/512x/mpc512x_shared.c5
5 files changed, 6 insertions, 45 deletions
diff --git a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c
index b3ba5163eae2..9ec3fe174cba 100644
--- a/arch/powerpc/kernel/crash_dump.c
+++ b/arch/powerpc/kernel/crash_dump.c
@@ -150,10 +150,7 @@ void crash_free_reserved_phys_range(unsigned long begin, unsigned long end)
150 if (addr <= rtas_end && ((addr + PAGE_SIZE) > rtas_start)) 150 if (addr <= rtas_end && ((addr + PAGE_SIZE) > rtas_start))
151 continue; 151 continue;
152 152
153 ClearPageReserved(pfn_to_page(addr >> PAGE_SHIFT)); 153 free_reserved_page(pfn_to_page(addr >> PAGE_SHIFT));
154 init_page_count(pfn_to_page(addr >> PAGE_SHIFT));
155 free_page((unsigned long)__va(addr));
156 totalram_pages++;
157 } 154 }
158} 155}
159#endif 156#endif
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index 06c8202a69cf..2230fd0ca3e4 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -1045,10 +1045,7 @@ static void fadump_release_memory(unsigned long begin, unsigned long end)
1045 if (addr <= ra_end && ((addr + PAGE_SIZE) > ra_start)) 1045 if (addr <= ra_end && ((addr + PAGE_SIZE) > ra_start))
1046 continue; 1046 continue;
1047 1047
1048 ClearPageReserved(pfn_to_page(addr >> PAGE_SHIFT)); 1048 free_reserved_page(pfn_to_page(addr >> PAGE_SHIFT));
1049 init_page_count(pfn_to_page(addr >> PAGE_SHIFT));
1050 free_page((unsigned long)__va(addr));
1051 totalram_pages++;
1052 } 1049 }
1053} 1050}
1054 1051
diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
index a61b133c4f99..6782221d49bd 100644
--- a/arch/powerpc/kernel/kvm.c
+++ b/arch/powerpc/kernel/kvm.c
@@ -756,12 +756,7 @@ static __init void kvm_free_tmp(void)
756 end = (ulong)&kvm_tmp[ARRAY_SIZE(kvm_tmp)] & PAGE_MASK; 756 end = (ulong)&kvm_tmp[ARRAY_SIZE(kvm_tmp)] & PAGE_MASK;
757 757
758 /* Free the tmp space we don't need */ 758 /* Free the tmp space we don't need */
759 for (; start < end; start += PAGE_SIZE) { 759 free_reserved_area(start, end, 0, NULL);
760 ClearPageReserved(virt_to_page(start));
761 init_page_count(virt_to_page(start));
762 free_page(start);
763 totalram_pages++;
764 }
765} 760}
766 761
767static int __init kvm_guest_init(void) 762static int __init kvm_guest_init(void)
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index f1f7409a4183..c756713aaaba 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -405,39 +405,14 @@ void __init mem_init(void)
405 405
406void free_initmem(void) 406void free_initmem(void)
407{ 407{
408 unsigned long addr;
409
410 ppc_md.progress = ppc_printk_progress; 408 ppc_md.progress = ppc_printk_progress;
411 409 free_initmem_default(POISON_FREE_INITMEM);
412 addr = (unsigned long)__init_begin;
413 for (; addr < (unsigned long)__init_end; addr += PAGE_SIZE) {
414 memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
415 ClearPageReserved(virt_to_page(addr));
416 init_page_count(virt_to_page(addr));
417 free_page(addr);
418 totalram_pages++;
419 }
420 pr_info("Freeing unused kernel memory: %luk freed\n",
421 ((unsigned long)__init_end -
422 (unsigned long)__init_begin) >> 10);
423} 410}
424 411
425#ifdef CONFIG_BLK_DEV_INITRD 412#ifdef CONFIG_BLK_DEV_INITRD
426void __init free_initrd_mem(unsigned long start, unsigned long end) 413void __init free_initrd_mem(unsigned long start, unsigned long end)
427{ 414{
428 if (start >= end) 415 free_reserved_area(start, end, 0, "initrd");
429 return;
430
431 start = _ALIGN_DOWN(start, PAGE_SIZE);
432 end = _ALIGN_UP(end, PAGE_SIZE);
433 pr_info("Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
434
435 for (; start < end; start += PAGE_SIZE) {
436 ClearPageReserved(virt_to_page(start));
437 init_page_count(virt_to_page(start));
438 free_page(start);
439 totalram_pages++;
440 }
441} 416}
442#endif 417#endif
443 418
diff --git a/arch/powerpc/platforms/512x/mpc512x_shared.c b/arch/powerpc/platforms/512x/mpc512x_shared.c
index d30235b7e3f7..db6ac389ef8c 100644
--- a/arch/powerpc/platforms/512x/mpc512x_shared.c
+++ b/arch/powerpc/platforms/512x/mpc512x_shared.c
@@ -172,12 +172,9 @@ static struct fsl_diu_shared_fb __attribute__ ((__aligned__(8))) diu_shared_fb;
172 172
173static inline void mpc512x_free_bootmem(struct page *page) 173static inline void mpc512x_free_bootmem(struct page *page)
174{ 174{
175 __ClearPageReserved(page);
176 BUG_ON(PageTail(page)); 175 BUG_ON(PageTail(page));
177 BUG_ON(atomic_read(&page->_count) > 1); 176 BUG_ON(atomic_read(&page->_count) > 1);
178 atomic_set(&page->_count, 1); 177 free_reserved_page(page);
179 __free_page(page);
180 totalram_pages++;
181} 178}
182 179
183void mpc512x_release_bootmem(void) 180void mpc512x_release_bootmem(void)