From patchwork Wed Jul 24 06:02:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 814141 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2618731wro; Tue, 23 Jul 2024 23:07:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX9DeTUha7uWQPJ2qcxcthS9eOIc13flmS6xanm8nZtF6iTbSkL3quDMWjs1fNYWADUHQY3xmN8vcsk8n1PImX6 X-Google-Smtp-Source: AGHT+IHHnTNEFgkFTLmComL47nTe2D/ByuEFZmA/DYl/9GAudZ1gr9udEDjbYGSAOsK0A3mrxaj5 X-Received: by 2002:a5d:58e1:0:b0:368:6ab:ba69 with SMTP id ffacd0b85a97d-369bae13aecmr7861362f8f.28.1721801258925; Tue, 23 Jul 2024 23:07:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721801258; cv=none; d=google.com; s=arc-20160816; b=Q0+HB6r7c9fBYjyGgKFNkb4jRRoa3dQqLAmqSpn/AYoPbhZR/NzpMCLiPfYBFuQWib pJ0SwwdlqGC9IjQ10bH1wpe05AK4NylHO/HmtmFv7wQukyKNInBm8FUjl1sJygrBu3PX x1cVmAeZC0ks8bFSz8f1V5YlfL7BCKYcPlcU20QZmY6gF6FZ5Ye6VFojlrGcTlb9rv/A 1DRAQqRONiHivoUqQfJKgGnoXH0S1ZQGaOI7vf0mgjrSBxERRSfxjsWlkksIT5tqYcYa ucJjSo397b+oDGBBNti1via3rgAUteUkhV9/MhhBYWEnBsD+XG8KDroFCaUh+lecArS8 c7LA== 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=zXGyTbvxysGXkHd01Apm0CN7x02bU6QFGi2ACBGgW/8=; fh=eimiGswTlodK8yi2DcDfSicmKwvq5bxKQKpD+SkkTNY=; b=wpsc+0NN/DiWLxdbQuCvuorkJJBvKVsdnwbT/4csFCscc5BsoOKV+/DyBFLMzI+FZQ wGlZwGZk0xELfQ6LXtHL4QRUkt4IjRQU7BTbBEM4J06G7O81xrfN8+9Xv/d0i7p2a+7/ ncm1+4jZznBL9aipPpFayAKh1XnPs73HIXOYEiUkVG8VwBB7JarCMhZ1wTwwg0W6OP48 BFjz+lMlwnjNEPGaLNz0dVfOgbEJAytPBZIBaGxWMtkDUEJh4tehLejmnwmLqHqBkOl2 bBsBa77of1I46Ph41wZZk7U+8JVpvO/MWCYWF1+WaAhUyiBAhqZzBlZgl6tk5EEKCoUF X8aQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id ffacd0b85a97d-369e3661c11si1336340f8f.71.2024.07.23.23.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 23:07:38 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 E2D25888BE; Wed, 24 Jul 2024 08:04:20 +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 47CD88883D; Wed, 24 Jul 2024 08:04:20 +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.9 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_NONE,T_SPF_TEMPERROR autolearn=unavailable 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 446F8888AB for ; Wed, 24 Jul 2024 08:04:06 +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 3AD89106F; Tue, 23 Jul 2024 23:04:31 -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 23B163F766; Tue, 23 Jul 2024 23:04:00 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Marek Vasut , Mark Kettenis , Michal Simek , Patrick DELAUNAY , Patrice CHOTARD , Huan Wang , Angelo Dureghello , Daniel Schwierzeck , Thomas Chou , Rick Chen , Max Filippov , Sughosh Ganu Subject: [PATCH 16/40] lmb: allow lmb module to be used in SPL Date: Wed, 24 Jul 2024 11:32:00 +0530 Message-Id: <20240724060224.3071065-17-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240724060224.3071065-1-sughosh.ganu@linaro.org> References: <20240724060224.3071065-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 With the introduction of separate config symbols for the SPL phase of U-Boot, the condition checks need to be tweaked so that platforms that enable the LMB module in SPL are also able to call the LMB API's. Use the appropriate condition checks to achieve this. Signed-off-by: Sughosh Ganu --- Changes since rfc: * Replace conditional compilation of lmb code to an if (CONFIG_IS_ENABLED()) in store_block() and tftp_init_load_addr(). board/xilinx/common/board.c | 2 +- boot/bootm.c | 4 ++-- boot/image-board.c | 2 +- fs/fs.c | 4 ++-- lib/Makefile | 2 +- net/tftp.c | 40 ++++++++++++++++++------------------- net/wget.c | 4 ++-- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index 4056884400..f04c92a70f 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -665,7 +665,7 @@ int embedded_dtb_select(void) } #endif -#if defined(CONFIG_LMB) +#if IS_ENABLED(CONFIG_LMB) #ifndef MMU_SECTION_SIZE #define MMU_SECTION_SIZE (1 * 1024 * 1024) diff --git a/boot/bootm.c b/boot/bootm.c index 7b3fe551de..5ce84b73b5 100644 --- a/boot/bootm.c +++ b/boot/bootm.c @@ -239,7 +239,7 @@ static int boot_get_kernel(const char *addr_fit, struct bootm_headers *images, return 0; } -#ifdef CONFIG_LMB +#if CONFIG_IS_ENABLED(LMB) static void boot_start_lmb(void) { phys_addr_t mem_start; @@ -1048,7 +1048,7 @@ int bootm_run_states(struct bootm_info *bmi, int states) } } #endif -#if CONFIG_IS_ENABLED(OF_LIBFDT) && defined(CONFIG_LMB) +#if CONFIG_IS_ENABLED(OF_LIBFDT) && CONFIG_IS_ENABLED(LMB) if (!ret && (states & BOOTM_STATE_FDT)) { boot_fdt_add_mem_rsv_regions(images->ft_addr); ret = boot_relocate_fdt(&images->ft_addr, &images->ft_len); diff --git a/boot/image-board.c b/boot/image-board.c index 1f8c1ac69f..99ee7968ba 100644 --- a/boot/image-board.c +++ b/boot/image-board.c @@ -883,7 +883,7 @@ int image_setup_linux(struct bootm_headers *images) int ret; /* This function cannot be called without lmb support */ - if (!IS_ENABLED(CONFIG_LMB)) + if (!CONFIG_IS_ENABLED(LMB)) return -EFAULT; if (CONFIG_IS_ENABLED(OF_LIBFDT)) boot_fdt_add_mem_rsv_regions(*of_flat_tree); diff --git a/fs/fs.c b/fs/fs.c index 2c835eef86..3fb00590be 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -526,7 +526,7 @@ int fs_size(const char *filename, loff_t *size) return ret; } -#ifdef CONFIG_LMB +#if CONFIG_IS_ENABLED(LMB) /* Check if a file may be read to the given address */ static int fs_read_lmb_check(const char *filename, ulong addr, loff_t offset, loff_t len, struct fstype_info *info) @@ -567,7 +567,7 @@ static int _fs_read(const char *filename, ulong addr, loff_t offset, loff_t len, void *buf; int ret; -#ifdef CONFIG_LMB +#if CONFIG_IS_ENABLED(LMB) if (do_lmb_check) { ret = fs_read_lmb_check(filename, addr, offset, len, info); if (ret) diff --git a/lib/Makefile b/lib/Makefile index 81b503ab52..398c11726e 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -118,7 +118,7 @@ obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdtdec.o fdtdec_common.o obj-y += hang.o obj-y += linux_compat.o obj-y += linux_string.o -obj-$(CONFIG_LMB) += lmb.o +obj-$(CONFIG_$(SPL_)LMB) += lmb.o obj-y += membuff.o obj-$(CONFIG_REGEX) += slre.o obj-y += string.o diff --git a/net/tftp.c b/net/tftp.c index a199f4a6df..f841f6b701 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -82,9 +82,7 @@ static ulong tftp_block_wrap; static ulong tftp_block_wrap_offset; static int tftp_state; static ulong tftp_load_addr; -#ifdef CONFIG_LMB static ulong tftp_load_size; -#endif #ifdef CONFIG_TFTP_TSIZE /* The file size reported by the server */ static int tftp_tsize; @@ -160,19 +158,20 @@ static inline int store_block(int block, uchar *src, unsigned int len) ulong store_addr = tftp_load_addr + offset; void *ptr; -#ifdef CONFIG_LMB - ulong end_addr = tftp_load_addr + tftp_load_size; + if (CONFIG_IS_ENABLED(LMB)) { + ulong end_addr = tftp_load_addr + tftp_load_size; - if (!end_addr) - end_addr = ULONG_MAX; + if (!end_addr) + end_addr = ULONG_MAX; - if (store_addr < tftp_load_addr || - store_addr + len > end_addr) { - puts("\nTFTP error: "); - puts("trying to overwrite reserved memory...\n"); - return -1; + if (store_addr < tftp_load_addr || + store_addr + len > end_addr) { + puts("\nTFTP error: "); + puts("trying to overwrite reserved memory...\n"); + return -1; + } } -#endif + ptr = map_sysmem(store_addr, len); memcpy(ptr, src, len); unmap_sysmem(ptr); @@ -709,17 +708,18 @@ static void tftp_timeout_handler(void) /* Initialize tftp_load_addr and tftp_load_size from image_load_addr and lmb */ static int tftp_init_load_addr(void) { -#ifdef CONFIG_LMB - phys_size_t max_size; + if (CONFIG_IS_ENABLED(LMB)) { + phys_size_t max_size; - lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob); + lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob); - max_size = lmb_get_free_size(image_load_addr); - if (!max_size) - return -1; + max_size = lmb_get_free_size(image_load_addr); + if (!max_size) + return -1; + + tftp_load_size = max_size; + } - tftp_load_size = max_size; -#endif tftp_load_addr = image_load_addr; return 0; } diff --git a/net/wget.c b/net/wget.c index 7cf809a8ef..b8ea43e7f0 100644 --- a/net/wget.c +++ b/net/wget.c @@ -98,7 +98,7 @@ static inline int store_block(uchar *src, unsigned int offset, unsigned int len) ulong newsize = offset + len; uchar *ptr; - if (IS_ENABLED(CONFIG_LMB)) { + if (CONFIG_IS_ENABLED(LMB)) { ulong end_addr = image_load_addr + wget_load_size; if (!end_addr) @@ -496,7 +496,7 @@ void wget_start(void) debug_cond(DEBUG_WGET, "\nwget:Load address: 0x%lx\nLoading: *\b", image_load_addr); - if (IS_ENABLED(CONFIG_LMB)) { + if (CONFIG_IS_ENABLED(LMB)) { if (wget_init_load_size()) { printf("\nwget error: "); printf("trying to overwrite reserved memory...\n");