[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231204185409.19615-4-quic_obabatun@quicinc.com>
Date: Mon, 4 Dec 2023 10:54:06 -0800
From: Oreoluwa Babatunde <quic_obabatun@...cinc.com>
To: <catalin.marinas@....com>, <will@...nel.org>, <robh+dt@...nel.org>,
<frowand.list@...il.com>, <dinguyen@...nel.org>,
<chenhuacai@...nel.org>, <tsbogend@...ha.franken.de>,
<jonas@...thpole.se>, <stefan.kristiansson@...nalahti.fi>,
<shorne@...il.com>, <mpe@...erman.id.au>,
<ysato@...rs.sourceforge.jp>, <dalias@...c.org>,
<glaubitz@...sik.fu-berlin.de>, <richard@....at>,
<anton.ivanov@...bridgegreys.com>, <johannes@...solutions.net>,
<chris@...kel.net>, <jcmvbkbc@...il.com>
CC: <linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <devicetree@...r.kernel.org>,
<linux-arm-msm@...r.kernel.org>, <kernel@...cinc.com>,
Oreoluwa Babatunde <quic_obabatun@...cinc.com>
Subject: [RFC PATCH v2 3/6] of: resevred_mem: Delay allocation of memory for dynamic regions
Defer the allocation of memory for the dynamically-placed reserved
memory regions until after the statically-placed reserved memory
regions have been reserved or marked as nomap in memblock.
This is to avoid allocating from regions that will later turn out to
have been reserved by other nodes.
Signed-off-by: Oreoluwa Babatunde <quic_obabatun@...cinc.com>
---
drivers/of/fdt.c | 18 ++++++++++++++++--
drivers/of/of_private.h | 1 +
drivers/of/of_reserved_mem.c | 1 -
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 34223c249914..46adce306bbd 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -613,6 +613,8 @@ void __init fdt_scan_reserved_mem_reg_nodes(void)
static int __init fdt_scan_reserved_mem(void)
{
int node, child;
+ int dynamic_nodes_cnt = 0;
+ int dynamic_nodes[MAX_RESERVED_REGIONS];
const void *fdt = initial_boot_params;
node = fdt_path_offset(fdt, "/reserved-memory");
@@ -634,8 +636,20 @@ static int __init fdt_scan_reserved_mem(void)
uname = fdt_get_name(fdt, child, NULL);
err = __reserved_mem_reserve_reg(child, uname);
- if (err == -ENOENT && of_get_flat_dt_prop(child, "size", NULL))
- __reserved_mem_alloc_size(child, uname);
+
+ if (err == -ENOENT && of_get_flat_dt_prop(child, "size", NULL)) {
+ dynamic_nodes[dynamic_nodes_cnt] = child;
+ dynamic_nodes_cnt++;
+ }
+ }
+
+ for (int i = 0; i < dynamic_nodes_cnt; i++) {
+ const char *uname;
+
+ child = dynamic_nodes[i];
+ uname = fdt_get_name(fdt, child, NULL);
+
+ __reserved_mem_alloc_size(child, uname);
}
return 0;
}
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index f38397c7b582..57694a704b00 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -36,6 +36,7 @@ struct alias_prop {
#endif
#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
+#define MAX_RESERVED_REGIONS 64
extern struct mutex of_mutex;
extern raw_spinlock_t devtree_lock;
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 8bd8bbc3aaec..d62f1956024c 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -26,7 +26,6 @@
#include "of_private.h"
-#define MAX_RESERVED_REGIONS 64
static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS];
static int reserved_mem_count;
--
2.17.1
Powered by blists - more mailing lists