bootmem: fix wrong call parameter for free_bootmem()
authorJoonsoo Kim <js1304@gmail.com>
Wed, 12 Dec 2012 00:03:10 +0000 (16:03 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 12 Dec 2012 01:22:28 +0000 (17:22 -0800)
It is strange that alloc_bootmem() returns a virtual address and
free_bootmem() requires a physical address.  Anyway, free_bootmem()'s
first parameter should be physical address.

There are some call sites for free_bootmem() with virtual address.  So fix
them.

[akpm@linux-foundation.org: improve free_bootmem() and free_bootmem_pate() documentation]
Signed-off-by: Joonsoo Kim <js1304@gmail.com>
Cc: Haavard Skinnemoen <hskinnemoen@gmail.com>
Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/powerpc/platforms/cell/celleb_pci.c
drivers/macintosh/smu.c
include/linux/bootmem.h
lib/cpumask.c
mm/bootmem.c

index abc8af43ea7c5abf293d56abca685963de63560b..173568140a32ec0df09c0269107c1caa7ec035c6 100644 (file)
@@ -401,11 +401,11 @@ error:
        } else {
                if (config && *config) {
                        size = 256;
-                       free_bootmem((unsigned long)(*config), size);
+                       free_bootmem(__pa(*config), size);
                }
                if (res && *res) {
                        size = sizeof(struct celleb_pci_resource);
-                       free_bootmem((unsigned long)(*res), size);
+                       free_bootmem(__pa(*res), size);
                }
        }
 
index 7d5a6b40b31cf973a99e7f7232ab52bcd0bddf90..196368009001196f08f103a39c9786d93f335751 100644 (file)
@@ -565,7 +565,7 @@ fail_msg_node:
 fail_db_node:
        of_node_put(smu->db_node);
 fail_bootmem:
-       free_bootmem((unsigned long)smu, sizeof(struct smu_device));
+       free_bootmem(__pa(smu), sizeof(struct smu_device));
        smu = NULL;
 fail_np:
        of_node_put(np);
index 6d6795d46a7509f01e4a12993e9c7de34b02d975..7b74452c531769e0e032ad8eb05cda3bf4117fa7 100644 (file)
@@ -51,8 +51,8 @@ extern unsigned long free_all_bootmem(void);
 extern void free_bootmem_node(pg_data_t *pgdat,
                              unsigned long addr,
                              unsigned long size);
-extern void free_bootmem(unsigned long addr, unsigned long size);
-extern void free_bootmem_late(unsigned long addr, unsigned long size);
+extern void free_bootmem(unsigned long physaddr, unsigned long size);
+extern void free_bootmem_late(unsigned long physaddr, unsigned long size);
 
 /*
  * Flags for reserve_bootmem (also if CONFIG_HAVE_ARCH_BOOTMEM_NODE,
index 402a54ac35cbf60f665485ddd18500d5034e9ee9..d327b87c99b7ca28a222c20e6d05975bfa912e9e 100644 (file)
@@ -161,6 +161,6 @@ EXPORT_SYMBOL(free_cpumask_var);
  */
 void __init free_bootmem_cpumask_var(cpumask_var_t mask)
 {
-       free_bootmem((unsigned long)mask, cpumask_size());
+       free_bootmem(__pa(mask), cpumask_size());
 }
 #endif
index f468185b3b28a517aaceb79b80e7f799df0dfc6f..ecc45958ac0c5d3527b84f7eeddad3e51627f55f 100644 (file)
@@ -147,21 +147,21 @@ unsigned long __init init_bootmem(unsigned long start, unsigned long pages)
 
 /*
  * free_bootmem_late - free bootmem pages directly to page allocator
- * @addr: starting address of the range
+ * @addr: starting physical address of the range
  * @size: size of the range in bytes
  *
  * This is only useful when the bootmem allocator has already been torn
  * down, but we are still initializing the system.  Pages are given directly
  * to the page allocator, no bootmem metadata is updated because it is gone.
  */
-void __init free_bootmem_late(unsigned long addr, unsigned long size)
+void __init free_bootmem_late(unsigned long physaddr, unsigned long size)
 {
        unsigned long cursor, end;
 
-       kmemleak_free_part(__va(addr), size);
+       kmemleak_free_part(__va(physaddr), size);
 
-       cursor = PFN_UP(addr);
-       end = PFN_DOWN(addr + size);
+       cursor = PFN_UP(physaddr);
+       end = PFN_DOWN(physaddr + size);
 
        for (; cursor < end; cursor++) {
                __free_pages_bootmem(pfn_to_page(cursor), 0);
@@ -377,21 +377,21 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
 
 /**
  * free_bootmem - mark a page range as usable
- * @addr: starting address of the range
+ * @addr: starting physical address of the range
  * @size: size of the range in bytes
  *
  * Partial pages will be considered reserved and left as they are.
  *
  * The range must be contiguous but may span node boundaries.
  */
-void __init free_bootmem(unsigned long addr, unsigned long size)
+void __init free_bootmem(unsigned long physaddr, unsigned long size)
 {
        unsigned long start, end;
 
-       kmemleak_free_part(__va(addr), size);
+       kmemleak_free_part(__va(physaddr), size);
 
-       start = PFN_UP(addr);
-       end = PFN_DOWN(addr + size);
+       start = PFN_UP(physaddr);
+       end = PFN_DOWN(physaddr + size);
 
        mark_bootmem(start, end, 0, 0);
 }