Commit 0962e800 authored by Jeremy Kerr's avatar Jeremy Kerr Committed by Benjamin Herrenschmidt

powerpc/prom: Scan reserved-ranges node for memory reservations

Based on benh's proposal at
https://lists.ozlabs.org/pipermail/linuxppc-dev/2012-September/101237.html,
this change provides support for reserving memory from the
reserved-ranges node at the root of the device tree.

We just call memblock_reserve on these ranges for now.
Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent d5d8ec89
...@@ -559,6 +559,33 @@ void __init early_init_dt_setup_initrd_arch(unsigned long start, ...@@ -559,6 +559,33 @@ void __init early_init_dt_setup_initrd_arch(unsigned long start,
} }
#endif #endif
static bool __init early_reserve_mem_dt(void)
{
unsigned long i, len, dt_root;
const __be32 *prop;
dt_root = of_get_flat_dt_root();
prop = of_get_flat_dt_prop(dt_root, "reserved-ranges", &len);
if (!prop)
return false;
/* Each reserved range is an (address,size) pair, 2 cells each,
* totalling 4 cells per range. */
for (i = 0; i < len / (sizeof(*prop) * 4); i++) {
u64 base, size;
base = of_read_number(prop + (i * 4) + 0, 2);
size = of_read_number(prop + (i * 4) + 2, 2);
if (size)
memblock_reserve(base, size);
}
return true;
}
static void __init early_reserve_mem(void) static void __init early_reserve_mem(void)
{ {
u64 base, size; u64 base, size;
...@@ -574,6 +601,14 @@ static void __init early_reserve_mem(void) ...@@ -574,6 +601,14 @@ static void __init early_reserve_mem(void)
self_size = initial_boot_params->totalsize; self_size = initial_boot_params->totalsize;
memblock_reserve(self_base, self_size); memblock_reserve(self_base, self_size);
/*
* Try looking for reserved-regions property in the DT first; if
* it's present, it'll contain all of the necessary reservation
* info
*/
if (early_reserve_mem_dt())
return;
#ifdef CONFIG_BLK_DEV_INITRD #ifdef CONFIG_BLK_DEV_INITRD
/* then reserve the initrd, if any */ /* then reserve the initrd, if any */
if (initrd_start && (initrd_end > initrd_start)) if (initrd_start && (initrd_end > initrd_start))
......
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