[Concept,24/32] boot: pxe: Drop fdtoverlay_addr_r check in label_boot_fdtoverlay()

Message ID 20260109231151.4056804-25-sjg@u-boot.org
State New
Headers
Series boot: pxe: Refactor into separate load/setup phases |

Commit Message

Simon Glass Jan. 9, 2026, 11:11 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Remove the upfront check for fdtoverlay_addr_r environment variable.
If it doesn't exist, get_relfile_envaddr() will reserve an address
using LMB.

Also use the address returned by get_relfile_envaddr() for mapping the
overlay blob, rather than re-reading from the environment variable.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 boot/pxe_utils.c | 13 +------------
 test/boot/pxe.c  | 13 ++++++++-----
 2 files changed, 9 insertions(+), 17 deletions(-)
  

Patch

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 2084bb3e9bf..b269ef13f5a 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -307,23 +307,12 @@  static void label_boot_fdtoverlay(struct pxe_context *ctx,
 				  struct pxe_label *label)
 {
 	char *fdtoverlay = label->fdtoverlays;
-	char *fdtoverlay_addr_env;
-	ulong fdtoverlay_addr;
 	int err;
 
 	err = fdt_check_header(ctx->fdt);
 	if (err)
 		return;
 
-	/* Get the specific overlay loading address */
-	fdtoverlay_addr_env = env_get("fdtoverlay_addr_r");
-	if (!fdtoverlay_addr_env) {
-		printf("Invalid fdtoverlay_addr_r for loading overlays\n");
-		return;
-	}
-
-	fdtoverlay_addr = hextoul(fdtoverlay_addr_env, NULL);
-
 	/* Cycle over the overlay files and apply them in order */
 	do {
 		struct fdt_header *blob;
@@ -362,7 +351,7 @@  static void label_boot_fdtoverlay(struct pxe_context *ctx,
 		/* Resize main fdt */
 		fdt_shrink_to_minimum(ctx->fdt, 8192);
 
-		blob = map_sysmem(fdtoverlay_addr, 0);
+		blob = map_sysmem(addr, 0);
 		err = fdt_check_header(blob);
 		if (err) {
 			printf("Invalid overlay %s, skipping\n",
diff --git a/test/boot/pxe.c b/test/boot/pxe.c
index 365aff9f37a..7132d318c56 100644
--- a/test/boot/pxe.c
+++ b/test/boot/pxe.c
@@ -611,8 +611,8 @@  PXE_TEST_ARGS(pxe_test_errors_norun, UTF_CONSOLE | UTF_MANUAL,
  * Test overlay loading when fdtoverlay_addr_r is not set
  *
  * This tests that when a label has fdtoverlays but fdtoverlay_addr_r is not
- * set, the overlay loading is skipped with an appropriate warning message,
- * but the FDT is still loaded successfully.
+ * set, overlay loading is attempted via LMB allocation. The FDT is still
+ * loaded successfully even if overlays fail to load.
  */
 static int pxe_test_overlay_no_addr_norun(struct unit_test_state *uts)
 {
@@ -676,13 +676,16 @@  static int pxe_test_overlay_no_addr_norun(struct unit_test_state *uts)
 	ut_assertok(fdt_check_header(fdt));
 
 	/*
-	 * Check console output - FDT loaded, but overlays skipped with
-	 * warning about missing fdtoverlay_addr_r
+	 * Check console output - FDT loaded, overlays attempted via LMB
+	 * allocation but fail since test environment cannot load them
 	 */
 	ut_assert_nextline("Retrieving file: /vmlinuz");
 	ut_assert_nextline("Retrieving file: /initrd.img");
 	ut_assert_nextline("Retrieving file: /dtb/board.dtb");
-	ut_assert_nextline("Invalid fdtoverlay_addr_r for loading overlays");
+	ut_assert_nextline("Retrieving file: /dtb/overlay1.dtbo");
+	ut_assert_nextline("Failed loading overlay /dtb/overlay1.dtbo");
+	ut_assert_nextline("Retrieving file: /dtb/overlay2.dtbo");
+	ut_assert_nextline("Failed loading overlay /dtb/overlay2.dtbo");
 	ut_assert_console_end();
 
 	/* Clean up */