aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2018-01-05 16:32:33 -0500
committerRob Herring <robh@kernel.org>2018-01-08 09:24:34 -0500
commit0fa1c579349fdd90173381712ad78aa99c09d38b (patch)
tree75cb0dbfbfad3df504ed14d52cca36a84683478b
parentaf6074fc9aa4b29517375634189ada1869eea598 (diff)
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: Rob Herring <robh@kernel.org>
-rw-r--r--drivers/of/fdt.c16
-rw-r--r--drivers/of/unittest.c11
-rw-r--r--include/linux/of_fdt.h1
3 files changed, 12 insertions, 16 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 7db5353a24c0..84aa9d676375 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -11,6 +11,7 @@
11#include <linux/crc32.h> 11#include <linux/crc32.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/initrd.h> 13#include <linux/initrd.h>
14#include <linux/bootmem.h>
14#include <linux/memblock.h> 15#include <linux/memblock.h>
15#include <linux/mutex.h> 16#include <linux/mutex.h>
16#include <linux/of.h> 17#include <linux/of.h>
@@ -1180,14 +1181,6 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base,
1180 return memblock_reserve(base, size); 1181 return memblock_reserve(base, size);
1181} 1182}
1182 1183
1183/*
1184 * called from unflatten_device_tree() to bootstrap devicetree itself
1185 * Architectures can override this definition if memblock isn't used
1186 */
1187void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align)
1188{
1189 return __va(memblock_alloc(size, align));
1190}
1191#else 1184#else
1192void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size) 1185void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
1193{ 1186{
@@ -1206,13 +1199,12 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base,
1206 &base, &size, nomap ? " (nomap)" : ""); 1199 &base, &size, nomap ? " (nomap)" : "");
1207 return -ENOSYS; 1200 return -ENOSYS;
1208} 1201}
1202#endif
1209 1203
1210void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) 1204static void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
1211{ 1205{
1212 WARN_ON(1); 1206 return memblock_virt_alloc(size, align);
1213 return NULL;
1214} 1207}
1215#endif
1216 1208
1217bool __init early_init_dt_verify(void *params) 1209bool __init early_init_dt_verify(void *params)
1218{ 1210{
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 0f8052f1355c..7a9abaae874d 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -5,6 +5,7 @@
5 5
6#define pr_fmt(fmt) "### dt-test ### " fmt 6#define pr_fmt(fmt) "### dt-test ### " fmt
7 7
8#include <linux/bootmem.h>
8#include <linux/clk.h> 9#include <linux/clk.h>
9#include <linux/err.h> 10#include <linux/err.h>
10#include <linux/errno.h> 11#include <linux/errno.h>
@@ -2053,6 +2054,11 @@ static struct overlay_info overlays[] = {
2053 2054
2054static struct device_node *overlay_base_root; 2055static struct device_node *overlay_base_root;
2055 2056
2057static void * __init dt_alloc_memory(u64 size, u64 align)
2058{
2059 return memblock_virt_alloc(size, align);
2060}
2061
2056/* 2062/*
2057 * Create base device tree for the overlay unittest. 2063 * Create base device tree for the overlay unittest.
2058 * 2064 *
@@ -2092,8 +2098,7 @@ void __init unittest_unflatten_overlay_base(void)
2092 return; 2098 return;
2093 } 2099 }
2094 2100
2095 info->data = early_init_dt_alloc_memory_arch(size, 2101 info->data = dt_alloc_memory(size, roundup_pow_of_two(FDT_V17_SIZE));
2096 roundup_pow_of_two(FDT_V17_SIZE));
2097 if (!info->data) { 2102 if (!info->data) {
2098 pr_err("alloc for dtb 'overlay_base' failed"); 2103 pr_err("alloc for dtb 'overlay_base' failed");
2099 return; 2104 return;
@@ -2102,7 +2107,7 @@ void __init unittest_unflatten_overlay_base(void)
2102 memcpy(info->data, info->dtb_begin, size); 2107 memcpy(info->data, info->dtb_begin, size);
2103 2108
2104 __unflatten_device_tree(info->data, NULL, &info->np_overlay, 2109 __unflatten_device_tree(info->data, NULL, &info->np_overlay,
2105 early_init_dt_alloc_memory_arch, true); 2110 dt_alloc_memory, true);
2106 overlay_base_root = info->np_overlay; 2111 overlay_base_root = info->np_overlay;
2107} 2112}
2108 2113
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index 08473f372e7f..b9cd9ebdf9b9 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -80,7 +80,6 @@ extern void early_init_dt_add_memory_arch(u64 base, u64 size);
80extern int early_init_dt_mark_hotplug_memory_arch(u64 base, u64 size); 80extern int early_init_dt_mark_hotplug_memory_arch(u64 base, u64 size);
81extern int early_init_dt_reserve_memory_arch(phys_addr_t base, phys_addr_t size, 81extern int early_init_dt_reserve_memory_arch(phys_addr_t base, phys_addr_t size,
82 bool no_map); 82 bool no_map);
83extern void * early_init_dt_alloc_memory_arch(u64 size, u64 align);
84extern u64 dt_mem_next_cell(int s, const __be32 **cellp); 83extern u64 dt_mem_next_cell(int s, const __be32 **cellp);
85 84
86/* Early flat tree scan hooks */ 85/* Early flat tree scan hooks */