From: Rob Herring <robherring2@gmail.com>
To: Grant Likely <grant.likely@linaro.org>,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Cc: Rob Herring <robh@kernel.org>,
Russell King <linux@arm.linux.org.uk>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>
Subject: [PATCH v2 15/21] of/fdt: move memreserve and dtb memory reservations into core
Date: Tue, 22 Apr 2014 20:18:15 -0500 [thread overview]
Message-ID: <1398215901-25609-16-git-send-email-robherring2@gmail.com> (raw)
In-Reply-To: <1398215901-25609-1-git-send-email-robherring2@gmail.com>
From: Rob Herring <robh@kernel.org>
Move the /memreserve/ processing and dtb memory reservations into
early_init_fdt_scan_reserved_mem. This converts arm, arm64, and powerpc
as they are the only users of early_init_fdt_scan_reserved_mem.
memblock_reserve is safe to call on the same region twice, so the
reservation check for the dtb in powerpc 32-bit reservations is safe to
remove.
Signed-off-by: Rob Herring <robh@kernel.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
---
v2: No change
arch/arm/include/asm/prom.h | 2 --
arch/arm/kernel/devtree.c | 27 ---------------------------
arch/arm/mm/init.c | 1 -
arch/arm64/mm/init.c | 21 ---------------------
arch/powerpc/kernel/prom.c | 22 ----------------------
drivers/of/fdt.c | 16 ++++++++++++++++
6 files changed, 16 insertions(+), 73 deletions(-)
diff --git a/arch/arm/include/asm/prom.h b/arch/arm/include/asm/prom.h
index b681575..cd94ef2 100644
--- a/arch/arm/include/asm/prom.h
+++ b/arch/arm/include/asm/prom.h
@@ -14,7 +14,6 @@
#ifdef CONFIG_OF
extern const struct machine_desc *setup_machine_fdt(unsigned int dt_phys);
-extern void arm_dt_memblock_reserve(void);
extern void __init arm_dt_init_cpu_maps(void);
#else /* CONFIG_OF */
@@ -24,7 +23,6 @@ static inline const struct machine_desc *setup_machine_fdt(unsigned int dt_phys)
return NULL;
}
-static inline void arm_dt_memblock_reserve(void) { }
static inline void arm_dt_init_cpu_maps(void) { }
#endif /* CONFIG_OF */
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index 38f4711..3e5a205 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -32,33 +32,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
arm_add_memory(base, size);
}
-void __init arm_dt_memblock_reserve(void)
-{
- u64 *reserve_map, base, size;
-
- if (!initial_boot_params)
- return;
-
- /* Reserve the dtb region */
- memblock_reserve(virt_to_phys(initial_boot_params),
- be32_to_cpu(initial_boot_params->totalsize));
-
- /*
- * Process the reserve map. This will probably overlap the initrd
- * and dtb locations which are already reserved, but overlaping
- * doesn't hurt anything
- */
- reserve_map = ((void*)initial_boot_params) +
- be32_to_cpu(initial_boot_params->off_mem_rsvmap);
- while (1) {
- base = be64_to_cpup(reserve_map++);
- size = be64_to_cpup(reserve_map++);
- if (!size)
- break;
- memblock_reserve(base, size);
- }
-}
-
#ifdef CONFIG_SMP
extern struct of_cpu_method __cpu_method_of_table_begin[];
extern struct of_cpu_method __cpu_method_of_table_end[];
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 2a77ba8..928d596 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -317,7 +317,6 @@ void __init arm_memblock_init(struct meminfo *mi,
#endif
arm_mm_memblock_reserve();
- arm_dt_memblock_reserve();
/* reserve any platform specific memblock areas */
if (mdesc->reserve)
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 51d5352..091d428 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -126,8 +126,6 @@ static void arm64_memory_present(void)
void __init arm64_memblock_init(void)
{
- u64 *reserve_map, base, size;
-
/* Register the kernel text, kernel data and initrd with memblock */
memblock_reserve(__pa(_text), _end - _text);
#ifdef CONFIG_BLK_DEV_INITRD
@@ -142,25 +140,6 @@ void __init arm64_memblock_init(void)
memblock_reserve(__pa(swapper_pg_dir), SWAPPER_DIR_SIZE);
memblock_reserve(__pa(idmap_pg_dir), IDMAP_DIR_SIZE);
- /* Reserve the dtb region */
- memblock_reserve(virt_to_phys(initial_boot_params),
- be32_to_cpu(initial_boot_params->totalsize));
-
- /*
- * Process the reserve map. This will probably overlap the initrd
- * and dtb locations which are already reserved, but overlapping
- * doesn't hurt anything
- */
- reserve_map = ((void*)initial_boot_params) +
- be32_to_cpu(initial_boot_params->off_mem_rsvmap);
- while (1) {
- base = be64_to_cpup(reserve_map++);
- size = be64_to_cpup(reserve_map++);
- if (!size)
- break;
- memblock_reserve(base, size);
- }
-
early_init_fdt_scan_reserved_mem();
dma_contiguous_reserve(0);
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 03624ce..b1de8e3 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -596,19 +596,11 @@ static void __init early_reserve_mem_dt(void)
static void __init early_reserve_mem(void)
{
- u64 base, size;
__be64 *reserve_map;
- unsigned long self_base;
- unsigned long self_size;
reserve_map = (__be64 *)(((unsigned long)initial_boot_params) +
be32_to_cpu(initial_boot_params->off_mem_rsvmap));
- /* before we do anything, lets reserve the dt blob */
- self_base = __pa((unsigned long)initial_boot_params);
- self_size = be32_to_cpu(initial_boot_params->totalsize);
- memblock_reserve(self_base, self_size);
-
/* Look for the new "reserved-regions" property in the DT */
early_reserve_mem_dt();
@@ -637,26 +629,12 @@ static void __init early_reserve_mem(void)
size_32 = be32_to_cpup(reserve_map_32++);
if (size_32 == 0)
break;
- /* skip if the reservation is for the blob */
- if (base_32 == self_base && size_32 == self_size)
- continue;
DBG("reserving: %x -> %x\n", base_32, size_32);
memblock_reserve(base_32, size_32);
}
return;
}
#endif
- DBG("Processing reserve map\n");
-
- /* Handle the reserve map in the fdt blob if it exists */
- while (1) {
- base = be64_to_cpup(reserve_map++);
- size = be64_to_cpup(reserve_map++);
- if (size == 0)
- break;
- DBG("reserving: %llx -> %llx\n", base, size);
- memblock_reserve(base, size);
- }
}
void __init early_init_devtree(void *params)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 4129f74..051be4c 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -492,9 +492,25 @@ static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname,
*/
void __init early_init_fdt_scan_reserved_mem(void)
{
+ int n;
+ u64 base, size;
+
if (!initial_boot_params)
return;
+ /* Reserve the dtb region */
+ early_init_dt_reserve_memory_arch(__pa(initial_boot_params),
+ fdt_totalsize(initial_boot_params),
+ 0);
+
+ /* Process header /memreserve/ fields */
+ for (n = 0; ; n++) {
+ fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
+ if (!size)
+ break;
+ early_init_dt_reserve_memory_arch(base, size, 0);
+ }
+
of_scan_flat_dt(__fdt_scan_reserved_mem, NULL);
fdt_init_reserved_mem();
}
--
1.9.1
next prev parent reply other threads:[~2014-04-23 1:22 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-23 1:18 [PATCH v2 00/21] FDT clean-ups and libfdt support Rob Herring
2014-04-23 1:18 ` [PATCH v2 01/21] mips: octeon: convert to use unflatten_and_copy_device_tree Rob Herring
2014-04-23 1:18 ` [PATCH v2 02/21] mips: lantiq: copy built-in DTB out of init section Rob Herring
2014-04-23 1:18 ` [PATCH v2 03/21] mips: xlp: " Rob Herring
2014-04-23 1:18 ` [PATCH v2 04/21] mips: ralink: convert to use unflatten_and_copy_device_tree Rob Herring
2014-04-23 1:18 ` [PATCH v2 05/21] ARM: dt: use default early_init_dt_alloc_memory_arch Rob Herring
2014-04-23 1:18 ` [PATCH v2 06/21] c6x: convert fdt pointers to opaque pointers Rob Herring
2014-04-24 14:21 ` Mark Salter
2014-04-23 1:18 ` [PATCH v2 07/21] mips: " Rob Herring
2014-04-23 1:18 ` [PATCH v2 08/21] of/fdt: consolidate built-in dtb section variables Rob Herring
2014-04-23 1:18 ` [PATCH v2 09/21] of/fdt: remove some unneeded includes Rob Herring
2014-04-23 1:18 ` [PATCH v2 10/21] of/fdt: remove unused of_scan_flat_dt_by_path Rob Herring
2014-04-23 1:18 ` [PATCH v2 11/21] of/fdt: update of_get_flat_dt_prop in prep for libfdt Rob Herring
2014-04-23 1:18 ` [PATCH v2 12/21] of/fdt: Convert FDT functions to use libfdt Rob Herring
2014-04-23 1:18 ` [PATCH v2 13/21] of/fdt: use libfdt accessors for header data Rob Herring
2014-04-23 1:18 ` [PATCH v2 14/21] of/fdt: create common debugfs Rob Herring
2014-04-23 13:52 ` Michal Simek
2014-04-23 1:18 ` Rob Herring [this message]
2014-05-01 16:27 ` [PATCH v2 15/21] of/fdt: move memreserve and dtb memory reservations into core Catalin Marinas
2014-04-23 1:18 ` [PATCH v2 16/21] of/fdt: fix phys_addr_t related print size warnings Rob Herring
2014-04-23 1:18 ` [PATCH v2 17/21] of/fdt: introduce of_get_flat_dt_size Rob Herring
2014-04-23 13:45 ` Michal Simek
2014-04-23 1:18 ` [PATCH v2 18/21] powerpc: use libfdt accessors for header data Rob Herring
2014-04-23 13:48 ` Michal Simek
2014-04-23 14:05 ` Rob Herring
2014-04-23 14:21 ` Michal Simek
2014-04-23 1:18 ` [PATCH v2 19/21] x86: use FDT accessors for FDT blob " Rob Herring
2014-04-23 1:18 ` [PATCH v2 20/21] of/fdt: convert initial_boot_params to opaque pointer Rob Herring
2014-04-23 1:18 ` [PATCH v2 21/21] of: push struct boot_param_header and defines into powerpc Rob Herring
2014-04-28 1:37 ` Benjamin Herrenschmidt
2014-04-23 14:22 ` [PATCH v2 00/21] FDT clean-ups and libfdt support Michal Simek
2014-04-23 21:04 ` Max Filippov
2014-04-29 14:00 ` Grant Likely
2014-04-30 0:33 ` Stephen N Chivers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1398215901-25609-16-git-send-email-robherring2@gmail.com \
--to=robherring2@gmail.com \
--cc=benh@kernel.crashing.org \
--cc=catalin.marinas@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=grant.likely@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=paulus@samba.org \
--cc=robh@kernel.org \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).