[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1482113266-13207-3-git-send-email-fancer.lancer@gmail.com>
Date: Mon, 19 Dec 2016 05:07:27 +0300
From: Serge Semin <fancer.lancer@...il.com>
To: ralf@...ux-mips.org, paul.burton@...tec.com, rabinv@...s.com,
matt.redfearn@...tec.com, james.hogan@...tec.com,
alexander.sverdlin@...ia.com, robh+dt@...nel.org,
frowand.list@...il.com
Cc: Sergey.Semin@...latforms.ru, linux-mips@...ux-mips.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
Serge Semin <fancer.lancer@...il.com>
Subject: [PATCH 02/21] MIPS memblock: Add dts mem and reserved-mem callbacks
In order to get a structured table of platform devices, it is
widespread amongst modern systems to use fdt'es.
MIPS should support one as well. Particularly /memory/ and
/reserved-memory/ should be analyzed and corresponding regions
registered with memblock subsystem.
Signed-off-by: Serge Semin <fancer.lancer@...il.com>
---
arch/mips/kernel/prom.c | 32 ++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c
index 5fcec30..f21eb8c 100644
--- a/arch/mips/kernel/prom.c
+++ b/arch/mips/kernel/prom.c
@@ -17,6 +17,7 @@
#include <linux/of.h>
#include <linux/of_fdt.h>
#include <linux/of_platform.h>
+#include <linux/memblock.h>
#include <asm/bootinfo.h>
#include <asm/page.h>
@@ -41,7 +42,36 @@ char *mips_get_machine_name(void)
#ifdef CONFIG_USE_OF
void __init early_init_dt_add_memory_arch(u64 base, u64 size)
{
- return add_memory_region(base, size, BOOT_MEM_RAM);
+ /* Check whether specified region is well formed */
+ if (sanity_check_dt_memory(&base, &size))
+ return;
+
+ /* Memory region should be in boot_mem_map, so use the old method */
+ add_memory_region(base, size, BOOT_MEM_RAM);
+}
+
+int __init early_init_dt_reserve_memory_arch(phys_addr_t base,
+ phys_addr_t size, bool nomap)
+{
+ /*
+ * NOTE We don't use add_memory_region() method here, since fdt
+ * reserved-memory regions are declared within already added memory,
+ * while boot_mem_map consists of unique regions
+ */
+
+ /* Check whether region is free. If so just ignore it */
+ if (memblock_is_region_reserved(base, size)) {
+ pr_err("FDT reserve-node %08zx @ %pa overlaps in-use memory\n",
+ (size_t)size, &base);
+ return -EBUSY;
+ }
+
+ /* If it can be mapped, then just reserve the region */
+ if (!nomap)
+ return memblock_reserve(base, size);
+
+ /* Completely remove region if it shouldn't be mapped */
+ return memblock_remove(base, size);
}
void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
--
2.6.6
Powered by blists - more mailing lists