[PATCH 2/2] of: reserved_mem: add config to extend dynamic reserved memory regions
From: Wandun Chen
Date: Thu Jun 04 2026 - 03:40:25 EST
From: Wandun Chen <chenwandun@xxxxxxxxxxx>
Nowadays, the dynamic reserved memory regions is 64 by default, If
the count of reserved memory regions defined in DTS bigger than 64,
only 64 reserved memory can be handled properly.
So add a config to configure the actual dynamic reserved memory
regions count instead of modify the code.
Signed-off-by: Wandun Chen <chenwandun@xxxxxxxxxxx>
---
drivers/of/Kconfig | 11 +++++++++++
drivers/of/of_private.h | 2 +-
drivers/of/of_reserved_mem.c | 2 +-
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 50697cc3b07e..d6496ec3765c 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -99,6 +99,17 @@ config OF_IRQ
config OF_RESERVED_MEM
def_bool OF_EARLY_FLATTREE
+config OF_RESERVED_MEM_DYNAMIC_REGIONS
+ int "Maximum count of the dynamic reserved memory regions"
+ depends on OF_RESERVED_MEM
+ default 64
+ range 1 256
+ help
+ Allows to define proper dynamic reserved memory regions number
+ according to DTS configuration.
+
+ If unsure, leave the default value "64".
+
config OF_RESOLVE
bool
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index 0ae16da066e2..6ad00798f39d 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -9,7 +9,7 @@
*/
#define FDT_ALIGN_SIZE 8
-#define MAX_RESERVED_REGIONS 64
+#define MAX_RESERVED_REGIONS CONFIG_OF_RESERVED_MEM_DYNAMIC_REGIONS
/**
* struct alias_prop - Alias property in 'aliases' node
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 27dc98aa9bf9..d1680fc4fb38 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -348,7 +348,7 @@ int __init fdt_scan_reserved_mem(void)
count++;
if (dynamic_nodes_cnt >= MAX_RESERVED_REGIONS) {
- pr_err_once("Reserved memory: reached MAX_RESERVED_REGIONS(%d)\n",
+ pr_err_once("Reserved memory: reached MAX_RESERVED_REGIONS(%d), try expanding CONFIG_OF_RESERVED_MEM_DYNAMIC_REGIONS.\n",
MAX_RESERVED_REGIONS);
continue;
}
--
2.43.0