diff options
author | Michael Ellerman <mpe@ellerman.id.au> | 2014-11-18 00:47:35 -0500 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2014-11-19 05:41:51 -0500 |
commit | e39f223fc93580c86ccf6b3422033e349f57f0dd (patch) | |
tree | 0aa179423f4c553bbf1fa361d28fe4c9c75927e7 | |
parent | a49ab6eeebe5624d51466969a7bac611231eede8 (diff) |
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: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r-- | arch/powerpc/kernel/pci-common.c | 1 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci_32.c | 4 | ||||
-rw-r--r-- | arch/powerpc/kernel/setup_64.c | 2 | ||||
-rw-r--r-- | arch/powerpc/lib/alloc.c | 4 | ||||
-rw-r--r-- | arch/powerpc/mm/hugetlbpage.c | 2 | ||||
-rw-r--r-- | arch/powerpc/mm/mmu_context_nohash.c | 8 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/celleb_pci.c | 6 | ||||
-rw-r--r-- | arch/powerpc/platforms/powermac/nvram.c | 6 | ||||
-rw-r--r-- | arch/powerpc/platforms/powernv/pci-ioda.c | 12 | ||||
-rw-r--r-- | arch/powerpc/platforms/powernv/pci-p5ioc2.c | 16 | ||||
-rw-r--r-- | arch/powerpc/platforms/ps3/setup.c | 7 | ||||
-rw-r--r-- | arch/powerpc/sysdev/fsl_pci.c | 1 |
12 files changed, 20 insertions, 49 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 @@ | |||
20 | #include <linux/pci.h> | 20 | #include <linux/pci.h> |
21 | #include <linux/string.h> | 21 | #include <linux/string.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/bootmem.h> | ||
24 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
25 | #include <linux/export.h> | 24 | #include <linux/export.h> |
26 | #include <linux/of_address.h> | 25 | #include <linux/of_address.h> |
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c index 432459c817fa..1f7930037cb7 100644 --- a/arch/powerpc/kernel/pci_32.c +++ b/arch/powerpc/kernel/pci_32.c | |||
@@ -199,9 +199,7 @@ pci_create_OF_bus_map(void) | |||
199 | struct property* of_prop; | 199 | struct property* of_prop; |
200 | struct device_node *dn; | 200 | struct device_node *dn; |
201 | 201 | ||
202 | of_prop = (struct property*) alloc_bootmem(sizeof(struct property) + 256); | 202 | of_prop = memblock_virt_alloc(sizeof(struct property) + 256, 0); |
203 | if (!of_prop) | ||
204 | return; | ||
205 | dn = of_find_node_by_path("/"); | 203 | dn = of_find_node_by_path("/"); |
206 | if (dn) { | 204 | if (dn) { |
207 | memset(of_prop, -1, sizeof(struct property) + 256); | 205 | 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) | |||
660 | } | 660 | } |
661 | 661 | ||
662 | /* | 662 | /* |
663 | * Called into from start_kernel this initializes bootmem, which is used | 663 | * Called into from start_kernel this initializes memblock, which is used |
664 | * to manage page allocation until mem_init is called. | 664 | * to manage page allocation until mem_init is called. |
665 | */ | 665 | */ |
666 | void __init setup_arch(char **cmdline_p) | 666 | void __init setup_arch(char **cmdline_p) |
diff --git a/arch/powerpc/lib/alloc.c b/arch/powerpc/lib/alloc.c index da22c84a8fed..4a6c2cf890d9 100644 --- a/arch/powerpc/lib/alloc.c +++ b/arch/powerpc/lib/alloc.c | |||
@@ -13,9 +13,7 @@ void * __init_refok zalloc_maybe_bootmem(size_t size, gfp_t mask) | |||
13 | if (mem_init_done) | 13 | if (mem_init_done) |
14 | p = kzalloc(size, mask); | 14 | p = kzalloc(size, mask); |
15 | else { | 15 | else { |
16 | p = alloc_bootmem(size); | 16 | p = memblock_virt_alloc(size, 0); |
17 | if (p) | ||
18 | memset(p, 0, size); | ||
19 | } | 17 | } |
20 | return p; | 18 | return p; |
21 | } | 19 | } |
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index af56de82375d..8c9b8115867c 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c | |||
@@ -315,7 +315,7 @@ int alloc_bootmem_huge_page(struct hstate *hstate) | |||
315 | * If gpages can be in highmem we can't use the trick of storing the | 315 | * If gpages can be in highmem we can't use the trick of storing the |
316 | * data structure in the page; allocate space for this | 316 | * data structure in the page; allocate space for this |
317 | */ | 317 | */ |
318 | m = alloc_bootmem(sizeof(struct huge_bootmem_page)); | 318 | m = memblock_virt_alloc(sizeof(struct huge_bootmem_page), 0); |
319 | m->phys = gpage_freearray[idx].gpage_list[--nr_gpages]; | 319 | m->phys = gpage_freearray[idx].gpage_list[--nr_gpages]; |
320 | #else | 320 | #else |
321 | m = phys_to_virt(gpage_freearray[idx].gpage_list[--nr_gpages]); | 321 | 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..9cba6cba2e50 100644 --- a/arch/powerpc/mm/mmu_context_nohash.c +++ b/arch/powerpc/mm/mmu_context_nohash.c | |||
@@ -421,12 +421,12 @@ void __init mmu_context_init(void) | |||
421 | /* | 421 | /* |
422 | * Allocate the maps used by context management | 422 | * Allocate the maps used by context management |
423 | */ | 423 | */ |
424 | context_map = alloc_bootmem(CTX_MAP_SIZE); | 424 | context_map = memblock_virt_alloc(CTX_MAP_SIZE, 0); |
425 | context_mm = alloc_bootmem(sizeof(void *) * (last_context + 1)); | 425 | context_mm = memblock_virt_alloc(sizeof(void *) * (last_context + 1), 0); |
426 | #ifndef CONFIG_SMP | 426 | #ifndef CONFIG_SMP |
427 | stale_map[0] = alloc_bootmem(CTX_MAP_SIZE); | 427 | stale_map[0] = memblock_virt_alloc(CTX_MAP_SIZE, 0); |
428 | #else | 428 | #else |
429 | stale_map[boot_cpuid] = alloc_bootmem(CTX_MAP_SIZE); | 429 | stale_map[boot_cpuid] = memblock_virt_alloc(CTX_MAP_SIZE, 0); |
430 | 430 | ||
431 | register_cpu_notifier(&mmu_context_cpu_nb); | 431 | register_cpu_notifier(&mmu_context_cpu_nb); |
432 | #endif | 432 | #endif |
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 @@ | |||
29 | #include <linux/pci.h> | 29 | #include <linux/pci.h> |
30 | #include <linux/string.h> | 30 | #include <linux/string.h> |
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/bootmem.h> | 32 | #include <linux/memblock.h> |
33 | #include <linux/pci_regs.h> | 33 | #include <linux/pci_regs.h> |
34 | #include <linux/of.h> | 34 | #include <linux/of.h> |
35 | #include <linux/of_device.h> | 35 | #include <linux/of_device.h> |
@@ -401,11 +401,11 @@ error: | |||
401 | } else { | 401 | } else { |
402 | if (config && *config) { | 402 | if (config && *config) { |
403 | size = 256; | 403 | size = 256; |
404 | free_bootmem(__pa(*config), size); | 404 | memblock_free(__pa(*config), size); |
405 | } | 405 | } |
406 | if (res && *res) { | 406 | if (res && *res) { |
407 | size = sizeof(struct celleb_pci_resource); | 407 | size = sizeof(struct celleb_pci_resource); |
408 | free_bootmem(__pa(*res), size); | 408 | memblock_free(__pa(*res), size); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | 411 | ||
diff --git a/arch/powerpc/platforms/powermac/nvram.c b/arch/powerpc/platforms/powermac/nvram.c index 014d06e6d46b..60b03a1703d1 100644 --- a/arch/powerpc/platforms/powermac/nvram.c +++ b/arch/powerpc/platforms/powermac/nvram.c | |||
@@ -513,11 +513,7 @@ static int __init core99_nvram_setup(struct device_node *dp, unsigned long addr) | |||
513 | printk(KERN_ERR "nvram: no address\n"); | 513 | printk(KERN_ERR "nvram: no address\n"); |
514 | return -EINVAL; | 514 | return -EINVAL; |
515 | } | 515 | } |
516 | nvram_image = alloc_bootmem(NVRAM_SIZE); | 516 | nvram_image = memblock_virt_alloc(NVRAM_SIZE, 0); |
517 | if (nvram_image == NULL) { | ||
518 | printk(KERN_ERR "nvram: can't allocate ram image\n"); | ||
519 | return -ENOMEM; | ||
520 | } | ||
521 | nvram_data = ioremap(addr, NVRAM_SIZE*2); | 517 | nvram_data = ioremap(addr, NVRAM_SIZE*2); |
522 | nvram_naddrs = 1; /* Make sure we get the correct case */ | 518 | nvram_naddrs = 1; /* Make sure we get the correct case */ |
523 | 519 | ||
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index d03503515692..cc861c14840d 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c | |||
@@ -1940,19 +1940,14 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np, | |||
1940 | phb_id = be64_to_cpup(prop64); | 1940 | phb_id = be64_to_cpup(prop64); |
1941 | pr_debug(" PHB-ID : 0x%016llx\n", phb_id); | 1941 | pr_debug(" PHB-ID : 0x%016llx\n", phb_id); |
1942 | 1942 | ||
1943 | phb = alloc_bootmem(sizeof(struct pnv_phb)); | 1943 | phb = memblock_virt_alloc(sizeof(struct pnv_phb), 0); |
1944 | if (!phb) { | ||
1945 | pr_err(" Out of memory !\n"); | ||
1946 | return; | ||
1947 | } | ||
1948 | 1944 | ||
1949 | /* Allocate PCI controller */ | 1945 | /* Allocate PCI controller */ |
1950 | memset(phb, 0, sizeof(struct pnv_phb)); | ||
1951 | phb->hose = hose = pcibios_alloc_controller(np); | 1946 | phb->hose = hose = pcibios_alloc_controller(np); |
1952 | if (!phb->hose) { | 1947 | if (!phb->hose) { |
1953 | pr_err(" Can't allocate PCI controller for %s\n", | 1948 | pr_err(" Can't allocate PCI controller for %s\n", |
1954 | np->full_name); | 1949 | np->full_name); |
1955 | free_bootmem((unsigned long)phb, sizeof(struct pnv_phb)); | 1950 | memblock_free(__pa(phb), sizeof(struct pnv_phb)); |
1956 | return; | 1951 | return; |
1957 | } | 1952 | } |
1958 | 1953 | ||
@@ -2019,8 +2014,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np, | |||
2019 | } | 2014 | } |
2020 | pemap_off = size; | 2015 | pemap_off = size; |
2021 | size += phb->ioda.total_pe * sizeof(struct pnv_ioda_pe); | 2016 | size += phb->ioda.total_pe * sizeof(struct pnv_ioda_pe); |
2022 | aux = alloc_bootmem(size); | 2017 | aux = memblock_virt_alloc(size, 0); |
2023 | memset(aux, 0, size); | ||
2024 | phb->ioda.pe_alloc = aux; | 2018 | phb->ioda.pe_alloc = aux; |
2025 | phb->ioda.m32_segmap = aux + m32map_off; | 2019 | phb->ioda.m32_segmap = aux + m32map_off; |
2026 | if (phb->type == PNV_PHB_IODA1) | 2020 | if (phb->type == PNV_PHB_IODA1) |
diff --git a/arch/powerpc/platforms/powernv/pci-p5ioc2.c b/arch/powerpc/platforms/powernv/pci-p5ioc2.c index 3336fcbdd08a..6ef6d4d8e7e2 100644 --- a/arch/powerpc/platforms/powernv/pci-p5ioc2.c +++ b/arch/powerpc/platforms/powernv/pci-p5ioc2.c | |||
@@ -122,12 +122,9 @@ static void __init pnv_pci_init_p5ioc2_phb(struct device_node *np, u64 hub_id, | |||
122 | return; | 122 | return; |
123 | } | 123 | } |
124 | 124 | ||
125 | phb = alloc_bootmem(sizeof(struct pnv_phb)); | 125 | phb = memblock_virt_alloc(sizeof(struct pnv_phb), 0); |
126 | if (phb) { | 126 | phb->hose = pcibios_alloc_controller(np); |
127 | memset(phb, 0, sizeof(struct pnv_phb)); | 127 | if (!phb->hose) { |
128 | phb->hose = pcibios_alloc_controller(np); | ||
129 | } | ||
130 | if (!phb || !phb->hose) { | ||
131 | pr_err(" Failed to allocate PCI controller\n"); | 128 | pr_err(" Failed to allocate PCI controller\n"); |
132 | return; | 129 | return; |
133 | } | 130 | } |
@@ -216,12 +213,7 @@ void __init pnv_pci_init_p5ioc2_hub(struct device_node *np) | |||
216 | * | 213 | * |
217 | * XXX TODO: Make it chip local if possible | 214 | * XXX TODO: Make it chip local if possible |
218 | */ | 215 | */ |
219 | tce_mem = __alloc_bootmem(P5IOC2_TCE_MEMORY, P5IOC2_TCE_MEMORY, | 216 | tce_mem = memblock_virt_alloc(P5IOC2_TCE_MEMORY, P5IOC2_TCE_MEMORY); |
220 | __pa(MAX_DMA_ADDRESS)); | ||
221 | if (!tce_mem) { | ||
222 | pr_err(" Failed to allocate TCE Memory !\n"); | ||
223 | return; | ||
224 | } | ||
225 | pr_debug(" TCE : 0x%016lx..0x%016lx\n", | 217 | pr_debug(" TCE : 0x%016lx..0x%016lx\n", |
226 | __pa(tce_mem), __pa(tce_mem) + P5IOC2_TCE_MEMORY - 1); | 218 | __pa(tce_mem), __pa(tce_mem) + P5IOC2_TCE_MEMORY - 1); |
227 | rc = opal_pci_set_hub_tce_memory(hub_id, __pa(tce_mem), | 219 | 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..799c8580ab09 100644 --- a/arch/powerpc/platforms/ps3/setup.c +++ b/arch/powerpc/platforms/ps3/setup.c | |||
@@ -125,12 +125,7 @@ static void __init prealloc(struct ps3_prealloc *p) | |||
125 | if (!p->size) | 125 | if (!p->size) |
126 | return; | 126 | return; |
127 | 127 | ||
128 | p->address = __alloc_bootmem(p->size, p->align, __pa(MAX_DMA_ADDRESS)); | 128 | p->address = memblock_virt_alloc(p->size, p->align); |
129 | if (!p->address) { | ||
130 | printk(KERN_ERR "%s: Cannot allocate %s\n", __func__, | ||
131 | p->name); | ||
132 | return; | ||
133 | } | ||
134 | 129 | ||
135 | printk(KERN_INFO "%s: %lu bytes at %p\n", p->name, p->size, | 130 | printk(KERN_INFO "%s: %lu bytes at %p\n", p->name, p->size, |
136 | p->address); | 131 | 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 @@ | |||
23 | #include <linux/string.h> | 23 | #include <linux/string.h> |
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
26 | #include <linux/bootmem.h> | ||
27 | #include <linux/memblock.h> | 26 | #include <linux/memblock.h> |
28 | #include <linux/log2.h> | 27 | #include <linux/log2.h> |
29 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |