aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiang Liu <liuj97@gmail.com>2013-04-29 18:06:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 18:54:29 -0400
commit83db0384a92ac4e52dccd275bc1a58dca86d629d (patch)
treeb09b3200b227acac7f5be12d58a9878a40be3e8e
parentf3beeb4a51d3aa16571e6c3774b929209e9956bf (diff)
mm/ARM: 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: Russell King <linux@arm.linux.org.uk> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/arm/mm/init.c48
-rw-r--r--arch/arm64/mm/init.c26
2 files changed, 18 insertions, 56 deletions
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index ad9a9f3f0322..611f21772fa8 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -427,24 +427,6 @@ void __init bootmem_init(void)
427 max_pfn = max_high - PHYS_PFN_OFFSET; 427 max_pfn = max_high - PHYS_PFN_OFFSET;
428} 428}
429 429
430static inline int free_area(unsigned long pfn, unsigned long end, char *s)
431{
432 unsigned int pages = 0, size = (end - pfn) << (PAGE_SHIFT - 10);
433
434 for (; pfn < end; pfn++) {
435 struct page *page = pfn_to_page(pfn);
436 ClearPageReserved(page);
437 init_page_count(page);
438 __free_page(page);
439 pages++;
440 }
441
442 if (size && s)
443 printk(KERN_INFO "Freeing %s memory: %dK\n", s, size);
444
445 return pages;
446}
447
448/* 430/*
449 * Poison init memory with an undefined instruction (ARM) or a branch to an 431 * Poison init memory with an undefined instruction (ARM) or a branch to an
450 * undefined instruction (Thumb). 432 * undefined instruction (Thumb).
@@ -537,6 +519,16 @@ static void __init free_unused_memmap(struct meminfo *mi)
537#endif 519#endif
538} 520}
539 521
522#ifdef CONFIG_HIGHMEM
523static inline void free_area_high(unsigned long pfn, unsigned long end)
524{
525 for (; pfn < end; pfn++) {
526 __free_reserved_page(pfn_to_page(pfn));
527 totalhigh_pages++;
528 }
529}
530#endif
531
540static void __init free_highpages(void) 532static void __init free_highpages(void)
541{ 533{
542#ifdef CONFIG_HIGHMEM 534#ifdef CONFIG_HIGHMEM
@@ -572,8 +564,7 @@ static void __init free_highpages(void)
572 if (res_end > end) 564 if (res_end > end)
573 res_end = end; 565 res_end = end;
574 if (res_start != start) 566 if (res_start != start)
575 totalhigh_pages += free_area(start, res_start, 567 free_area_high(start, res_start);
576 NULL);
577 start = res_end; 568 start = res_end;
578 if (start == end) 569 if (start == end)
579 break; 570 break;
@@ -581,7 +572,7 @@ static void __init free_highpages(void)
581 572
582 /* And now free anything which remains */ 573 /* And now free anything which remains */
583 if (start < end) 574 if (start < end)
584 totalhigh_pages += free_area(start, end, NULL); 575 free_area_high(start, end);
585 } 576 }
586 totalram_pages += totalhigh_pages; 577 totalram_pages += totalhigh_pages;
587#endif 578#endif
@@ -612,8 +603,7 @@ void __init mem_init(void)
612 603
613#ifdef CONFIG_SA1111 604#ifdef CONFIG_SA1111
614 /* now that our DMA memory is actually so designated, we can free it */ 605 /* now that our DMA memory is actually so designated, we can free it */
615 totalram_pages += free_area(PHYS_PFN_OFFSET, 606 free_reserved_area(__va(PHYS_PFN_OFFSET), swapper_pg_dir, 0, NULL);
616 __phys_to_pfn(__pa(swapper_pg_dir)), NULL);
617#endif 607#endif
618 608
619 free_highpages(); 609 free_highpages();
@@ -741,16 +731,12 @@ void free_initmem(void)
741 extern char __tcm_start, __tcm_end; 731 extern char __tcm_start, __tcm_end;
742 732
743 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start); 733 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
744 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)), 734 free_reserved_area(&__tcm_start, &__tcm_end, 0, "TCM link");
745 __phys_to_pfn(__pa(&__tcm_end)),
746 "TCM link");
747#endif 735#endif
748 736
749 poison_init_mem(__init_begin, __init_end - __init_begin); 737 poison_init_mem(__init_begin, __init_end - __init_begin);
750 if (!machine_is_integrator() && !machine_is_cintegrator()) 738 if (!machine_is_integrator() && !machine_is_cintegrator())
751 totalram_pages += free_area(__phys_to_pfn(__pa(__init_begin)), 739 free_initmem_default(0);
752 __phys_to_pfn(__pa(__init_end)),
753 "init");
754} 740}
755 741
756#ifdef CONFIG_BLK_DEV_INITRD 742#ifdef CONFIG_BLK_DEV_INITRD
@@ -761,9 +747,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
761{ 747{
762 if (!keep_initrd) { 748 if (!keep_initrd) {
763 poison_init_mem((void *)start, PAGE_ALIGN(end) - start); 749 poison_init_mem((void *)start, PAGE_ALIGN(end) - start);
764 totalram_pages += free_area(__phys_to_pfn(__pa(start)), 750 free_reserved_area(start, end, 0, "initrd");
765 __phys_to_pfn(__pa(end)),
766 "initrd");
767 } 751 }
768} 752}
769 753
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 800aac306a08..f497ca77925a 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -197,24 +197,6 @@ void __init bootmem_init(void)
197 max_pfn = max_low_pfn = max; 197 max_pfn = max_low_pfn = max;
198} 198}
199 199
200static inline int free_area(unsigned long pfn, unsigned long end, char *s)
201{
202 unsigned int pages = 0, size = (end - pfn) << (PAGE_SHIFT - 10);
203
204 for (; pfn < end; pfn++) {
205 struct page *page = pfn_to_page(pfn);
206 ClearPageReserved(page);
207 init_page_count(page);
208 __free_page(page);
209 pages++;
210 }
211
212 if (size && s)
213 pr_info("Freeing %s memory: %dK\n", s, size);
214
215 return pages;
216}
217
218/* 200/*
219 * Poison init memory with an undefined instruction (0x0). 201 * Poison init memory with an undefined instruction (0x0).
220 */ 202 */
@@ -405,9 +387,7 @@ void __init mem_init(void)
405void free_initmem(void) 387void free_initmem(void)
406{ 388{
407 poison_init_mem(__init_begin, __init_end - __init_begin); 389 poison_init_mem(__init_begin, __init_end - __init_begin);
408 totalram_pages += free_area(__phys_to_pfn(__pa(__init_begin)), 390 free_initmem_default(0);
409 __phys_to_pfn(__pa(__init_end)),
410 "init");
411} 391}
412 392
413#ifdef CONFIG_BLK_DEV_INITRD 393#ifdef CONFIG_BLK_DEV_INITRD
@@ -418,9 +398,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
418{ 398{
419 if (!keep_initrd) { 399 if (!keep_initrd) {
420 poison_init_mem((void *)start, PAGE_ALIGN(end) - start); 400 poison_init_mem((void *)start, PAGE_ALIGN(end) - start);
421 totalram_pages += free_area(__phys_to_pfn(__pa(start)), 401 free_reserved_area(start, end, 0, "initrd");
422 __phys_to_pfn(__pa(end)),
423 "initrd");
424 } 402 }
425} 403}
426 404