On Fri, 09 Aug 2024 11:48:14 -0700, Oreoluwa Babatunde wrote: > The reserved_mem array is statically allocated with a size of > MAX_RESERVED_REGIONS(64). Therefore, if the number of reserved_mem > regions exceeds this size, there will not be enough space to store > all the data. > > Hence, extend the use of the static array by introducing a > dynamically allocated array based on the number of reserved memory > regions specified in the DT. > > On architectures such as arm64, memblock allocated memory is not > writable until after the page tables have been setup. Hence, the > dynamic allocation of the reserved_mem array will need to be done only > after the page tables have been setup. > > As a result, a temporary static array is still needed in the initial > stages to store the information of the dynamically-placed reserved > memory regions because the start address is selected only at run-time > and is not stored anywhere else. > It is not possible to wait until the reserved_mem array is allocated > because this is done after the page tables are setup and the reserved > memory regions need to be initialized before then. > > After the reserved_mem array is allocated, all entries from the static > array is copied over to the new array, and the rest of the information > for the statically-placed reserved memory regions are read in from the > DT and stored in the new array as well. > > Once the init process is completed, the temporary static array is > released back to the system because it is no longer needed. This is > achieved by marking it as __initdata. > > Signed-off-by: Oreoluwa Babatunde <quic_obabatun@xxxxxxxxxxx> > --- > drivers/of/of_reserved_mem.c | 68 +++++++++++++++++++++++++++++++++--- > 1 file changed, 64 insertions(+), 4 deletions(-) > Applied, thanks!