[PATCH] powerpc: Remove more traces of bootmem

Subsystems: cell broadband engine architecture, linux for power macintosh, linux for powerpc (32-bit and 64-bit), ps3 platform support, the rest

STALE4354d

5 messages, 2 authors, 2014-11-19 · open the first message on its own page

[PATCH] powerpc: Remove more traces of bootmem

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2014-11-18 06:53:01

Although we are now selecting NO_BOOTMEM, we still have some traces of
bootmem lying around. That is because even with NO_BOOTMEM there is
still a shim that converts bootmem calls into memblock calls, but
ultimately we want to remove all traces of bootmem.

Most of the patch is conversions from alloc_bootmem() to
memblock_alloc(). In general a call such as:

  p = (struct foo *)alloc_bootmem(x);

Becomes:

  p = __va(memblock_alloc(x, 0));

We need __va() because memblock returns a physical address. We don't
need the cast because __va() returns a void *. The alignment value of
zero tells memblock to use the default alignment, which is
SMP_CACHE_BYTES, the same value alloc_bootmem() uses.

We also remove a number of NULL checks on the result of memblock_alloc().
That is because memblock_alloc() will panic if it can't allocate, in
exactly the same way as alloc_bootmem(), so the NULL checks are and
always have been redundant.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/pci-common.c            |  1 -
 arch/powerpc/kernel/pci_32.c                |  6 ++----
 arch/powerpc/kernel/setup_64.c              |  2 +-
 arch/powerpc/lib/alloc.c                    |  7 +++----
 arch/powerpc/mm/hugetlbpage.c               |  3 +--
 arch/powerpc/mm/mmu_context_nohash.c        | 10 +++++-----
 arch/powerpc/mm/numa.c                      |  2 +-
 arch/powerpc/platforms/cell/celleb_pci.c    |  6 +++---
 arch/powerpc/platforms/powermac/nvram.c     |  8 ++------
 arch/powerpc/platforms/powernv/pci-ioda.c   | 12 ++++--------
 arch/powerpc/platforms/powernv/pci-p5ioc2.c | 19 ++++++-------------
 arch/powerpc/platforms/ps3/setup.c          | 10 +++-------
 arch/powerpc/sysdev/fsl_pci.c               |  1 -
 13 files changed, 31 insertions(+), 56 deletions(-)
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index bc2dab52a991..37d512d35943 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -20,7 +20,6 @@
 #include <linux/pci.h>
 #include <linux/string.h>
 #include <linux/init.h>
-#include <linux/bootmem.h>
 #include <linux/delay.h>
 #include <linux/export.h>
 #include <linux/of_address.h>
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index 432459c817fa..bf156230a16f 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -10,7 +10,7 @@
 #include <linux/capability.h>
 #include <linux/sched.h>
 #include <linux/errno.h>
-#include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <linux/irq.h>
 #include <linux/list.h>
 #include <linux/of.h>
@@ -199,9 +199,7 @@ pci_create_OF_bus_map(void)
 	struct property* of_prop;
 	struct device_node *dn;
 
-	of_prop = (struct property*) alloc_bootmem(sizeof(struct property) + 256);
-	if (!of_prop)
-		return;
+	of_prop = __va(memblock_alloc(sizeof(struct property) + 256, 0));
 	dn = of_find_node_by_path("/");
 	if (dn) {
 		memset(of_prop, -1, sizeof(struct property) + 256);
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 6e5310ddf8c7..49f553bbb360 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -660,7 +660,7 @@ static void __init emergency_stack_init(void)
 }
 
 /*
- * Called into from start_kernel this initializes bootmem, which is used
+ * Called into from start_kernel this initializes memblock, which is used
  * to manage page allocation until mem_init is called.
  */
 void __init setup_arch(char **cmdline_p)
diff --git a/arch/powerpc/lib/alloc.c b/arch/powerpc/lib/alloc.c
index da22c84a8fed..633d7af89699 100644
--- a/arch/powerpc/lib/alloc.c
+++ b/arch/powerpc/lib/alloc.c
@@ -1,7 +1,7 @@
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <linux/string.h>
 #include <asm/setup.h>
 
@@ -13,9 +13,8 @@ void * __init_refok zalloc_maybe_bootmem(size_t size, gfp_t mask)
 	if (mem_init_done)
 		p = kzalloc(size, mask);
 	else {
-		p = alloc_bootmem(size);
-		if (p)
-			memset(p, 0, size);
+		p = __va(memblock_alloc(size, 0));
+		memset(p, 0, size);
 	}
 	return p;
 }
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index af56de82375d..df4eb786d98e 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -15,7 +15,6 @@
 #include <linux/export.h>
 #include <linux/of_fdt.h>
 #include <linux/memblock.h>
-#include <linux/bootmem.h>
 #include <linux/moduleparam.h>
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
@@ -315,7 +314,7 @@ int alloc_bootmem_huge_page(struct hstate *hstate)
 	 * If gpages can be in highmem we can't use the trick of storing the
 	 * data structure in the page; allocate space for this
 	 */
-	m = alloc_bootmem(sizeof(struct huge_bootmem_page));
+	m = __va(memblock_alloc(sizeof(struct huge_bootmem_page), 0));
 	m->phys = gpage_freearray[idx].gpage_list[--nr_gpages];
 #else
 	m = phys_to_virt(gpage_freearray[idx].gpage_list[--nr_gpages]);
diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
index 928ebe79668b..8810bd8531ed 100644
--- a/arch/powerpc/mm/mmu_context_nohash.c
+++ b/arch/powerpc/mm/mmu_context_nohash.c
@@ -44,7 +44,7 @@
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
-#include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <linux/notifier.h>
 #include <linux/cpu.h>
 #include <linux/slab.h>
@@ -421,12 +421,12 @@ void __init mmu_context_init(void)
 	/*
 	 * Allocate the maps used by context management
 	 */
-	context_map = alloc_bootmem(CTX_MAP_SIZE);
-	context_mm = alloc_bootmem(sizeof(void *) * (last_context + 1));
+	context_map = __va(memblock_alloc(CTX_MAP_SIZE, 0));
+	context_mm = __va(memblock_alloc(sizeof(void *) * (last_context + 1), 0));
 #ifndef CONFIG_SMP
-	stale_map[0] = alloc_bootmem(CTX_MAP_SIZE);
+	stale_map[0] = __va(memblock_alloc(CTX_MAP_SIZE, 0));
 #else
-	stale_map[boot_cpuid] = alloc_bootmem(CTX_MAP_SIZE);
+	stale_map[boot_cpuid] = __va(memblock_alloc(CTX_MAP_SIZE, 0));
 
 	register_cpu_notifier(&mmu_context_cpu_nb);
 #endif
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 417b0a523a47..aba064a17637 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -11,7 +11,6 @@
 #define pr_fmt(fmt) "numa: " fmt
 
 #include <linux/threads.h>
-#include <linux/bootmem.h>
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/mmzone.h>
@@ -19,6 +18,7 @@
 #include <linux/nodemask.h>
 #include <linux/cpu.h>
 #include <linux/notifier.h>
+#include <linux/bootmem.h>
 #include <linux/memblock.h>
 #include <linux/of.h>
 #include <linux/pfn.h>
diff --git a/arch/powerpc/platforms/cell/celleb_pci.c b/arch/powerpc/platforms/cell/celleb_pci.c
index 2b98a36ef8fb..3ce70ded2d6a 100644
--- a/arch/powerpc/platforms/cell/celleb_pci.c
+++ b/arch/powerpc/platforms/cell/celleb_pci.c
@@ -29,7 +29,7 @@
 #include <linux/pci.h>
 #include <linux/string.h>
 #include <linux/init.h>
-#include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <linux/pci_regs.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -401,11 +401,11 @@ error:
 	} else {
 		if (config && *config) {
 			size = 256;
-			free_bootmem(__pa(*config), size);
+			memblock_free(__pa(*config), size);
 		}
 		if (res && *res) {
 			size = sizeof(struct celleb_pci_resource);
-			free_bootmem(__pa(*res), size);
+			memblock_free(__pa(*res), size);
 		}
 	}
 
diff --git a/arch/powerpc/platforms/powermac/nvram.c b/arch/powerpc/platforms/powermac/nvram.c
index 014d06e6d46b..74541254e1a9 100644
--- a/arch/powerpc/platforms/powermac/nvram.c
+++ b/arch/powerpc/platforms/powermac/nvram.c
@@ -18,7 +18,7 @@
 #include <linux/errno.h>
 #include <linux/adb.h>
 #include <linux/pmu.h>
-#include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <linux/completion.h>
 #include <linux/spinlock.h>
 #include <asm/sections.h>
@@ -513,11 +513,7 @@ static int __init core99_nvram_setup(struct device_node *dp, unsigned long addr)
 		printk(KERN_ERR "nvram: no address\n");
 		return -EINVAL;
 	}
-	nvram_image = alloc_bootmem(NVRAM_SIZE);
-	if (nvram_image == NULL) {
-		printk(KERN_ERR "nvram: can't allocate ram image\n");
-		return -ENOMEM;
-	}
+	nvram_image = __va(memblock_alloc(NVRAM_SIZE, 0));
 	nvram_data = ioremap(addr, NVRAM_SIZE*2);
 	nvram_naddrs = 1; /* Make sure we get the correct case */
 
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index d03503515692..c95af005e82c 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -18,7 +18,7 @@
 #include <linux/delay.h>
 #include <linux/string.h>
 #include <linux/init.h>
-#include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <linux/irq.h>
 #include <linux/io.h>
 #include <linux/msi.h>
@@ -1940,11 +1940,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
 	phb_id = be64_to_cpup(prop64);
 	pr_debug("  PHB-ID  : 0x%016llx\n", phb_id);
 
-	phb = alloc_bootmem(sizeof(struct pnv_phb));
-	if (!phb) {
-		pr_err("  Out of memory !\n");
-		return;
-	}
+	phb = __va(memblock_alloc(sizeof(struct pnv_phb), 0));
 
 	/* Allocate PCI controller */
 	memset(phb, 0, sizeof(struct pnv_phb));
@@ -1952,7 +1948,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
 	if (!phb->hose) {
 		pr_err("  Can't allocate PCI controller for %s\n",
 		       np->full_name);
-		free_bootmem((unsigned long)phb, sizeof(struct pnv_phb));
+		memblock_free(__pa(phb), sizeof(struct pnv_phb));
 		return;
 	}
 
@@ -2019,7 +2015,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
 	}
 	pemap_off = size;
 	size += phb->ioda.total_pe * sizeof(struct pnv_ioda_pe);
-	aux = alloc_bootmem(size);
+	aux = __va(memblock_alloc(size, 0));
 	memset(aux, 0, size);
 	phb->ioda.pe_alloc = aux;
 	phb->ioda.m32_segmap = aux + m32map_off;
diff --git a/arch/powerpc/platforms/powernv/pci-p5ioc2.c b/arch/powerpc/platforms/powernv/pci-p5ioc2.c
index 3336fcbdd08a..0282d9d6b58e 100644
--- a/arch/powerpc/platforms/powernv/pci-p5ioc2.c
+++ b/arch/powerpc/platforms/powernv/pci-p5ioc2.c
@@ -16,7 +16,7 @@
 #include <linux/delay.h>
 #include <linux/string.h>
 #include <linux/init.h>
-#include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <linux/irq.h>
 #include <linux/io.h>
 #include <linux/msi.h>
