From patchwork Thu Jul 4 07:35:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 809918 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1042522wru; Thu, 4 Jul 2024 00:38:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWZ+qBF+9Z9UdcGdtUC7+v5wZ+TdL729Fejb8Dn0AxOsAn9gZBoSFQpTFGx9mvxdvPoJDGJbiaPHuAf8fHyzRE1 X-Google-Smtp-Source: AGHT+IHh0HlB54kgEZJWjQzRhG/QR8ln3lMwyqtP7bY52nhgFLXAqXpvcMuSZuZrEgXD1wV8ovnT X-Received: by 2002:a05:6402:40c8:b0:58b:d7f2:eef3 with SMTP id 4fb4d7f45d1cf-58e5965a9femr546815a12.12.1720078698581; Thu, 04 Jul 2024 00:38:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720078698; cv=none; d=google.com; s=arc-20160816; b=PNXRGTPjca8zXQ326Phwb5T90B70VLl+lLJu+6p33lk5Pc1I6g1rTUs79AsvBVxEKS shM2yeFD1x4PC/daWcN9upTQX0ROGWIEkIUCLOaHfSqWDRYPgOtaxhO0S3TurXc8tyEQ 8RBruYjHty7Xc/yzzqmkTBG4wZJtjZhulnpUJ9acB0KaZp46V/AwXrlZSkWpdC2O3zZp fH6RLYOleSEsdAWJnoM2fZ5MSKnXLGk4+IxqUQbKvn/WzlTtUd+M+iVHRwVof9S2z7IX cdrWnF9Cce67K3Pr34R/0uzl7rJ3952FezWeDMepwyQVfxTjQAOHy43pZf5cevDbPiEl zv+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=3QRWnehBQ2F+l84+dYJPVP/0OZfyowc2dfVqPuKyx80=; fh=ez1zzjhC0XWyqTp7tWutqrA/nFdALDnQKrnQnXYhk5Q=; b=IBkW0VYc76M38FZL3D2hf0aunD+X/DHaSixYgbV/eUZ/7ZawpEEg+Wymu7ypDXBb8F ui6wrXA+6ETvfxqYgJrmge0jdkTwoIKbLNDHkMy2YbWo7PX/r7g6KoQxIAe8L9pdlPEr cIEfYXJOsFBQNnScVmGla+K1yJzr1gahIu6CiHNfgXX2ij4HFxSwPCJubODTEiBe0Emb ywA3pfmKEspSDizN5/V9SryqaDyoIRerTUIlR0Q7MDSADl9lCzObGSYb85ZqcF9jiNro 3qyIOP+64TPl32NKn9MNxFsnrTyfQ+ghh+nZvJbQUBW3V5AmND3w4ujmACHlXQ6X+FJg 8+mQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-58bbabf4f2dsi2364188a12.585.2024.07.04.00.38.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jul 2024 00:38:18 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3DDA5888EF; Thu, 4 Jul 2024 09:36:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 4B983888EC; Thu, 4 Jul 2024 09:36:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 2F940888FD for ; Thu, 4 Jul 2024 09:36:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AE0AB367; Thu, 4 Jul 2024 00:37:09 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8A4B43F762; Thu, 4 Jul 2024 00:36:41 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Tom Rini , Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Marek Vasut , Mark Kettenis , Fabio Estevam , Michal Simek , Sughosh Ganu Subject: [RFC PATCH v2 11/48] lmb: pass a flag to image_setup_libfdt() for lmb reservations Date: Thu, 4 Jul 2024 13:05:07 +0530 Message-Id: <20240704073544.670249-12-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240704073544.670249-1-sughosh.ganu@linaro.org> References: <20240704073544.670249-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The image_setup_libfdt() function optionally calls the LMB API to reserve the region of memory occupied by the FDT blob. This was earlier determined through the presence of the pointer to the lmb structure, which is no longer present. Pass a flag to the image_setup_libfdt() function to indicate if the region occupied by the FDT blob is to be marked as reserved by the LMB module. Signed-off-by: Sughosh Ganu Reviewed-by: Simon Glass --- Changes since V1: * Use true/false identifiers for bool instead of 1/0 * Fix the argument passed to the function in arch/mips/lib/bootm.c arch/mips/lib/bootm.c | 2 +- boot/image-board.c | 2 +- boot/image-fdt.c | 7 +++---- cmd/elf.c | 2 +- include/image.h | 5 ++--- lib/efi_loader/efi_dt_fixup.c | 2 +- lib/efi_loader/efi_helper.c | 2 +- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c index 54d89e9cca..8fb3a3923f 100644 --- a/arch/mips/lib/bootm.c +++ b/arch/mips/lib/bootm.c @@ -247,7 +247,7 @@ static int boot_setup_fdt(struct bootm_headers *images) images->initrd_start = virt_to_phys((void *)images->initrd_start); images->initrd_end = virt_to_phys((void *)images->initrd_end); - return image_setup_libfdt(images, images->ft_addr, &images->lmb); + return image_setup_libfdt(images, images->ft_addr, true); } static void boot_prep_linux(struct bootm_headers *images) diff --git a/boot/image-board.c b/boot/image-board.c index e3cb418e3c..1f8c1ac69f 100644 --- a/boot/image-board.c +++ b/boot/image-board.c @@ -904,7 +904,7 @@ int image_setup_linux(struct bootm_headers *images) } if (CONFIG_IS_ENABLED(OF_LIBFDT) && of_size) { - ret = image_setup_libfdt(images, *of_flat_tree, lmb); + ret = image_setup_libfdt(images, *of_flat_tree, true); if (ret) return ret; } diff --git a/boot/image-fdt.c b/boot/image-fdt.c index 943a3477a1..7c3d66bad7 100644 --- a/boot/image-fdt.c +++ b/boot/image-fdt.c @@ -566,8 +566,7 @@ __weak int arch_fixup_fdt(void *blob) return 0; } -int image_setup_libfdt(struct bootm_headers *images, void *blob, - struct lmb *lmb) +int image_setup_libfdt(struct bootm_headers *images, void *blob, bool lmb) { ulong *initrd_start = &images->initrd_start; ulong *initrd_end = &images->initrd_end; @@ -667,7 +666,7 @@ int image_setup_libfdt(struct bootm_headers *images, void *blob, } /* Delete the old LMB reservation */ - if (lmb) + if (CONFIG_IS_ENABLED(LMB) && lmb) lmb_free(map_to_sysmem(blob), fdt_totalsize(blob)); ret = fdt_shrink_to_minimum(blob, 0); @@ -676,7 +675,7 @@ int image_setup_libfdt(struct bootm_headers *images, void *blob, of_size = ret; /* Create a new LMB reservation */ - if (lmb) + if (CONFIG_IS_ENABLED(LMB) && lmb) lmb_reserve(map_to_sysmem(blob), of_size); #if defined(CONFIG_ARCH_KEYSTONE) diff --git a/cmd/elf.c b/cmd/elf.c index 32b7462f92..df53c5b0cb 100644 --- a/cmd/elf.c +++ b/cmd/elf.c @@ -68,7 +68,7 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) log_debug("Setting up FDT at 0x%08lx ...\n", fdt_addr); flush(); - if (image_setup_libfdt(&img, (void *)fdt_addr, NULL)) + if (image_setup_libfdt(&img, (void *)fdt_addr, false)) return 1; } #endif diff --git a/include/image.h b/include/image.h index 8036eae15c..47fd80bef4 100644 --- a/include/image.h +++ b/include/image.h @@ -1018,11 +1018,10 @@ int image_decomp(int comp, ulong load, ulong image_start, int type, * * @images: Images information * @blob: FDT to update - * @lmb: Points to logical memory block structure + * @lmb: Flag indicating use of lmb for reserving FDT memory region * Return: 0 if ok, <0 on failure */ -int image_setup_libfdt(struct bootm_headers *images, void *blob, - struct lmb *lmb); +int image_setup_libfdt(struct bootm_headers *images, void *blob, bool lmb); /** * Set up the FDT to use for booting a kernel diff --git a/lib/efi_loader/efi_dt_fixup.c b/lib/efi_loader/efi_dt_fixup.c index 9886e6897c..9d017804ee 100644 --- a/lib/efi_loader/efi_dt_fixup.c +++ b/lib/efi_loader/efi_dt_fixup.c @@ -172,7 +172,7 @@ efi_dt_fixup(struct efi_dt_fixup_protocol *this, void *dtb, } fdt_set_totalsize(dtb, *buffer_size); - if (image_setup_libfdt(&img, dtb, NULL)) { + if (image_setup_libfdt(&img, dtb, false)) { log_err("failed to process device tree\n"); ret = EFI_INVALID_PARAMETER; goto out; diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c index 348612c3da..13e97fb741 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -513,7 +513,7 @@ efi_status_t efi_install_fdt(void *fdt) return EFI_OUT_OF_RESOURCES; } - if (image_setup_libfdt(&img, fdt, NULL)) { + if (image_setup_libfdt(&img, fdt, false)) { log_err("ERROR: failed to process device tree\n"); return EFI_LOAD_ERROR; }