@@ -102,4 +102,17 @@ config OF_OVERLAY
config OF_NUMA
bool
+config OF_MAX_RESERVED_REGIONS
+ int "OF resvered_mem array size"
+ default "64"
+ range 1 64
+ help
+ The reserved_mem_array is used to store information about the dynamically
+ placed reserved memory regions before we are able to allocate the memory
+ needed to store all the reserved memory regions defined in the DT.
+ Because the amount of memory needed initially for this array could vary,
+ make the size of the reserved_mem_array configurable in an attempt to
+ save some memory when possible.
+ if unsure, leave as default value.
+
endif # OF
@@ -26,11 +26,10 @@
#include "of_private.h"
-#define MAX_RESERVED_REGIONS 64
-static struct reserved_mem reserved_mem_array[MAX_RESERVED_REGIONS];
-static struct reserved_mem *reserved_mem __refdata = reserved_mem_array;
+static struct reserved_mem reserved_mem_array[CONFIG_OF_MAX_RESERVED_REGIONS];
+static struct reserved_mem *reserved_mem = reserved_mem_array;
-static int total_reserved_mem_cnt = MAX_RESERVED_REGIONS;
+static int total_reserved_mem_cnt = CONFIG_OF_MAX_RESERVED_REGIONS;
static int reserved_mem_count;
static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
@@ -93,7 +92,7 @@ static int alloc_reserved_mem_array(void)
overlow_err:
memblock_free(new_array, alloc_size);
- total_reserved_mem_cnt = MAX_RESERVED_REGIONS;
+ total_reserved_mem_cnt = CONFIG_OF_MAX_RESERVED_REGIONS;
return -1;
}
Add code to make the size of reserved_mem_array a config option which can be modified based on user requirements. The reserved_mem_array is required during device bootup to store the information of the reserved memory regions that need to be dynamically allocated. After some time, this information is transferred to another array which is used to store all reserved memory regions, after which the reserved_mem_array will no longer be needed. Since the size required for the reserved_mem_array can vary and there is currently no way to free the memory afterwards, make the size of the array configurable in an attempt to save some memory. Signed-off-by: Oreoluwa Babatunde <quic_obabatun@quicinc.com> --- drivers/of/Kconfig | 13 +++++++++++++ drivers/of/of_reserved_mem.c | 9 ++++----- 2 files changed, 17 insertions(+), 5 deletions(-)