From patchwork Fri Jan 9 23:11:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1414 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=1768000419; bh=7AdBBWFuB88mXPkMhxikE/BkeNTmK5+0CrST18/OTB8=; 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=sE+t/XUlk+MOYnd2WDeRgwJRJeg0HpBkpkq51Ns04pUuxqYmPJ9BSUMezVtip3rcY OoH9Z7XSguEVVsF5qh3oM9yc7569fZmTBGTctLJNExkcwp5zi8pNuSoKL6bbNqgKR6 GgZhqSdxtU6tMcZlFnmBSpV6OFdRkN66YEDFHTn50H9pqg+b2fwjYUrDWvAMR8rhwl y53rW4+TXBlwFEmqerxWjXlstbD3eoRbpZJGsNkw8M464Wd3OCs5CzjmtEOmiIdN9O psdg8mlysSQZJ05eyKpdC7KOyrhUMw1pZTtvA7Wj4+DbppY+aDcmf7+tKaOLkMcP1U rv6yePuw0huIw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B22E269240 for ; Fri, 9 Jan 2026 16:13:39 -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 gpR8_5eCu4aZ for ; Fri, 9 Jan 2026 16:13:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000419; bh=7AdBBWFuB88mXPkMhxikE/BkeNTmK5+0CrST18/OTB8=; 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=sE+t/XUlk+MOYnd2WDeRgwJRJeg0HpBkpkq51Ns04pUuxqYmPJ9BSUMezVtip3rcY OoH9Z7XSguEVVsF5qh3oM9yc7569fZmTBGTctLJNExkcwp5zi8pNuSoKL6bbNqgKR6 GgZhqSdxtU6tMcZlFnmBSpV6OFdRkN66YEDFHTn50H9pqg+b2fwjYUrDWvAMR8rhwl y53rW4+TXBlwFEmqerxWjXlstbD3eoRbpZJGsNkw8M464Wd3OCs5CzjmtEOmiIdN9O psdg8mlysSQZJ05eyKpdC7KOyrhUMw1pZTtvA7Wj4+DbppY+aDcmf7+tKaOLkMcP1U rv6yePuw0huIw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8B0A969218 for ; Fri, 9 Jan 2026 16:13:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000416; bh=fujWWgBopStXkPRLlw/FW0M6SJDn5Tb4Q1ZmmVloRhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K6h6+hj2eh6AdaKeOOyl237BybFHtUFLMr5GK64I5kCs3p9x5zJqaAYMLZ6ka0zkr FQR8ZpRLSJh6+K/nInN0+BkKmwuqksYgmiMjF57uiuetZRpaFYfQwFIkkNw8irlfuz 6hcdFLxTwQPkJYQJOpWtnuz8sTV7o5Psw3GQZoDHcicDwljlyYWm60oxd0OF1QRh3t CtFl/DXOoGkf1bC8YMa4szeTNqiC672KQrjr72bbSaJwo2WZzSiIs8BJCKIPPaEi8Q KvVFHmd/O5RpGPZVvjcouTPv4hs3nS+h2GSUGand8VcFj4niG0pD4IKyqlDor5GrSR FKn2tg60V7JPw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6B33769218; Fri, 9 Jan 2026 16:13:36 -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 xuSwlElyr1ZE; Fri, 9 Jan 2026 16:13:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000412; bh=NPnduS7H9Xr2jj22Z7Aov4QtloLGj5Nuw8s4EHzFRBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jqrUPROfyB1NsZYmt//dokJAccDID5RT4PD8i4Zfyh107Wmi5crDqcNcTTAVQjWWI ne484rXA1dsu3LocU0wW5H9lDMOZKSurSNWVbl42nWvb+heD8LAwYEjHQs/p22GtWo +tk62Se2qRL0qKWSd2nwR082WxXX4oiaJtjWY6f6VgJB0hHp2bi0mXfa+VmuKZ/9Rs gCmELjjSFdQxQQUnUGJQ9OecPLL5FjdrItAjxtuvlCHJ+FrAyQauw6dzp5fiIOi7t8 OnEHmdc6rSSDpNQqPmK0vfNt7sj/p6K0KMlfoYCiJVnnITduowbArtjxcBUbvPfacK ocGi7Vkn9/Bcg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A190E6923D; Fri, 9 Jan 2026 16:13:31 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:27 -0700 Message-ID: <20260109231151.4056804-19-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: K6CWHJUF6EZ3WQ4VKY6Y72WXKDB7OPNJ X-Message-ID-Hash: K6CWHJUF6EZ3WQ4VKY6Y72WXKDB7OPNJ 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 18/32] boot: pxe: Move fdt_addr_r check to caller of label_load_fdt() 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 check for whether fdt_addr_r is set from label_load_fdt() to the caller. This simplifies the function and makes the control flow clearer - the function is now only called when there's an FDT address to load to. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 73 +++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 0e335cb2fdd..f6ad3f905b9 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -503,8 +503,7 @@ static int label_get_fdt_path(struct pxe_label *label, char **fdtfilep) * label_load_fdt() - Load FDT file for the label * * If "fdt" or "fdtdir" is defined in the pxe file, retrieve the FDT blob - * from the server. This is only called when fdt_addr_r is set in the - * environment. + * from the server. * * If retrieval fails and an exact FDT file is specified with "fdt", an * error is returned. If "fdtdir" is used and retrieval fails, this returns @@ -512,7 +511,7 @@ 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 + * @fdt_argp: Updated to NULL if FDT retrieval fails or no FDT is specified * Return: 0 if OK, -ENOMEM if out of memory, -ENOENT if FDT file specified * by "fdt" label could not be loaded */ @@ -520,56 +519,48 @@ static int label_load_fdt(struct pxe_context *ctx, struct pxe_label *label, const char **fdt_argp) { char *fdtfile; + ulong addr; int ret; - /* if fdt label is defined then get fdt from server */ - if (*fdt_argp) { - ret = label_get_fdt_path(label, &fdtfile); - if (ret) - return ret; + ret = label_get_fdt_path(label, &fdtfile); + if (ret) + return ret; - if (fdtfile) { - ulong addr; - int err; + if (fdtfile) { + ret = get_relfile_envaddr(ctx, fdtfile, "fdt_addr_r", SZ_4K, + (enum bootflow_img_t)IH_TYPE_FLATDT, + &addr, NULL); - err = get_relfile_envaddr(ctx, fdtfile, "fdt_addr_r", - SZ_4K, - (enum bootflow_img_t)IH_TYPE_FLATDT, - &addr, NULL); - - free(fdtfile); - if (err < 0) { - *fdt_argp = NULL; - - if (label->fdt) { - printf("Skipping %s for failure retrieving FDT\n", - label->name); - return -ENOENT; - } - - if (label->fdtdir) { - printf("Skipping fdtdir %s for failure retrieving dts\n", - label->fdtdir); - } - } else { - ctx->fdt = map_sysmem(addr, 0); + free(fdtfile); + if (ret < 0) { + *fdt_argp = NULL; - if (label->kaslrseed) - label_boot_kaslrseed(ctx); + if (label->fdt) { + printf("Skipping %s for failure retrieving FDT\n", + label->name); + return -ENOENT; + } -#ifdef CONFIG_OF_LIBFDT_OVERLAY - if (label->fdtoverlays) - label_boot_fdtoverlay(ctx, label); -#endif + if (label->fdtdir) { + printf("Skipping fdtdir %s for failure retrieving dts\n", + label->fdtdir); } } else { - *fdt_argp = NULL; + ctx->fdt = map_sysmem(addr, 0); + + if (label->kaslrseed) + label_boot_kaslrseed(ctx); + + if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY) && + label->fdtoverlays) + label_boot_fdtoverlay(ctx, label); } + } else { + *fdt_argp = NULL; } return 0; } - /** * label_run_boot() - Set up the FDT and call the appropriate bootm/z/i command * @@ -773,7 +764,7 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) /* Scenario 1: FIT with embedded FDT */ if (label->fdt && !strcmp(label->kernel_label, label->fdt)) { conf_fdt_str = fit_addr; - } else { + } else if (conf_fdt_str) { /* Scenario 2: load FDT file if fdt_addr_r is set */ ret = label_load_fdt(ctx, label, &conf_fdt_str); if (ret)