From patchwork Thu Jul 4 07:35:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 809929 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1043094wru; Thu, 4 Jul 2024 00:40:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUYViRNdr4zre5Gwk7xXtpBzFkldR484297jhTC0TgitlRWh5aLRXPuM2D0EE3ZbAMd0+vXtfdPS3FK/LvmZ0YO X-Google-Smtp-Source: AGHT+IGxqy/9Lpc3YRm8Lmp1adqzVfsQ7E8IaUarvAWec+kETYxdbzZw66J90r7B7/nxWhHwVVRN X-Received: by 2002:a17:906:e9a:b0:a77:aa6f:a0d7 with SMTP id a640c23a62f3a-a77ba6fbcbfmr51593866b.26.1720078818958; Thu, 04 Jul 2024 00:40:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720078818; cv=none; d=google.com; s=arc-20160816; b=IqwMW4yI+VlfcTRG+N/9iXEsFdMP9fD4ado/uHXpgOw/1/V2hk4a8MI/ZaNWcPfxnL dXFNZWwLGD7GAaBdyqT/DGqezthA9i78KN+/qUp/H/R/RgUTyAi7KTb1Y76xnddkHOTL KIcmyLIIRvvW79p7bHFOCd3XOj7NIUrq/lBkkUbMnN64TcG3njZcu+XV5Fsms6PK9+EW /bVIaBvR/cbvcohhvEU5QvqjW7AI9XHfqWNZsgelQb7CYaG6gsb17IYZtXlsfWlmQ7iW 5ulLp/NmXZ0iPInslzjp5cGB471sJkIbqcP7Ucehjm8sckwv5LWyVAyJSzJcpouSUl2B AaSQ== 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=T4g6mjS7AwDvs6sGCSpe6eKi7780bolgQH2Wzbny/Eg=; fh=ez1zzjhC0XWyqTp7tWutqrA/nFdALDnQKrnQnXYhk5Q=; b=gVqc1MTgzHNA3/xS1HAixE7NSortcovDjXJYTdQl3kKqmsrXEVYwEhhy7cOQAEwHQH RbowDh1/DF7fy3p6MEICanrTCtl6Vl1SJrpXchfRIqF58wmT3d3DcIkAvPXXFpMYWc22 ZoWyHwbFRMgsmS5c+3TMyPzxjXIrhaZf0M7Dw1INtfJ0s2/aVtnz+yrljHqylWuEpBnP otZSoHCrdGAWsUctvNP9CYYJ9Qhanp6E5vt1BaUCot2mhc1eVKma3TVXuMwdECydQdRd Ionkb9NY9Dn6csbm0bQAPyjSCi0ZTFaZSanwXsA3t44HVwuVDmqvj3qMwilu1VrHMSnM gGEw==; 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 a640c23a62f3a-a7510330287si533134766b.541.2024.07.04.00.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jul 2024 00:40: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 9CCAC8891F; Thu, 4 Jul 2024 09:37:28 +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 EBF51888A9; Thu, 4 Jul 2024 09:37:27 +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 BE6DA8891F for ; Thu, 4 Jul 2024 09:37:25 +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 4BBF8367; Thu, 4 Jul 2024 00:37:50 -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 284C43F762; Thu, 4 Jul 2024 00:37:21 -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 22/48] lmb: init: initialise the lmb data structures during board init Date: Thu, 4 Jul 2024 13:05:18 +0530 Message-Id: <20240704073544.670249-23-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 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 V1: * Initialise the lmb structures as part of board init. * Initialise the lmb structure durint SPL init when enabled. common/board_r.c | 4 ++++ common/spl/spl.c | 4 ++++ include/lmb.h | 11 +++++++++++ lib/lmb.c | 20 ++++++++++++++++++++ 4 files changed, 39 insertions(+) diff --git a/common/board_r.c b/common/board_r.c index c823cd262f..1a5bb98218 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -611,6 +612,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..633dbd1234 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -686,6 +686,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2) SPL_SYS_MALLOC_SIZE); gd->flags |= GD_FLG_FULL_MALLOC_INIT; } + + if (IS_ENABLED(CONFIG_SPL_LMB)) + initr_lmb(); + if (!(gd->flags & GD_FLG_SPL_INIT)) { if (spl_init()) hang(); diff --git a/include/lmb.h b/include/lmb.h index d0c094107c..02891a14be 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -36,6 +36,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 bf6254f4fc..1534380969 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -739,3 +739,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; +}