powerpc: Move free_initmem to common code
authorDave Carroll <dcarroll@astekcorp.com>
Sat, 18 Jun 2011 07:36:39 +0000 (07:36 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Thu, 30 Jun 2011 05:28:05 +0000 (15:28 +1000)
The free_initmem function is basically duplicated in mm/init_32,
and init_64, and is moved to the common 32/64-bit mm/mem.c.

All other sections except init were removed in v2.6.15 by
6c45ab992e4299c869fb26427944a8f8ea177024 (powerpc: Remove section
free() and linker script bits), and therefore the bulk of the executed
code is identical.

This patch also removes updating ppc_md.progress to NULL in the powermac
late_initcall.

Suggested-by: Milton Miller <miltonm@bga.com>
Suggested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Dave Carroll <dcarroll@astekcorp.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/mm/init_32.c
arch/powerpc/mm/init_64.c
arch/powerpc/mm/mem.c
arch/powerpc/platforms/powermac/setup.c

index 5de0f254dbb5cb38fc39b2879fd2f6c40e36c3c6..c77fef56dad68ad342486546ba8af68f2f5636ed 100644 (file)
@@ -191,38 +191,6 @@ void __init *early_get_page(void)
                return __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE));
 }
 
-/* Free up now-unused memory */
-static void free_sec(unsigned long start, unsigned long end, const char *name)
-{
-       unsigned long cnt = 0;
-
-       while (start < end) {
-               ClearPageReserved(virt_to_page(start));
-               init_page_count(virt_to_page(start));
-               free_page(start);
-               cnt++;
-               start += PAGE_SIZE;
-       }
-       if (cnt) {
-               printk(" %ldk %s", cnt << (PAGE_SHIFT - 10), name);
-               totalram_pages += cnt;
-       }
-}
-
-void free_initmem(void)
-{
-#define FREESEC(TYPE) \
-       free_sec((unsigned long)(&__ ## TYPE ## _begin), \
-                (unsigned long)(&__ ## TYPE ## _end), \
-                #TYPE);
-
-       printk ("Freeing unused kernel memory:");
-       FREESEC(init);
-       printk("\n");
-       ppc_md.progress = NULL;
-#undef FREESEC
-}
-
 #ifdef CONFIG_8xx /* No 8xx specific .c file to put that in ... */
 void setup_initial_memory_limit(phys_addr_t first_memblock_base,
                                phys_addr_t first_memblock_size)
index f6dbb4c20e645ad071d87e6f5244c214e565e667..e94b57fb79a09be65781fbefe4d3e46d194d9f2a 100644 (file)
@@ -83,22 +83,6 @@ EXPORT_SYMBOL_GPL(memstart_addr);
 phys_addr_t kernstart_addr;
 EXPORT_SYMBOL_GPL(kernstart_addr);
 
-void free_initmem(void)
-{
-       unsigned long addr;
-
-       addr = (unsigned long)__init_begin;
-       for (; addr < (unsigned long)__init_end; addr += PAGE_SIZE) {
-               memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
-               ClearPageReserved(virt_to_page(addr));
-               init_page_count(virt_to_page(addr));
-               free_page(addr);
-               totalram_pages++;
-       }
-       printk ("Freeing unused kernel memory: %luk freed\n",
-               ((unsigned long)__init_end - (unsigned long)__init_begin) >> 10);
-}
-
 static void pgd_ctor(void *addr)
 {
        memset(addr, 0, PGD_TABLE_SIZE);
index 89cbfef5a7ddbc88c13e028208b28c09d4536bea..e9379ce6f3be2909e9732e041ed54c83adb1e1c1 100644 (file)
@@ -383,6 +383,25 @@ void __init mem_init(void)
        mem_init_done = 1;
 }
 
+void free_initmem(void)
+{
+       unsigned long addr;
+
+       ppc_md.progress = NULL;
+
+       addr = (unsigned long)__init_begin;
+       for (; addr < (unsigned long)__init_end; addr += PAGE_SIZE) {
+               memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
+               ClearPageReserved(virt_to_page(addr));
+               init_page_count(virt_to_page(addr));
+               free_page(addr);
+               totalram_pages++;
+       }
+       pr_info("Freeing unused kernel memory: %luk freed\n",
+               ((unsigned long)__init_end -
+               (unsigned long)__init_begin) >> 10);
+}
+
 #ifdef CONFIG_BLK_DEV_INITRD
 void __init free_initrd_mem(unsigned long start, unsigned long end)
 {
index aa45281bd296824d1927f1982e365fb8dd6e724b..a028f08309d64fcec51fd7b86f3d3b49d8bf263b 100644 (file)
@@ -355,9 +355,6 @@ static int initializing = 1;
 static int pmac_late_init(void)
 {
        initializing = 0;
-       /* this is udbg (which is __init) and we can later use it during
-        * cpu hotplug (in smp_core99_kick_cpu) */
-       ppc_md.progress = NULL;
        return 0;
 }
 machine_late_initcall(powermac, pmac_late_init);