From patchwork Wed Jul 24 06:02:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 814146 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2619059wro; Tue, 23 Jul 2024 23:08:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUVpt4ItedH9hbJyVhP3D34EKBKRt+zDwBocpAdrYPDzs6bJoSOoBgehuRbYoknc7edaYUsJVaGss5RUyHzkauC X-Google-Smtp-Source: AGHT+IGTJsdE85JtDg/aC/Kj4lq4ZVbtNYc+6hjtHfu+iYElkeNihWo4sf/G8GMtBjjZao3zx3Pg X-Received: by 2002:adf:e54b:0:b0:368:3751:de3 with SMTP id ffacd0b85a97d-369f5b45f3bmr702515f8f.31.1721801334855; Tue, 23 Jul 2024 23:08:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721801334; cv=none; d=google.com; s=arc-20160816; b=n7dpPgMxBEILiRNcH4JqBz/5k5bEECD19CU5pZqqpHtH5+Gn763e4K+SAm62OUDfgI x5RsCW2vXdFlM0etXJhswuMl2MrWvuQOU8MP9NMa53cUAsnum3nJlGAn8zm1ysxZNCNp CGuONmdHvH7DjTvL8cCJveKXIreSz76WUz+jWsJ5LNsuCvE+UsgUhd2lKMx5BJIINuf1 Jz/fvHuOykb8DdpnMi0ftVa/dcN/qtJrUrEK7hZ4EaF/Eucnh87Wr+hLZL/PvGaIhlAt acMHjRmRHDepOU1sVk0/UyFq2wbCxoPtt1e+tFdpGHxDcBuyZBanXe3epJoYZqvH3KYo vKgg== 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=ylnLOhPnPWGNwRoo0tcAbpk7D1xTwGfXiVm/NIW+30s=; fh=eimiGswTlodK8yi2DcDfSicmKwvq5bxKQKpD+SkkTNY=; b=dKeYcdJfiMZAZZyZH3ESKTHW8ML/1IABDdSy6w+f6rAPiZATSDVZFQEKqpBGt7Z+Jl uqVVHi3qeMtOHwtc7gcNv69lcO3UL6zpr6cwj6YraoeCXkct7e8RLXAegRwhjzJdmg8C /AVqblQd3hsH8SFl/MVZMZU0SHZZGMhBTsEy/d1udXcT/gzX4GtBpIhvCVfD9EybmSVn APZxDLwbcDSCTmthq7HKII3o5eodRVbKmV6TFNnPkOpd4ImJ6jr5EM23aoHjlo/o06yF EdresfCA0s6KdWF+YBluv1tR2cjRw9q0Dj49jztpfh2XiuopKgQ3Qo/lLZS5onEWKJIz ecRw==; 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-369e3662221si1372886f8f.196.2024.07.23.23.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 23:08:54 -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 0191A8890D; Wed, 24 Jul 2024 08:04:49 +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 4BF208891C; Wed, 24 Jul 2024 08:04:48 +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=ham 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 6938788901 for ; Wed, 24 Jul 2024 08:04:37 +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 557ED106F; Tue, 23 Jul 2024 23:05:02 -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 437B93F766; Tue, 23 Jul 2024 23:04:32 -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 22/40] lmb: init: initialise the lmb data structures during board init Date: Wed, 24 Jul 2024 11:32:06 +0530 Message-Id: <20240724060224.3071065-23-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 The memory map maintained by the LMB module is now persistent and global. This memory map is being maintained through the alloced list structure which can be extended at runtime -- there is one list for the available memory, and one for the used memory. Allocate and initialise these lists during the board init. Signed-off-by: Sughosh Ganu --- Changes since rfc: None common/board_r.c | 4 ++++ common/spl/spl.c | 3 +++ include/lmb.h | 11 +++++++++++ lib/lmb.c | 20 ++++++++++++++++++++ 4 files changed, 38 insertions(+) diff --git a/common/board_r.c b/common/board_r.c index d4ba245ac6..eaf9b40ec0 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -610,6 +611,9 @@ static init_fnc_t init_sequence_r[] = { #ifdef CONFIG_CLOCKS set_cpu_clk_info, /* Setup clock information */ #endif +#if CONFIG_IS_ENABLED(LMB) + initr_lmb, +#endif #ifdef CONFIG_EFI_LOADER efi_memory_init, #endif diff --git a/common/spl/spl.c b/common/spl/spl.c index 7794ddccad..38ac0608bb 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -723,6 +723,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2) IS_ENABLED(CONFIG_SPL_ATF)) dram_init_banksize(); + if (IS_ENABLED(CONFIG_SPL_LMB)) + initr_lmb(); + if (CONFIG_IS_ENABLED(PCI) && !(gd->flags & GD_FLG_DM_DEAD)) { ret = pci_init(); if (ret) diff --git a/include/lmb.h b/include/lmb.h index 2d8f9a6b71..cc4cf9f3c8 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -37,6 +37,17 @@ struct lmb_region { enum lmb_flags flags; }; +/** + * initr_lmb() - Initialise the LMB lists + * + * Initialise the LMB lists needed for keeping the memory map. There + * are two lists, in form of alloced list data structure. One for the + * available memory, and one for the used memory. + * + * Return: 0 on success, -ve on error + */ +int initr_lmb(void); + /** * lmb_add_memory() - Add memory range for LMB allocations * diff --git a/lib/lmb.c b/lib/lmb.c index 5afdfc32fb..5baa5c4c52 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -783,3 +783,23 @@ int lmb_mem_regions_init(void) return 0; } + +/** + * initr_lmb() - Initialise the LMB lists + * + * Initialise the LMB lists needed for keeping the memory map. There + * are two lists, in form of alloced list data structure. One for the + * available memory, and one for the used memory. + * + * Return: 0 on success, -ve on error + */ +int initr_lmb(void) +{ + int ret; + + ret = lmb_mem_regions_init(); + if (ret) + printf("Unable to initialise the LMB data structures\n"); + + return ret; +}