Commit 0fa1c579 authored by Rob Herring's avatar Rob Herring

of/fdt: use memblock_virt_alloc for early alloc

memblock_virt_alloc() works for both memblock and bootmem, so use it and
make early_init_dt_alloc_memory_arch a static function. The arches using
bootmem define early_init_dt_alloc_memory_arch as either:

__alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS))

or:

alloc_bootmem_align(size, align)

Both of these evaluate to the same thing as does memblock_virt_alloc for
bootmem. So we can disable the arch specific functions by making
early_init_dt_alloc_memory_arch static and they can be removed in
subsequent commits.

Cc: Frank Rowand <frowand.list@gmail.com>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
parent af6074fc
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/crc32.h> #include <linux/crc32.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/initrd.h> #include <linux/initrd.h>
#include <linux/bootmem.h>
#include <linux/memblock.h> #include <linux/memblock.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/of.h> #include <linux/of.h>
...@@ -1180,14 +1181,6 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, ...@@ -1180,14 +1181,6 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base,
return memblock_reserve(base, size); return memblock_reserve(base, size);
} }
/*
* called from unflatten_device_tree() to bootstrap devicetree itself
* Architectures can override this definition if memblock isn't used
*/
void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align)
{
return __va(memblock_alloc(size, align));
}
#else #else
void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size) void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
{ {
...@@ -1206,13 +1199,12 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, ...@@ -1206,13 +1199,12 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base,
&base, &size, nomap ? " (nomap)" : ""); &base, &size, nomap ? " (nomap)" : "");
return -ENOSYS; return -ENOSYS;
} }
#endif
void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) static void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
{ {
WARN_ON(1); return memblock_virt_alloc(size, align);
return NULL;
} }
#endif
bool __init early_init_dt_verify(void *params) bool __init early_init_dt_verify(void *params)
{ {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#define pr_fmt(fmt) "### dt-test ### " fmt #define pr_fmt(fmt) "### dt-test ### " fmt
#include <linux/bootmem.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/errno.h> #include <linux/errno.h>
...@@ -2053,6 +2054,11 @@ static struct overlay_info overlays[] = { ...@@ -2053,6 +2054,11 @@ static struct overlay_info overlays[] = {
static struct device_node *overlay_base_root; static struct device_node *overlay_base_root;
static void * __init dt_alloc_memory(u64 size, u64 align)
{
return memblock_virt_alloc(size, align);
}
/* /*
* Create base device tree for the overlay unittest. * Create base device tree for the overlay unittest.
* *
...@@ -2092,8 +2098,7 @@ void __init unittest_unflatten_overlay_base(void) ...@@ -2092,8 +2098,7 @@ void __init unittest_unflatten_overlay_base(void)
return; return;
} }
info->data = early_init_dt_alloc_memory_arch(size, info->data = dt_alloc_memory(size, roundup_pow_of_two(FDT_V17_SIZE));
roundup_pow_of_two(FDT_V17_SIZE));
if (!info->data) { if (!info->data) {
pr_err("alloc for dtb 'overlay_base' failed"); pr_err("alloc for dtb 'overlay_base' failed");
return; return;
...@@ -2102,7 +2107,7 @@ void __init unittest_unflatten_overlay_base(void) ...@@ -2102,7 +2107,7 @@ void __init unittest_unflatten_overlay_base(void)
memcpy(info->data, info->dtb_begin, size); memcpy(info->data, info->dtb_begin, size);
__unflatten_device_tree(info->data, NULL, &info->np_overlay, __unflatten_device_tree(info->data, NULL, &info->np_overlay,
early_init_dt_alloc_memory_arch, true); dt_alloc_memory, true);
overlay_base_root = info->np_overlay; overlay_base_root = info->np_overlay;
} }
......
...@@ -80,7 +80,6 @@ extern void early_init_dt_add_memory_arch(u64 base, u64 size); ...@@ -80,7 +80,6 @@ extern void early_init_dt_add_memory_arch(u64 base, u64 size);
extern int early_init_dt_mark_hotplug_memory_arch(u64 base, u64 size); extern int early_init_dt_mark_hotplug_memory_arch(u64 base, u64 size);
extern int early_init_dt_reserve_memory_arch(phys_addr_t base, phys_addr_t size, extern int early_init_dt_reserve_memory_arch(phys_addr_t base, phys_addr_t size,
bool no_map); bool no_map);
extern void * early_init_dt_alloc_memory_arch(u64 size, u64 align);
extern u64 dt_mem_next_cell(int s, const __be32 **cellp); extern u64 dt_mem_next_cell(int s, const __be32 **cellp);
/* Early flat tree scan hooks */ /* Early flat tree scan hooks */
......
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