Commit e39f223f authored by Michael Ellerman's avatar Michael Ellerman

powerpc: Remove more traces of bootmem

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_virt_alloc(). In general a call such as:

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

Becomes:

  p = memblock_virt_alloc(x, 0);

We don't need the cast because memblock_virt_alloc() 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 remove a number of NULL checks on the result of
memblock_virt_alloc(). That is because memblock_virt_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.

The memory returned by memblock_virt_alloc() is already zeroed, so we
remove several memsets of the result of memblock_virt_alloc().

Finally we convert a few uses of __alloc_bootmem(x, y, MAX_DMA_ADDRESS)
to just plain memblock_virt_alloc(). We don't use memblock_alloc_base()
because MAX_DMA_ADDRESS is ~0ul on powerpc, so limiting the allocation
to that is pointless, 16XB ought to be enough for anyone.
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent a49ab6ee
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/bootmem.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/of_address.h> #include <linux/of_address.h>
......
...@@ -199,9 +199,7 @@ pci_create_OF_bus_map(void) ...@@ -199,9 +199,7 @@ pci_create_OF_bus_map(void)
struct property* of_prop; struct property* of_prop;
struct device_node *dn; struct device_node *dn;
of_prop = (struct property*) alloc_bootmem(sizeof(struct property) + 256); of_prop = memblock_virt_alloc(sizeof(struct property) + 256, 0);
if (!of_prop)
return;
dn = of_find_node_by_path("/"); dn = of_find_node_by_path("/");
if (dn) { if (dn) {
memset(of_prop, -1, sizeof(struct property) + 256); memset(of_prop, -1, sizeof(struct property) + 256);
......
...@@ -660,7 +660,7 @@ static void __init emergency_stack_init(void) ...@@ -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. * to manage page allocation until mem_init is called.
*/ */
void __init setup_arch(char **cmdline_p) void __init setup_arch(char **cmdline_p)
......
...@@ -13,9 +13,7 @@ void * __init_refok zalloc_maybe_bootmem(size_t size, gfp_t mask) ...@@ -13,9 +13,7 @@ void * __init_refok zalloc_maybe_bootmem(size_t size, gfp_t mask)
if (mem_init_done) if (mem_init_done)
p = kzalloc(size, mask); p = kzalloc(size, mask);
else { else {
p = alloc_bootmem(size); p = memblock_virt_alloc(size, 0);
if (p)
memset(p, 0, size);
} }
return p; return p;
} }
...@@ -315,7 +315,7 @@ int alloc_bootmem_huge_page(struct hstate *hstate) ...@@ -315,7 +315,7 @@ int alloc_bootmem_huge_page(struct hstate *hstate)
* If gpages can be in highmem we can't use the trick of storing the * If gpages can be in highmem we can't use the trick of storing the
* data structure in the page; allocate space for this * data structure in the page; allocate space for this
*/ */
m = alloc_bootmem(sizeof(struct huge_bootmem_page)); m = memblock_virt_alloc(sizeof(struct huge_bootmem_page), 0);
m->phys = gpage_freearray[idx].gpage_list[--nr_gpages]; m->phys = gpage_freearray[idx].gpage_list[--nr_gpages];
#else #else
m = phys_to_virt(gpage_freearray[idx].gpage_list[--nr_gpages]); m = phys_to_virt(gpage_freearray[idx].gpage_list[--nr_gpages]);
......
...@@ -421,12 +421,12 @@ void __init mmu_context_init(void) ...@@ -421,12 +421,12 @@ void __init mmu_context_init(void)
/* /*
* Allocate the maps used by context management * Allocate the maps used by context management
*/ */
context_map = alloc_bootmem(CTX_MAP_SIZE); context_map = memblock_virt_alloc(CTX_MAP_SIZE, 0);
context_mm = alloc_bootmem(sizeof(void *) * (last_context + 1)); context_mm = memblock_virt_alloc(sizeof(void *) * (last_context + 1), 0);
#ifndef CONFIG_SMP #ifndef CONFIG_SMP
stale_map[0] = alloc_bootmem(CTX_MAP_SIZE); stale_map[0] = memblock_virt_alloc(CTX_MAP_SIZE, 0);
#else #else
stale_map[boot_cpuid] = alloc_bootmem(CTX_MAP_SIZE); stale_map[boot_cpuid] = memblock_virt_alloc(CTX_MAP_SIZE, 0);
register_cpu_notifier(&mmu_context_cpu_nb); register_cpu_notifier(&mmu_context_cpu_nb);
#endif #endif
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/bootmem.h> #include <linux/memblock.h>
#include <linux/pci_regs.h> #include <linux/pci_regs.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
...@@ -401,11 +401,11 @@ static int __init celleb_setup_fake_pci_device(struct device_node *node, ...@@ -401,11 +401,11 @@ static int __init celleb_setup_fake_pci_device(struct device_node *node,
} else { } else {
if (config && *config) { if (config && *config) {
size = 256; size = 256;
free_bootmem(__pa(*config), size); memblock_free(__pa(*config), size);
} }
if (res && *res) { if (res && *res) {
size = sizeof(struct celleb_pci_resource); size = sizeof(struct celleb_pci_resource);
free_bootmem(__pa(*res), size); memblock_free(__pa(*res), size);
} }
} }
......
...@@ -513,11 +513,7 @@ static int __init core99_nvram_setup(struct device_node *dp, unsigned long addr) ...@@ -513,11 +513,7 @@ static int __init core99_nvram_setup(struct device_node *dp, unsigned long addr)
printk(KERN_ERR "nvram: no address\n"); printk(KERN_ERR "nvram: no address\n");
return -EINVAL; return -EINVAL;
} }
nvram_image = alloc_bootmem(NVRAM_SIZE); nvram_image = memblock_virt_alloc(NVRAM_SIZE, 0);
if (nvram_image == NULL) {
printk(KERN_ERR "nvram: can't allocate ram image\n");
return -ENOMEM;
}
nvram_data = ioremap(addr, NVRAM_SIZE*2); nvram_data = ioremap(addr, NVRAM_SIZE*2);
nvram_naddrs = 1; /* Make sure we get the correct case */ nvram_naddrs = 1; /* Make sure we get the correct case */
......
...@@ -1940,19 +1940,14 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np, ...@@ -1940,19 +1940,14 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
phb_id = be64_to_cpup(prop64); phb_id = be64_to_cpup(prop64);
pr_debug(" PHB-ID : 0x%016llx\n", phb_id); pr_debug(" PHB-ID : 0x%016llx\n", phb_id);
phb = alloc_bootmem(sizeof(struct pnv_phb)); phb = memblock_virt_alloc(sizeof(struct pnv_phb), 0);
if (!phb) {
pr_err(" Out of memory !\n");
return;
}
/* Allocate PCI controller */ /* Allocate PCI controller */
memset(phb, 0, sizeof(struct pnv_phb));
phb->hose = hose = pcibios_alloc_controller(np); phb->hose = hose = pcibios_alloc_controller(np);
if (!phb->hose) { if (!phb->hose) {
pr_err(" Can't allocate PCI controller for %s\n", pr_err(" Can't allocate PCI controller for %s\n",
np->full_name); np->full_name);
free_bootmem((unsigned long)phb, sizeof(struct pnv_phb)); memblock_free(__pa(phb), sizeof(struct pnv_phb));
return; return;
} }
...@@ -2019,8 +2014,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np, ...@@ -2019,8 +2014,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
} }
pemap_off = size; pemap_off = size;
size += phb->ioda.total_pe * sizeof(struct pnv_ioda_pe); size += phb->ioda.total_pe * sizeof(struct pnv_ioda_pe);
aux = alloc_bootmem(size); aux = memblock_virt_alloc(size, 0);
memset(aux, 0, size);
phb->ioda.pe_alloc = aux; phb->ioda.pe_alloc = aux;
phb->ioda.m32_segmap = aux + m32map_off; phb->ioda.m32_segmap = aux + m32map_off;
if (phb->type == PNV_PHB_IODA1) if (phb->type == PNV_PHB_IODA1)
......
...@@ -122,12 +122,9 @@ static void __init pnv_pci_init_p5ioc2_phb(struct device_node *np, u64 hub_id, ...@@ -122,12 +122,9 @@ static void __init pnv_pci_init_p5ioc2_phb(struct device_node *np, u64 hub_id,
return; return;
} }
phb = alloc_bootmem(sizeof(struct pnv_phb)); phb = memblock_virt_alloc(sizeof(struct pnv_phb), 0);
if (phb) { phb->hose = pcibios_alloc_controller(np);
memset(phb, 0, sizeof(struct pnv_phb)); if (!phb->hose) {
phb->hose = pcibios_alloc_controller(np);
}
if (!phb || !phb->hose) {
pr_err(" Failed to allocate PCI controller\n"); pr_err(" Failed to allocate PCI controller\n");
return; return;
} }
...@@ -216,12 +213,7 @@ void __init pnv_pci_init_p5ioc2_hub(struct device_node *np) ...@@ -216,12 +213,7 @@ void __init pnv_pci_init_p5ioc2_hub(struct device_node *np)
* *
* XXX TODO: Make it chip local if possible * XXX TODO: Make it chip local if possible
*/ */
tce_mem = __alloc_bootmem(P5IOC2_TCE_MEMORY, P5IOC2_TCE_MEMORY, tce_mem = memblock_virt_alloc(P5IOC2_TCE_MEMORY, P5IOC2_TCE_MEMORY);
__pa(MAX_DMA_ADDRESS));
if (!tce_mem) {
pr_err(" Failed to allocate TCE Memory !\n");
return;
}
pr_debug(" TCE : 0x%016lx..0x%016lx\n", pr_debug(" TCE : 0x%016lx..0x%016lx\n",
__pa(tce_mem), __pa(tce_mem) + P5IOC2_TCE_MEMORY - 1); __pa(tce_mem), __pa(tce_mem) + P5IOC2_TCE_MEMORY - 1);
rc = opal_pci_set_hub_tce_memory(hub_id, __pa(tce_mem), rc = opal_pci_set_hub_tce_memory(hub_id, __pa(tce_mem),
......
...@@ -125,12 +125,7 @@ static void __init prealloc(struct ps3_prealloc *p) ...@@ -125,12 +125,7 @@ static void __init prealloc(struct ps3_prealloc *p)
if (!p->size) if (!p->size)
return; return;
p->address = __alloc_bootmem(p->size, p->align, __pa(MAX_DMA_ADDRESS)); p->address = memblock_virt_alloc(p->size, p->align);
if (!p->address) {
printk(KERN_ERR "%s: Cannot allocate %s\n", __func__,
p->name);
return;
}
printk(KERN_INFO "%s: %lu bytes at %p\n", p->name, p->size, printk(KERN_INFO "%s: %lu bytes at %p\n", p->name, p->size,
p->address); p->address);
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/bootmem.h>
#include <linux/memblock.h> #include <linux/memblock.h>
#include <linux/log2.h> #include <linux/log2.h>
#include <linux/slab.h> #include <linux/slab.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment