kboot: Postpone setting of /memory

Postpone the setting of the /memory node so that any allocations made
in course of the devicetree prep (e.g. the SIO reservations allocated
from the top of memory) are reflected in the usable memory span that's
set on the /memory node.

Signed-off-by: Martin Povišer <povik@cutebit.org>
This commit is contained in:
Martin Povišer 2023-04-26 20:30:34 +02:00 committed by Hector Martin
parent 9f12d5b3ff
commit 94cf41e124

View file

@ -2071,8 +2071,6 @@ int kboot_prepare_dt(void *fdt)
return -1;
if (dt_set_serial_number())
return -1;
if (dt_set_memory())
return -1;
if (dt_set_cpus())
return -1;
if (dt_set_mac_addresses())
@ -2108,6 +2106,14 @@ int kboot_prepare_dt(void *fdt)
return 1;
#endif
/*
* Set the /memory node late since we might be allocating from the top of memory
* in one of the above devicetree prep functions, and we want an up-to-date value
* for the usable memory span to make it into the devicetree.
*/
if (dt_set_memory())
return -1;
if (fdt_pack(dt))
bail("FDT: fdt_pack() failed\n");