From 94cf41e1246c1cc2c097a88e0cc4054c72fcd77e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Wed, 26 Apr 2023 20:30:34 +0200 Subject: [PATCH] kboot: Postpone setting of /memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/kboot.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/kboot.c b/src/kboot.c index df92fb06..00598c46 100644 --- a/src/kboot.c +++ b/src/kboot.c @@ -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");