@@ -122,12 +122,10 @@ static void __init pnv_pci_init_p5ioc2_phb(struct device_node *np, u64 hub_id,
 		return;
 	}
 
-	phb = alloc_bootmem(sizeof(struct pnv_phb));
-	if (phb) {
-		memset(phb, 0, sizeof(struct pnv_phb));
-		phb->hose = pcibios_alloc_controller(np);
-	}
-	if (!phb || !phb->hose) {
+	phb = __va(memblock_alloc(sizeof(struct pnv_phb), 0));
+	memset(phb, 0, sizeof(struct pnv_phb));
+	phb->hose = pcibios_alloc_controller(np);
+	if (!phb->hose) {
 		pr_err("  Failed to allocate PCI controller\n");
 		return;
 	}
@@ -216,12 +214,7 @@ void __init pnv_pci_init_p5ioc2_hub(struct device_node *np)
 	 *
 	 * XXX TODO: Make it chip local if possible
 	 */
-	tce_mem = __alloc_bootmem(P5IOC2_TCE_MEMORY, P5IOC2_TCE_MEMORY,
-				  __pa(MAX_DMA_ADDRESS));
-	if (!tce_mem) {
-		pr_err(" Failed to allocate TCE Memory !\n");
-		return;
-	}
+	tce_mem = __va(memblock_alloc(P5IOC2_TCE_MEMORY, P5IOC2_TCE_MEMORY));
 	pr_debug(" TCE    : 0x%016lx..0x%016lx\n",
 		__pa(tce_mem), __pa(tce_mem) + P5IOC2_TCE_MEMORY - 1);
 	rc = opal_pci_set_hub_tce_memory(hub_id, __pa(tce_mem),
diff --git a/arch/powerpc/platforms/ps3/setup.c b/arch/powerpc/platforms/ps3/setup.c
index 009a2004b876..86ed156f468f 100644
--- a/arch/powerpc/platforms/ps3/setup.c
+++ b/arch/powerpc/platforms/ps3/setup.c
@@ -24,7 +24,7 @@
 #include <linux/root_dev.h>
 #include <linux/console.h>
 #include <linux/export.h>
-#include <linux/bootmem.h>
+#include <linux/memblock.h>
 
 #include <asm/machdep.h>
 #include <asm/firmware.h>
@@ -125,12 +125,8 @@ static void __init prealloc(struct ps3_prealloc *p)
 	if (!p->size)
 		return;
 
-	p->address = __alloc_bootmem(p->size, p->align, __pa(MAX_DMA_ADDRESS));
-	if (!p->address) {
-		printk(KERN_ERR "%s: Cannot allocate %s\n", __func__,
-		       p->name);
-		return;
-	}
+	p->address = __va(memblock_alloc_base(p->size, p->align,
+					      __pa(MAX_DMA_ADDRESS)));
 
 	printk(KERN_INFO "%s: %lu bytes at %p\n", p->name, p->size,
 	       p->address);
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index d8484d7cffaa..6455c1eada1a 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -23,7 +23,6 @@
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
-#include <linux/bootmem.h>
 #include <linux/memblock.h>
 #include <linux/log2.h>
 #include <linux/slab.h>
-- 
1.9.1

Re: [PATCH] powerpc: Remove more traces of bootmem

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2014-11-18 10:28:22

On Tue, 2014-11-18 at 17:52 +1100, Michael Ellerman wrote:
quoted hunk
diff --git a/arch/powerpc/platforms/ps3/setup.c b/arch/powerpc/platforms/ps3/setup.c
index 009a2004b876..86ed156f468f 100644
--- a/arch/powerpc/platforms/ps3/setup.c
+++ b/arch/powerpc/platforms/ps3/setup.c
@@ -125,12 +125,8 @@ static void __init prealloc(struct ps3_prealloc *p)
 	if (!p->size)
 		return;
 
-	p->address = __alloc_bootmem(p->size, p->align, __pa(MAX_DMA_ADDRESS));
-	if (!p->address) {
-		printk(KERN_ERR "%s: Cannot allocate %s\n", __func__,
-		       p->name);
-		return;
-	}
+	p->address = __va(memblock_alloc_base(p->size, p->align,
+					      __pa(MAX_DMA_ADDRESS)));
This should be:
+	p->address = __va(memblock_alloc(p->size, p->align));
And a comment in the change log pointing out that MAX_DMA_ADDRESS is ~0ull on
powerpc, so limiting allocations to that is pointless.

cheers

RE: [PATCH] powerpc: Remove more traces of bootmem

From: David Laight <hidden>
Date: 2014-11-18 10:33:56

RnJvbTogTWljaGFlbCBFbGxlcm1hbg0KPiBBbHRob3VnaCB3ZSBhcmUgbm93IHNlbGVjdGluZyBO
T19CT09UTUVNLCB3ZSBzdGlsbCBoYXZlIHNvbWUgdHJhY2VzIG9mDQo+IGJvb3RtZW0gbHlpbmcg
YXJvdW5kLiBUaGF0IGlzIGJlY2F1c2UgZXZlbiB3aXRoIE5PX0JPT1RNRU0gdGhlcmUgaXMNCj4g
c3RpbGwgYSBzaGltIHRoYXQgY29udmVydHMgYm9vdG1lbSBjYWxscyBpbnRvIG1lbWJsb2NrIGNh
bGxzLCBidXQNCj4gdWx0aW1hdGVseSB3ZSB3YW50IHRvIHJlbW92ZSBhbGwgdHJhY2VzIG9mIGJv
b3RtZW0uDQo+IA0KPiBNb3N0IG9mIHRoZSBwYXRjaCBpcyBjb252ZXJzaW9ucyBmcm9tIGFsbG9j
X2Jvb3RtZW0oKSB0bw0KPiBtZW1ibG9ja19hbGxvYygpLiBJbiBnZW5lcmFsIGEgY2FsbCBzdWNo
IGFzOg0KPiANCj4gICBwID0gKHN0cnVjdCBmb28gKilhbGxvY19ib290bWVtKHgpOw0KPiANCj4g
QmVjb21lczoNCj4gDQo+ICAgcCA9IF9fdmEobWVtYmxvY2tfYWxsb2MoeCwgMCkpOw0KPiANCj4g
V2UgbmVlZCBfX3ZhKCkgYmVjYXVzZSBtZW1ibG9jayByZXR1cm5zIGEgcGh5c2ljYWwgYWRkcmVz
cy4gV2UgZG9uJ3QNCj4gbmVlZCB0aGUgY2FzdCBiZWNhdXNlIF9fdmEoKSByZXR1cm5zIGEgdm9p
ZCAqLiBUaGUgYWxpZ25tZW50IHZhbHVlIG9mDQo+IHplcm8gdGVsbHMgbWVtYmxvY2sgdG8gdXNl
IHRoZSBkZWZhdWx0IGFsaWdubWVudCwgd2hpY2ggaXMNCj4gU01QX0NBQ0hFX0JZVEVTLCB0aGUg
c2FtZSB2YWx1ZSBhbGxvY19ib290bWVtKCkgdXNlcy4NCg0KSXQgZG9lc24ndCBzZWVtIHJpZ2h0
IHRvIG1lIHRvIHJlcGxpY2F0ZSBfX3ZhKG1lbWJsb2NrX2FsbG9jKHgsIDApKQ0KdGhhdCBtYW55
IHRpbWVzLiBJIGNhbiBpbWFnaW5lIHRoYXQgdGhlIHJlcXVpcmVkIGNvZGUgd2lsbCBjaGFuZ2UN
CmFnYWluIGF0IHRvIGZ1dHVyZSB0aW1lLCBhbmQgdGhlbiBhbGwgdGhlIHNhbWUgcGxhY2VzIHdv
dWxkIG5lZWQgY2hhbmdpbmcuDQoNCldvdWxkbid0IGl0IGJlIGJldHRlciB0byB1c2U6DQojZGVm
aW5lIGFsbG9jX2Jvb3RtZW0oeCkgX192YShtZW1ibG9ja19hbGxvYyh4LCAwKSkNCnBvc3NpYmx5
IHdpdGggYSByZW5hbWUsIG9yIGFzIGEgc3RhdGljIGlubGluZS4NCklmIF9fdmEoKSBpcyBub24t
dHJpdmlhbCB5b3Ugd2FudCBhIHJlYWwgZnVuY3Rpb24uDQoNCglEYXZpZA0KDQo=

Re: [PATCH] powerpc: Remove more traces of bootmem

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2014-11-19 05:29:18

On Tue, 2014-11-18 at 10:26 +0000, David Laight wrote:
From: Michael Ellerman
quoted
Although we are now selecting NO_BOOTMEM, we still have some traces of
bootmem lying around. That is because even with NO_BOOTMEM there is
still a shim that converts bootmem calls into memblock calls, but
ultimately we want to remove all traces of bootmem.

Most of the patch is conversions from alloc_bootmem() to
memblock_alloc(). In general a call such as:

  p = (struct foo *)alloc_bootmem(x);

Becomes:

  p = __va(memblock_alloc(x, 0));

We need __va() because memblock returns a physical address. We don't
need the cast because __va() returns a void *. The alignment value of
zero tells memblock to use the default alignment, which is
SMP_CACHE_BYTES, the same value alloc_bootmem() uses.
It doesn't seem right to me to replicate __va(memblock_alloc(x, 0))
that many times. I can imagine that the required code will change
again at to future time, and then all the same places would need changing.
Yeah it's a bit ugly. Actually most of that code has never changed, which is
the problem, no one has bothered to update it.
Wouldn't it be better to use:
#define alloc_bootmem(x) __va(memblock_alloc(x, 0))
possibly with a rename, or as a static inline.
Well that's essentially what the existing shim does. So we can't use that name.

My plan is to add a memblock_alloc_virt() which does the __va() for you. But I
didn't want the powerpc changes to get backed up behind that.
If __va() is non-trivial you want a real function.
It can't be a function because we use it on void * as well as unsigned long,
phys_addr_t etc.

phys_to_virt() is the nicer version, though it only takes unsigned long.

cheers

Re: [PATCH] powerpc: Remove more traces of bootmem

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2014-11-19 07:57:38

On Wed, 2014-11-19 at 16:29 +1100, Michael Ellerman wrote:
On Tue, 2014-11-18 at 10:26 +0000, David Laight wrote:
quoted
From: Michael Ellerman
quoted
Although we are now selecting NO_BOOTMEM, we still have some traces of
bootmem lying around. That is because even with NO_BOOTMEM there is
still a shim that converts bootmem calls into memblock calls, but
ultimately we want to remove all traces of bootmem.

Most of the patch is conversions from alloc_bootmem() to
memblock_alloc(). In general a call such as:

  p = (struct foo *)alloc_bootmem(x);

Becomes:

  p = __va(memblock_alloc(x, 0));

We need __va() because memblock returns a physical address. We don't
need the cast because __va() returns a void *. The alignment value of
zero tells memblock to use the default alignment, which is
SMP_CACHE_BYTES, the same value alloc_bootmem() uses.
It doesn't seem right to me to replicate __va(memblock_alloc(x, 0))
that many times. I can imagine that the required code will change
again at to future time, and then all the same places would need changing.
After more grovelling through header files it turns out there is a wrapper that
does what we want - I think.

It's memblock_virt_alloc() (name reversed), and it's in bootmem.h, which is why
I didn't find it originally.

I'll try that instead.

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help