From patchwork Fri Jan 9 23:11:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1417 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000434; bh=3Ns4hgzgDOEbrKZDujaNTfZjbPaN80ukxfxYmB6jsu0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Uf84HGitGtSq3apvuuGeMw1pS1tkONdEO++IfxIgUEgxqv+crw1MTlM74OT9oHffA eegVYTw7hvUGe+Lc0aoijb7Vu3bv/uDjIv60OMy4wbvu002sMkjsavsTj0nz/3MnOR 46/Z66RoMhGXE3I+Hwc252QTuH8HjZRc4tG/AEylTMTxRQzXORnO/oHLxLV3JWAIfv RA5gT6OHfeEn6fWkNlp5gOfV5eCzVZcVWqTco/s6mgyZ1qPMfJ5rxW5M2l+BIpR13i 6uaELSTn7z2b2Id9iwv6nhBIbm7+x/PL8h1EmZ0ZUxKz5mitFB0ME4sJSHjTD3ccj8 Yk44s0FcFHvWw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 239D06925B for ; Fri, 9 Jan 2026 16:13:54 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id pOIkxiSECPYD for ; Fri, 9 Jan 2026 16:13:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000431; bh=3Ns4hgzgDOEbrKZDujaNTfZjbPaN80ukxfxYmB6jsu0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=lEIp+C+Q7F2A5bmDyHoCOe38OgTZ1cmAU5MjpwwxgmIUhYb25AAf5LLQjEoLIdF7N VXrZK7bYWZoCjcZ35Xff7prtC9O2oStpCHHq+23C/rzrKPMbAAhmU+e3Vwpia1ORwZ cGz9oz1Jq43SoRCQBRrrBTMH4/W90dUVajZVOpWYIJs6+rKGNnymdBNTPHDw89IGWl u1G7JIjGoe8jCehU6NRJ4AIswHelDwcI+6GPEDtF2+FTGpkyKw7apUAtUxZrXDzYwL Uk2TcgAdY57W/fe6U9e+n4RJS5XZeQjK4DHVJuApBtBoFqVaEbzR4JGW4/w/YCPNKQ /MfOYHTxkScPw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 46DD569221 for ; Fri, 9 Jan 2026 16:13:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000429; bh=v6wvp2vxmvXAsvYEAC8GajVyBrRRIJSP4z5Nf9WB1cw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qm1hpJZKtamSNqsPz60G3t9w2mqaI1Iy0qih8Xa0Q0xuVSS3QSX6Pl1gY1BKls4Rn pFbH7drBEQJdgCLbUZmQbSBuq/DNhKepEtZ/N/vDxKo7jo5VGKVrJECnMe6JF8Z/Lr Jcj59zCrnePIQ6tEWcHSUAnsPPx1X5dqlkbJ+XJu1GwEfVMgEwN+mUOH4nfCNuagIz EhAg1GrqLJ735+vr3V8v0km8y73rsuaozlOit2wkni7KG1Cd5hTkfc2kbzQsIpARzz 0pHMYqIuJU3qN6xOyh5/DdXy4r9tmm3yZAakvmcn6xOV595pGpcLnJZy/fVHxsKRte 8JloSAzU8ccJQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1AE3369249; Fri, 9 Jan 2026 16:13:49 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id KaWep8fPRLgf; Fri, 9 Jan 2026 16:13:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000426; bh=sL5Ag6DqXn0ylXqnKTXJ123ZjT+7l1oOCRmmTkzW9TQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mVl8/tc5bIR+TkSWQAketeZh3R5b04WpaQevoCgGpShUkdrt4ssgmAYXcnx5N8HUH BLxFYjSJFyCb6ILDeFMokM0+I/zaFHSIk5eK0XOg0wciSKWJJqPhPdANYgsWWxQW98 G3PVNSH2HZwx73ykV+ceDBx7hoIkTobZjtzaNT21G+0SMUzhT03ED+xPI5ApXHYQfL MZMl5g3tbFo45accmKUgC+AKcNf1uHIDKf7WlqSwz2F24JW6XYSDjOGJFBZ8NqByDu dDlj2sEpbQDWOVeSn/j1dBUs2UEQnH5CRQp6lTOnLYqi4ZW8WRHDtujoYvhpy1za18 vcu2+acmDRCyQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 42DFD69221; Fri, 9 Jan 2026 16:13:46 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:30 -0700 Message-ID: <20260109231151.4056804-22-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: FXBAO3LLER7IJUAPM2JX4N6F5EHIVQXP X-Message-ID-Hash: FXBAO3LLER7IJUAPM2JX4N6F5EHIVQXP X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 21/32] boot: pxe: Move label_get_fdt_path() call to pxe_load_label() List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Move the FDT path lookup from label_process_fdt() to pxe_load_label(), calling it early just after determining if this is a FIT boot. This groups related path-resolution logic together in the caller. Update label_process_fdt() to take the fdtfile as a parameter instead of calling label_get_fdt_path() internally. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 05102914717..4cb14783c77 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -506,33 +506,24 @@ static int label_get_fdt_path(struct pxe_label *label, char **fdtfilep) * * @ctx: PXE context * @label: Label to process - * @fdt_argp: Updated to NULL if FDT retrieval fails or no FDT is specified + * @fdtfile: FDT file path to load (freed by this function), or NULL * Return: 0 if OK, -ENOMEM if out of memory, -ENOENT if FDT file specified * by "fdt" label could not be loaded */ static int label_load_fdt(struct pxe_context *ctx, struct pxe_label *label, - const char **fdt_argp) + char *fdtfile) { - char *fdtfile; ulong addr; int ret; - ret = label_get_fdt_path(label, &fdtfile); - if (ret) - return ret; - - if (!fdtfile) { - *fdt_argp = NULL; + if (!fdtfile) return 0; - } ret = get_relfile_envaddr(ctx, fdtfile, "fdt_addr_r", SZ_4K, (enum bootflow_img_t)IH_TYPE_FLATDT, &addr, NULL); free(fdtfile); if (ret < 0) { - *fdt_argp = NULL; - if (label->fdt) { printf("Skipping %s for failure retrieving FDT\n", label->name); @@ -704,6 +695,8 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) const char *conf_fdt_str; ulong conf_fdt = 0; char initrd_str[28] = ""; + char *fdtfile = NULL; + bool is_fit; int ret; if (label->localboot) { @@ -719,9 +712,21 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) return 0; } + /* Check for FIT case: FDT comes from FIT image, not a separate file */ + is_fit = label->fdt && label->kernel_label && + !strcmp(label->kernel_label, label->fdt); + + if (!is_fit) { + ret = label_get_fdt_path(label, &fdtfile); + if (ret) + return ret; + } + ret = pxe_load_files(ctx, label); - if (ret) + if (ret) { + free(fdtfile); return ret; + } /* for FIT, append the configuration identifier */ snprintf(fit_addr, sizeof(fit_addr), "%lx%s", ctx->kern_addr, @@ -757,13 +762,17 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) label->kernel_label, conf_fdt_str); /* Scenario 1: FIT with embedded FDT */ - if (label->fdt && !strcmp(label->kernel_label, label->fdt)) { + if (is_fit) { conf_fdt_str = fit_addr; - } else if (conf_fdt_str) { + } else if (fdtfile) { /* Scenario 2: load FDT file if fdt_addr_r is set */ - ret = label_load_fdt(ctx, label, &conf_fdt_str); + ret = label_load_fdt(ctx, label, fdtfile); if (ret) return ret; + conf_fdt_str = env_get("fdt_addr_r"); + } else { + /* No FDT specified, use fallback */ + conf_fdt_str = NULL; } /* Scenarios 3 and 4: fallback options */