From patchwork Thu Sep 5 08:27:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 825614 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp186544wrb; Thu, 5 Sep 2024 01:28:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU/tN70q6ebwdjDbsHHml3RETlF7MEGwhVfZ21OE1bS39SMeCDDMW4kfVIoz+If0oQUifAU8A==@linaro.org X-Google-Smtp-Source: AGHT+IEqV2d3zejKgYpGH5ypBzjojPE8KiqZwuL7GDVuy7ua/vDpLIGdnXYdPCeyiXHCSthVApde X-Received: by 2002:a2e:be15:0:b0:2f4:510:10d9 with SMTP id 38308e7fff4ca-2f6108934d0mr209765941fa.34.1725524927383; Thu, 05 Sep 2024 01:28:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725524927; cv=none; d=google.com; s=arc-20240605; b=ElopQO8EF+5laa7JqmVKbFIgOCw3qHt2VFUjldWzA1bZBwG0FHYgaG3v1Ip/43X7QL VfsG6rrdVk2mTcDJyU23dWz36Af6jyUwi4q/V/E+Wt7QRQOSpDERudFlS61I7jnfXB1X /oTZnoO01KysUTVc+OxmK5KiJTlhW83w+j1wGmy/+lvYuVyKDPCNQLt+GkiGKrzPByr+ EE0erFVcWCyAWECs7Q+u6pY93cNRE/IKQgrxVIPaoFfZgWfv4T/W7/Fijny3oq7q261I 3cTJNKD5bDAmPsPrt0CV1TBDLauAVR3ahAxaRRFt7X8yIMP8jlbzW0+Q3QoqvSMljlAR sc5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=yt7jqlSufVEFQqd5Ck3pCbQCVaO8wMcuzMxwpAeV82E=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=dFCeXe6WiuRIKzTdHvBlzRpMPisgdFEBdY8aGf0EIdw0n/hs+pyWYWlUyDSzXCHymv 9uBfhFm1cWREWN/fzbq/tNr57m6jThHUfJPdeUdj3wUbl1IHcuXyAvMnrZKnpv8u5u6o wFNpo4oAN/YsFJ2XPxfm/a6jn86FUdojRd6q5SpvtSQ5lFF7Z4RV6a6+7UdP5xCy2LJI ZFPaygPJpNGDLdGqzgS5G2sR5KN6bu6ZdviKPVlJpUSUbxjFbK0VQn8o7rS1Dw9PKLVp IV5Y7ug+kZksrR0icXgWzIZKRMQTmHQuqi6he1Es28I7TpZYfkHvKcdCnXx+9hF9gJW2 /I3w==; 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 a640c23a62f3a-a8a61ff176asi123981566b.83.2024.09.05.01.28.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:28:47 -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 CDE9088C87; Thu, 5 Sep 2024 10:28:40 +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 B3A9C88BF2; Thu, 5 Sep 2024 10:28:39 +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_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 82DCB88C51 for ; Thu, 5 Sep 2024 10:28: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 83F61FEC; Thu, 5 Sep 2024 01:29:03 -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 9145F3F66E; Thu, 5 Sep 2024 01:28:34 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 01/16] lmb: add versions of the lmb API with flags Date: Thu, 5 Sep 2024 13:57:56 +0530 Message-Id: <20240905082811.1585467-2-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-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 LMB module is to be used as a backend for allocating and freeing up memory requested from other modules like EFI. These memory requests are different from the typical LMB reservations in that memory required by the EFI module cannot be overwritten, or re-requested. Add versions of the LMB API functions with flags for allocating and freeing up memory. The caller can then use these API's for specifying the type of memory that is required. For now, these functions will be used by the EFI memory module. Signed-off-by: Sughosh Ganu --- include/lmb.h | 6 ++++++ lib/lmb.c | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/include/lmb.h b/include/lmb.h index fc2daaa7bf..45a06c3b99 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -86,8 +86,13 @@ long lmb_reserve(phys_addr_t base, phys_size_t size); long lmb_reserve_flags(phys_addr_t base, phys_size_t size, enum lmb_flags flags); phys_addr_t lmb_alloc(phys_size_t size, ulong align); +phys_addr_t lmb_alloc_flags(phys_size_t size, ulong align, uint flags); phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr); +phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align, + phys_addr_t max_addr, uint flags); phys_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size); +phys_addr_t lmb_alloc_addr_flags(phys_addr_t base, phys_size_t size, + uint flags); phys_size_t lmb_get_free_size(phys_addr_t addr); /** @@ -103,6 +108,7 @@ phys_size_t lmb_get_free_size(phys_addr_t addr); int lmb_is_reserved_flags(phys_addr_t addr, int flags); long lmb_free(phys_addr_t base, phys_size_t size); +long lmb_free_flags(phys_addr_t base, phys_size_t size, uint flags); void lmb_dump_all(void); void lmb_dump_all_force(void); diff --git a/lib/lmb.c b/lib/lmb.c index 3ed570fb29..da6a1595cc 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -479,7 +479,7 @@ long lmb_add(phys_addr_t base, phys_size_t size) return lmb_add_region(lmb_rgn_lst, base, size); } -long lmb_free(phys_addr_t base, phys_size_t size) +static long __lmb_free(phys_addr_t base, phys_size_t size) { struct lmb_region *rgn; struct alist *lmb_rgn_lst = &lmb.used_mem; @@ -530,6 +530,17 @@ long lmb_free(phys_addr_t base, phys_size_t size) rgn[i].flags); } +long lmb_free(phys_addr_t base, phys_size_t size) +{ + return __lmb_free(base, size); +} + +long lmb_free_flags(phys_addr_t base, phys_size_t size, + __always_unused uint flags) +{ + return __lmb_free(base, size); +} + long lmb_reserve_flags(phys_addr_t base, phys_size_t size, enum lmb_flags flags) { struct alist *lmb_rgn_lst = &lmb.used_mem; @@ -613,6 +624,12 @@ phys_addr_t lmb_alloc(phys_size_t size, ulong align) return lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE); } +phys_addr_t lmb_alloc_flags(phys_size_t size, ulong align, uint flags) +{ + return __lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE, + flags); +} + phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr) { phys_addr_t alloc; @@ -626,6 +643,20 @@ phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr) return alloc; } +phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align, + phys_addr_t max_addr, uint flags) +{ + phys_addr_t alloc; + + alloc = __lmb_alloc_base(size, align, max_addr, flags); + + if (alloc == 0) + printf("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n", + (ulong)size, (ulong)max_addr); + + return alloc; +} + static phys_addr_t __lmb_alloc_addr(phys_addr_t base, phys_size_t size, enum lmb_flags flags) { @@ -660,6 +691,12 @@ phys_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size) return __lmb_alloc_addr(base, size, LMB_NONE); } +phys_addr_t lmb_alloc_addr_flags(phys_addr_t base, phys_size_t size, + uint flags) +{ + return __lmb_alloc_addr(base, size, flags); +} + /* Return number of bytes from a given address that are free */ phys_size_t lmb_get_free_size(phys_addr_t addr) { From patchwork Thu Sep 5 08:27:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 825615 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp186597wrb; Thu, 5 Sep 2024 01:28:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXw5iljcsnrQQiuCVrLA30c+zSp3s80gaEsaZ8qI8RRl1qIgfF5+i68Ux4Rkt5B0usBlL3q1Q==@linaro.org X-Google-Smtp-Source: AGHT+IHv+qU/3NLKiqnErEB/yL3uK43HgBledZGRqGVciamyFtf5iip/WvyfQyp64vA3Ju8VzoNr X-Received: by 2002:a05:6402:540f:b0:5c2:7741:7d82 with SMTP id 4fb4d7f45d1cf-5c3c1f8a2c0mr6174322a12.11.1725524936730; Thu, 05 Sep 2024 01:28:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725524936; cv=none; d=google.com; s=arc-20240605; b=O+/7uFPYAra/3ef1pqG+M8MEbhJFYS9MECDVM3hq5A4p8UUnjUkOHSsctl3KxhDUaG W1YsR7AoO7+SeHb/VHZ3tN2m/SWLYHxHTmePjG/GCInlbGQIMZFbKuqVQX+OLgVInFdZ ZjMNW740hnSDDUlc3PGWTSUB6FFdmyKRcYp/kcenseutJtDtcfBQq0oE30EMUDk0Ijcf 3X4zgFU4GwiPnpGi4A/ishd3CPydKNFc2XmxXKj8Fl3h5w2gMGLjG/WdxezQJ7HrtxRc BT/WxU6wd5/hBcKV+yB7NyEWNNRLesFO2YmIcjAKNWPuqKbDaXX2JlmONfev/yEu+z6C VTNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=YcOWo64A5Gy6DVo+7oiuW5wC7Xcfa5GGuBLUDPWkLBQ=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=Sd+GFL9GzD5RkE09aUmfPKl9cxlrdpASvGc/mQC7mEDCxEUdxoBrWZlLgtKBNaAlE/ IsAKWurw2lc9+6WijHvi2pPwCgJ1VxLQwqnXKKNwJdpfpoZ2cnuggA66eQee2ZiYceVk MK0X4ss1ujl8NGL4qyL1DHdO8FVg0VLbCOdEi14bkTwW4BC3cI1GvC0YBjTdQHsbndZF fiJajiq3HEuNcl0eQ/IgTyma3zzP7TGhB6PdMKGpREKYmYgcY+i8ElC8fe+lwWWH4BFO 0r0uOFjkUJhzhNZUmPaNBgP6GgeMMCYYsBqKbZL9em2qZ6R44uCEgUFOtiygHaj+Qamu zTgA==; 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 4fb4d7f45d1cf-5c3cc69a762si1148708a12.218.2024.09.05.01.28.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:28:56 -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 3644388CAC; Thu, 5 Sep 2024 10:28:43 +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 622BC88CA3; Thu, 5 Sep 2024 10:28:42 +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_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 6C90688BFF for ; Thu, 5 Sep 2024 10:28:40 +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 7193FFEC; Thu, 5 Sep 2024 01:29:06 -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 7F3743F66E; Thu, 5 Sep 2024 01:28:37 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 02/16] lmb: add a flag to allow suppressing memory map change notification Date: Thu, 5 Sep 2024 13:57:57 +0530 Message-Id: <20240905082811.1585467-3-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-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 Add a flag LMB_NONOTIFY that can be passed to the LMB API's for reserving memory. This will then result in no notification being sent from the LMB module for the changes to the LMB's memory map. Signed-off-by: Sughosh Ganu --- include/lmb.h | 1 + lib/lmb.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/lmb.h b/include/lmb.h index 45a06c3b99..ffba7e2889 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -23,6 +23,7 @@ enum lmb_flags { LMB_NONE = 0, LMB_NOMAP = BIT(1), LMB_NOOVERWRITE = BIT(2), + LMB_NONOTIFY = BIT(3), }; /** diff --git a/lib/lmb.c b/lib/lmb.c index da6a1595cc..419b31a651 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -30,7 +30,7 @@ static struct lmb lmb; static void lmb_print_region_flags(enum lmb_flags flags) { u64 bitpos; - const char *flag_str[] = { "none", "no-map", "no-overwrite" }; + const char *flag_str[] = { "none", "no-map", "no-overwrite", "no-notify" }; do { bitpos = flags ? fls(flags) - 1 : 0; From patchwork Thu Sep 5 08:27:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 825616 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp186657wrb; Thu, 5 Sep 2024 01:29:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUvbfaZD+or7fie32rtU13gybePLKX35tumzrsAglJ06MQHgsJg6Z/JJYPycREjsR6ee8RsCA==@linaro.org X-Google-Smtp-Source: AGHT+IH0o4S2skRnFfyjVwiNslMa+knJHZLcNlmWV1eot772taQPxHNKFT10gCqt0nX0uuAj/Mt0 X-Received: by 2002:a05:6402:27ce:b0:5c3:c530:e999 with SMTP id 4fb4d7f45d1cf-5c3c530eacfmr2528865a12.10.1725524947759; Thu, 05 Sep 2024 01:29:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725524947; cv=none; d=google.com; s=arc-20240605; b=I0s6mvFWOcwIHXIj+1AQC1x43USCIKh1C4/5uiAo6wBBt7Ov6LX7JXQ/8Nh1j1ZQxB 5xHAwTg1G88MipU9d80Pfb+P1yGhxCnQsxgCKBUvoZY7LM0feXQeIIhudGwdTd1N/SWv Xy7sJSeYXKBSPIxdFDDGcEB8JoxToL3xbaNyerxj0P98PRWGRmW/+pge4TXvxlPUVmul H1FM3gl/IHJmxfPFNA+RCgIRzAzVNkDQzuuSTPciDBBln6I+AxFlR9aoQV4Czn5lqVWh YUfADnvuqcfv2pG0U+V1fYqN9Q3bgT8rEAJxPWcWUZ3981fnQxm7p8v4UqYXR5pDOlrX TbjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=Zmngq2OPOFioj2zhj7VoP4GBTinIy1HcF4AwKGEQoJY=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=Xxr7AXdN/nPLj1mgRkgJpk5dNlpOBYu9eGPe8tCoxQQn1TrAkvWO1seskPQDlQREwG giSrc6SbIYbQQdBjTU4XPbkQdjRXc26kD+/JRWLtydbC0n7U7TnsITi0VVz1ikGKFg0P z4VYXcBr4TSwzDQovqlepaAJW5syDwtVU24qBXxqGrt+eLc8nAbZDIJgKThhkSjYJHQs 40acZuG7KwZZr5jSkEaQm3FIFt0/mxQF0e17Ka2LZQi3O64vSxmzJ7h2pFzzwY29gz4B x4C7yMEVgM4nyoMPQ9diHpwkc1bqCwmUTsOb7nt4S7A2OY5Ya+kTr0i0r0QxRIaEeyGl xM+g==; 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 4fb4d7f45d1cf-5c3cc6af817si1129785a12.499.2024.09.05.01.29.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:29:07 -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 96F2588C7A; Thu, 5 Sep 2024 10:28:47 +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 A4B2F88C7A; Thu, 5 Sep 2024 10:28:46 +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_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 58CE288CB0 for ; Thu, 5 Sep 2024 10:28:43 +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 5E7D7FEC; Thu, 5 Sep 2024 01:29: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 6C8813F66E; Thu, 5 Sep 2024 01:28:40 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 03/16] efi: memory: use the lmb API's for allocating and freeing memory Date: Thu, 5 Sep 2024 13:57:58 +0530 Message-Id: <20240905082811.1585467-4-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-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 Use the LMB API's for allocating and freeing up memory. With this, the LMB module becomes the common backend for managing non U-Boot image memory that might be requested by other modules. Signed-off-by: Sughosh Ganu --- lib/efi_loader/Kconfig | 1 + lib/efi_loader/efi_memory.c | 74 ++++++++++--------------------------- 2 files changed, 21 insertions(+), 54 deletions(-) diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 6ffefa9103..911d4c6bbe 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -18,6 +18,7 @@ config EFI_LOADER select DM_EVENT select EVENT_DYNAMIC select LIB_UUID + select LMB imply PARTITION_UUIDS select REGEX imply FAT diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index c6f1dd0945..90e07ed6a2 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -432,53 +433,6 @@ static efi_status_t efi_check_allocated(u64 addr, bool must_be_allocated) return EFI_NOT_FOUND; } -/** - * efi_find_free_memory() - find free memory pages - * - * @len: size of memory area needed - * @max_addr: highest address to allocate - * Return: pointer to free memory area or 0 - */ -static uint64_t efi_find_free_memory(uint64_t len, uint64_t max_addr) -{ - struct efi_mem_list *lmem; - - /* - * Prealign input max address, so we simplify our matching - * logic below and can just reuse it as return pointer. - */ - max_addr &= ~EFI_PAGE_MASK; - - list_for_each_entry(lmem, &efi_mem, link) { - struct efi_mem_desc *desc = &lmem->desc; - uint64_t desc_len = desc->num_pages << EFI_PAGE_SHIFT; - uint64_t desc_end = desc->physical_start + desc_len; - uint64_t curmax = min(max_addr, desc_end); - uint64_t ret = curmax - len; - - /* We only take memory from free RAM */ - if (desc->type != EFI_CONVENTIONAL_MEMORY) - continue; - - /* Out of bounds for max_addr */ - if ((ret + len) > max_addr) - continue; - - /* Out of bounds for upper map limit */ - if ((ret + len) > desc_end) - continue; - - /* Out of bounds for lower map limit */ - if (ret < desc->physical_start) - continue; - - /* Return the highest address in this map within bounds */ - return ret; - } - - return 0; -} - /** * efi_allocate_pages - allocate memory pages * @@ -493,6 +447,7 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type, efi_uintn_t pages, uint64_t *memory) { u64 len; + uint flags; efi_status_t ret; uint64_t addr; @@ -508,33 +463,35 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type, (len >> EFI_PAGE_SHIFT) != (u64)pages) return EFI_OUT_OF_RESOURCES; + flags = LMB_NOOVERWRITE | LMB_NONOTIFY; switch (type) { case EFI_ALLOCATE_ANY_PAGES: /* Any page */ - addr = efi_find_free_memory(len, -1ULL); + addr = (u64)lmb_alloc_flags(len, EFI_PAGE_SIZE, flags); if (!addr) return EFI_OUT_OF_RESOURCES; break; case EFI_ALLOCATE_MAX_ADDRESS: /* Max address */ - addr = efi_find_free_memory(len, *memory); + addr = (u64)lmb_alloc_base_flags(len, EFI_PAGE_SIZE, *memory, + flags); if (!addr) return EFI_OUT_OF_RESOURCES; break; case EFI_ALLOCATE_ADDRESS: if (*memory & EFI_PAGE_MASK) return EFI_NOT_FOUND; - /* Exact address, reserve it. The addr is already in *memory. */ - ret = efi_check_allocated(*memory, false); - if (ret != EFI_SUCCESS) - return EFI_NOT_FOUND; - addr = *memory; + + addr = (u64)lmb_alloc_addr_flags(*memory, len, flags); + if (!addr) + return EFI_OUT_OF_RESOURCES; break; default: /* UEFI doesn't specify other allocation types */ return EFI_INVALID_PARAMETER; } + addr = (u64)(uintptr_t)map_sysmem(addr, 0); /* Reserve that map in our memory maps */ ret = efi_add_memory_map_pg(addr, pages, memory_type, true); if (ret != EFI_SUCCESS) @@ -555,6 +512,9 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type, */ efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages) { + u64 len; + uint flags; + long status; efi_status_t ret; ret = efi_check_allocated(memory, true); @@ -568,6 +528,12 @@ efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages) return EFI_INVALID_PARAMETER; } + flags = LMB_NOOVERWRITE | LMB_NONOTIFY; + len = (u64)pages << EFI_PAGE_SHIFT; + status = lmb_free_flags(memory, len, flags); + if (status) + return EFI_NOT_FOUND; + ret = efi_add_memory_map_pg(memory, pages, EFI_CONVENTIONAL_MEMORY, false); if (ret != EFI_SUCCESS) From patchwork Thu Sep 5 08:27:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 825617 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp186701wrb; Thu, 5 Sep 2024 01:29:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWch2ta1KqYKp7Ro0CAlkDG5fF5MS1Tnq+6pgb3JF0ssPx/tVCfO0f3idxTJdNYAj31IHbMdg==@linaro.org X-Google-Smtp-Source: AGHT+IF1GhqSVFhyVRUSIWH4sH+sp5vrZCRszVsAWwvQKt4B15ZP/HTATRqsTveDIzDHyMxOUxJu X-Received: by 2002:a17:907:ea7:b0:a7d:89ac:9539 with SMTP id a640c23a62f3a-a8a42f8af35mr436662266b.7.1725524958070; Thu, 05 Sep 2024 01:29:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725524958; cv=none; d=google.com; s=arc-20240605; b=R5Pzrc22v4ihf30ZDgyqiKgxbiugf8/rUMHyWkEt6jlkuPu4Au72AMkrPi09FB7mZ1 +oAS/bpfERHd812+FFZQsrgToCU4AeeupZRqsZR8Qp/ZmyA5B6aJ8mbohiT0Jh6WcLW9 2q3mvLNcY5ZpMbJBrSEojVqlHKrR5omaFINPKLenQQ8fP6XUIlnRpMNFCeJ5OeNwDPyj BUoZNSsjYnACEy5u/2F2vhne9KaHJgqjywpBahzrLo04VdtLxPv2nDf5Ofy1HkxGQPzE HeI9+EDpXK21CLhK3G2KMOR0PtCsDj6v24qeEjMcXmMOX5vuZN9l4C9FHJp87RvEn4G6 gFLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=bf6P9OR/6upTzM1d7VuQgmwOVCxoqTTjick5IpFrRRk=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=V2DAGTcdYZL1E5CFYJ4dDg5+vk3UumpTfkHgEoGCyotWd3cZ9vRx19tMD7q3wCXr0v q7EdbVihQfvn/kCnpIflg050KWLwAZYnInWq0XESv0ebCiIpKi/8GVxFS604SQS1mERq S2It/8h51mwycgQZ8klr8qkHnE5RU2PH0y9su4G9MXJAZjLr8y71QCHFHXN1/u8kwokN nq4eVoY/z158YFQ0RMwYtJsIzfqu7KpRiQPh017QWrLojXjTncJYhRB8VHtRJjMCtny7 jyzi4B2czgsYrBbSDWeX+5xs/OdPGzHM2Cnyj9L2f/O+gBWy/II4ABVGdiCVz9YGIdYg ga8A==; 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 a640c23a62f3a-a8a623c3106si122897566b.490.2024.09.05.01.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:29:18 -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 094F988C98; Thu, 5 Sep 2024 10:28:51 +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 EEC2F88C9C; Thu, 5 Sep 2024 10:28: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.2 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 3E98088BFF for ; Thu, 5 Sep 2024 10:28:46 +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 4B7D8FEC; Thu, 5 Sep 2024 01:29:12 -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 59B793F66E; Thu, 5 Sep 2024 01:28:43 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 04/16] event: add event to notify lmb memory map changes Date: Thu, 5 Sep 2024 13:57:59 +0530 Message-Id: <20240905082811.1585467-5-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-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 Add an event which would be used for notifying changes in the LMB modules' memory map. This is to be used for having a synchronous view of the memory that is currently in use, and that is available for allocations. Signed-off-by: Sughosh Ganu --- common/event.c | 2 ++ include/event.h | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/common/event.c b/common/event.c index dda569d447..fc8002603c 100644 --- a/common/event.c +++ b/common/event.c @@ -48,6 +48,8 @@ const char *const type_name[] = { /* main loop events */ "main_loop", + + "lmb_map_update", }; _Static_assert(ARRAY_SIZE(type_name) == EVT_COUNT, "event type_name size"); diff --git a/include/event.h b/include/event.h index fb353ad623..fce7e96170 100644 --- a/include/event.h +++ b/include/event.h @@ -153,6 +153,14 @@ enum event_t { */ EVT_MAIN_LOOP, + /** + * @EVT_LMB_MAP_UPDATE: + * This event is triggered on an update to the LMB reserved memory + * region. This can be used to notify about any LMB memory allocation + * or freeing of memory having occurred. + */ + EVT_LMB_MAP_UPDATE, + /** * @EVT_COUNT: * This constants holds the maximum event number + 1 and is used when @@ -203,6 +211,12 @@ union event_data { oftree tree; struct bootm_headers *images; } ft_fixup; + + struct event_lmb_map_update { + u64 base; + u64 size; + u8 op; + } lmb_map; }; /** From patchwork Thu Sep 5 08:28: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: 825618 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp186760wrb; Thu, 5 Sep 2024 01:29:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUr/vahCvq332UPyrzuvmYbp5iDtjGGehAmp9kznT2baKo3a+9UfI0WxUkUdexHhFwXIWRojA==@linaro.org X-Google-Smtp-Source: AGHT+IEA8kwIV+VQZNx5S872iY8UtF8lq3j3L/vdQUxKkEOhy2eNJli9a7P0aj6LbCzuESpOrz7Z X-Received: by 2002:a05:6512:3ca3:b0:533:97b:e26e with SMTP id 2adb3069b0e04-53546a5de53mr13414963e87.0.1725524967927; Thu, 05 Sep 2024 01:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725524967; cv=none; d=google.com; s=arc-20240605; b=fY7ryYReUhnfCkbrj8bk9ulF55Y538r5SIP1TwN9kRMDcTyHCgb5y7CYhsDtLSJQXy NleYKODHJ7z0Ncv4cCBmQsyPn9afDG3hBJlMYlmoyWtlWtO05ercMjOSex5y4V+LsHyc CirlwdFQsxn5qnPFgyTKxkUxVNJPrYeVumjEhYrcy+vB7wG8FD5PRP0EvrPiT2UVaPbo z+p5KZU2ud1Z7fCTeg0st0h1RHVG8avRxPScihHqe5hKMQ7hbYTJLjggUhmFOJD1mK6c KrVHVV1rg2iKJxOfNA4FrikgnhU4heJvf+yll1qBYRmtp4OL1k+HkTHhuMX22lpWeaXQ F7LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=dj+brSJ4Xt/kx/a1xMwCkmQHgRCKQP6rA+9LVjI9odo=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=Lmjavp+v5c9zI0wTNxcTOl4kXzhO6E4qFl+8Sa0NVAF6MWOzm312gp/9MAg1efsDBq FUvsiseDXiwCJBcZIib7sw8iaXwEE8gYmb8FHAWbPU/M720MBX6aoEQX1wp7AsFiVGAT Mey//QrWTOsZNpQMpiDfKEKJATuovAQF9l4oIdZrK0XQyms3bEbOtFq1o+9RGNTxYjGe fdY0GYu6xMvhGYo6hBmg6saYmiar4dw0PEgqWP8Lit/2WeZlrREvE43dOou+y3Gwwa8q z5QW5O2x3atNcElnkEg9Sy86fD6lnhunp5A7nZlllSWtLwQWqs67CsL8JTnFhJnsYxAd nvcg==; 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-a8a6237945bsi115656466b.472.2024.09.05.01.29.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:29:27 -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 7859788CC5; Thu, 5 Sep 2024 10:28:52 +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 2317888C94; Thu, 5 Sep 2024 10:28:51 +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_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 2CB6888C51 for ; Thu, 5 Sep 2024 10:28:49 +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 396BF1063; Thu, 5 Sep 2024 01:29:15 -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 46B1C3F66E; Thu, 5 Sep 2024 01:28:46 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 05/16] lib: Kconfig: add a config symbol for getting lmb memory map updates Date: Thu, 5 Sep 2024 13:58:00 +0530 Message-Id: <20240905082811.1585467-6-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-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 Add a Kconfig symbol to enable getting updates on any memory map changes that might be done by the LMB module. This notification mechanism can then be used to have a synchronous view of allocated and free memory. Signed-off-by: Sughosh Ganu --- lib/Kconfig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/Kconfig b/lib/Kconfig index 5f282ecb54..2e73cda580 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -74,6 +74,17 @@ config HAVE_PRIVATE_LIBGCC config LIB_UUID bool +config MEM_MAP_UPDATE_NOTIFY + bool "Get notified of any changes to the LMB memory map" + depends on LMB && EFI_LOADER + select EVENT + default y + help + Enable this option to get notification on any changes to the + memory that is allocated or freed by the LMB module. This will + allow different modules that allocate memory or maintain a memory + map to have a synchronous view of available and allocated memory. + config RANDOM_UUID bool "GPT Random UUID generation" select LIB_UUID From patchwork Thu Sep 5 08:28:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 825619 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp186804wrb; Thu, 5 Sep 2024 01:29:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXya42zUzAjd2wycqJdYyi84pu27a3C/lbTouU6qHGl4wrRpCmfB7SIwJ9rjQH+ym6xjxgzyw==@linaro.org X-Google-Smtp-Source: AGHT+IHWFUu0S+Sqv6rm/9Sj9LUcuQX6LKe2vh3kTAA9cZswFyj/ik6r9MtxuZfEErWWZO8cmgFT X-Received: by 2002:a05:6402:1d51:b0:5c0:a8d0:8782 with SMTP id 4fb4d7f45d1cf-5c24377a939mr12638558a12.28.1725524976795; Thu, 05 Sep 2024 01:29:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725524976; cv=none; d=google.com; s=arc-20240605; b=KX4V+Kh+XPw317kVFsZvQCq0LZMjc3y7o+Gkeg50lhNAdw7I8UM2SsIbBZauLw7nsd uoW9255gXBkff8gGY/sofLrLXQqJgAfq7cQ9RNCizXVRXgBUW+zgWrYkZvEg+Og8yaxr ELyJgqV7Nro6ZrJaeQpNl4gombAecWpdEJSATjF1DYsmEe5R03BcQi0165fZnz+QuVTQ p9WKrmbzZMqWDTmqQMHJAAYv6mQNixQ6LNwfcoll7sN9a1c1MVy+anT742QI8yV41TAu c2NJ9lMyJGISuXjAt0yFv7r1Xc+czjbXqGbKnT0X96/mRc77ypy8mMDAp6evFr2eGCe7 WzPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=GzSW4VU9+fYhN/NA3Sd5uPm2n3Ymbbb4PQUQU3dgpAA=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=fmHE9tReNklURmSaBOBEb78gzgkndcGYTBgQLbtEnBM5+ytECfHRAlErH4h+ei7PPO a7up6oZTxxTVnjlU7owb/phS/4zQxOEn1CDTZzTMWTtp4MxBMVyLtdGuQomiHOMBF5Tn 35pX6S9xobUwJDMrZLyr05SENCEYoIQwJuE2xT1m5iOI2GKpyZSu74WKmnyhdQjQeDmL zZwPjsAKsSAy09yPnay63G3TkG/0ult+4sXASYbahaTF9FnsPgTNuXKS9kP1e4DW2XkD QkleBnrZ7kZdj4lpTeYdSnwg4n8iLp7OyfuGCECSgPR1FSr0JAyoeXsPAmOpKQ6ebMyJ mh3Q==; 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-5c3cc6b0da6si1141183a12.572.2024.09.05.01.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:29:36 -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 D0E0088C94; Thu, 5 Sep 2024 10:28:57 +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 2410888C91; Thu, 5 Sep 2024 10:28:56 +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_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 190BD88CC2 for ; Thu, 5 Sep 2024 10:28:52 +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 27174FEC; Thu, 5 Sep 2024 01:29:18 -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 342363F66E; Thu, 5 Sep 2024 01:28:48 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 06/16] add a function to check if an address is in RAM memory Date: Thu, 5 Sep 2024 13:58:01 +0530 Message-Id: <20240905082811.1585467-7-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-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 Add a function to check if a given address falls within the RAM address used by U-Boot. This will be used to notify other modules if the address gets allocated, so as to not get re-allocated by some other module. Signed-off-by: Sughosh Ganu --- common/board_r.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/board_r.c b/common/board_r.c index 4faaa20242..877ea3afd0 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -72,6 +72,11 @@ DECLARE_GLOBAL_DATA_PTR; ulong monitor_flash_len; +__weak bool __maybe_unused is_addr_in_ram(uintptr_t addr) +{ + return addr >= gd->ram_base && addr <= gd->ram_top; +} + __weak int board_flash_wp_on(void) { /* From patchwork Thu Sep 5 08:28:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 825620 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp186853wrb; Thu, 5 Sep 2024 01:29:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUuSbQAAgXFPclN0KtMg9KtkQagVAiahGjVPkjScnQy63i2welqqLZnc8V0SPzK+9KPE4X1jw==@linaro.org X-Google-Smtp-Source: AGHT+IHsdW0aRpkvwj6vVUI6207YBKZQYE1wWEXsYJ/WxogIle2BNl0FSFXrEXFjrHQ1f8n4eBlj X-Received: by 2002:a05:6402:42c5:b0:5c2:6f35:41af with SMTP id 4fb4d7f45d1cf-5c3c1fa0581mr5981240a12.16.1725524986696; Thu, 05 Sep 2024 01:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725524986; cv=none; d=google.com; s=arc-20240605; b=IdezrtR0Rf92eIZOpfbd2G/twlSjIHTYiBbXke1K8T0ZLY7oI2mcmkJpv20xn61ft9 R/jO1IWzRsxxJL8iCQ9jilE6R2n+Cu2sCW/PhMzXVWJZh5KXubm5UI6ivNUC/Gw99ytW LRUwLrDhIT2sgXIuVDxcNnuNFKqANPQIt7Zo1TRXSAbR3odz/NIdXk05pxCJUzkmiv6o ShTpJtXmEaSYENif9JDPkR5ISjMPA+m7pKBQpds8EuVnqcCYawczcrbjb1W/CipncFBI hUtG65Rocp7LYLPPWTQdnJxTQxLPiIbjedjwJw5VVmRWMjXzt0eFUqQGpcEOpcA8kr4q xLbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=mFzzS3LP2P+1fwrv5avZ++28bs+EmTpA50KXgcjw7fg=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=OoO2StUk2dHc6kyKnGzx200Xmg/L/PosroWd+FbQ3JEmpsrzbNuWKJd5YBxd0u7pKp N/1y7BmPuYx/dIANPF745HILW10s/U8YQZ+ED6H5gL8gW41wrjOiYrF2GppHkoRecJMX M06yfxX/+mShxNoZGBCMigt87T4SQbsx3/xN4NJ9JBn5yjbxQmX+l/pVtViQdGAxMoib /cYJv5R4adLrXnOgyjpuK5HfTtt8GkoUNcjYhM/6lPugtVmE/Larn2yzw6EtANKgDYBr KwPfYnhh+L/U9rjBuXoJY1yUF9pMvcneXhezBamENex3sMKgJ+GcXw4JUwqied2VP4W6 Nt5Q==; 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 4fb4d7f45d1cf-5c3cc52ef4esi1219770a12.45.2024.09.05.01.29.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:29:46 -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 4082888CA8; Thu, 5 Sep 2024 10:28:58 +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 769D388C91; Thu, 5 Sep 2024 10:28:57 +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_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 0917A88CA3 for ; Thu, 5 Sep 2024 10:28:55 +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 1546EFEC; Thu, 5 Sep 2024 01:29:21 -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 224B33F66E; Thu, 5 Sep 2024 01:28:51 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 07/16] lmb: notify of any changes to the LMB memory map Date: Thu, 5 Sep 2024 13:58:02 +0530 Message-Id: <20240905082811.1585467-8-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-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 In U-Boot, LMB and EFI are two primary modules who provide memory allocation and reservation API's. Both these modules operate with the same regions of memory for allocations. Use the LMB memory map update event to notify other interested listeners about a change in it's memory map. This can then be used by the other module to keep track of available and used memory. There is no need to send these notifications when the LMB module is being unit-tested. Add a flag to the lmb structure to indicate if the memory map is being used for tests, and suppress sending any notifications when running these unit tests. Signed-off-by: Sughosh Ganu --- include/lmb.h | 2 ++ lib/lmb.c | 74 ++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 67 insertions(+), 9 deletions(-) diff --git a/include/lmb.h b/include/lmb.h index ffba7e2889..f711b8fac8 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -44,10 +44,12 @@ struct lmb_region { * * @free_mem: List of free memory regions * @used_mem: List of used/reserved memory regions + * @test: Is structure being used for LMB tests */ struct lmb { struct alist free_mem; struct alist used_mem; + bool test; }; /** diff --git a/lib/lmb.c b/lib/lmb.c index 419b31a651..aff2830cb9 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -22,10 +23,33 @@ DECLARE_GLOBAL_DATA_PTR; +#define MAP_OP_RESERVE (u8)0x1 +#define MAP_OP_FREE (u8)0x2 +#define MAP_OP_ADD (u8)0x3 + #define LMB_ALLOC_ANYWHERE 0 #define LMB_ALIST_INITIAL_SIZE 4 static struct lmb lmb; +extern bool is_addr_in_ram(uintptr_t addr); + +static bool lmb_notify(enum lmb_flags flags) +{ + return !lmb.test && !(flags & LMB_NONOTIFY); +} + +static void lmb_map_update_notify(phys_addr_t addr, phys_size_t size, + u8 op) +{ + struct event_lmb_map_update lmb_map = {0}; + + lmb_map.base = addr; + lmb_map.size = size; + lmb_map.op = op; + + if (is_addr_in_ram((uintptr_t)addr)) + event_notify(EVT_LMB_MAP_UPDATE, &lmb_map, sizeof(lmb_map)); +} static void lmb_print_region_flags(enum lmb_flags flags) { @@ -474,9 +498,17 @@ static long lmb_add_region(struct alist *lmb_rgn_lst, phys_addr_t base, /* This routine may be called with relocation disabled. */ long lmb_add(phys_addr_t base, phys_size_t size) { + long ret; struct alist *lmb_rgn_lst = &lmb.free_mem; - return lmb_add_region(lmb_rgn_lst, base, size); + ret = lmb_add_region(lmb_rgn_lst, base, size); + if (ret) + return ret; + + if (CONFIG_IS_ENABLED(MEM_MAP_UPDATE_NOTIFY)) + lmb_map_update_notify(base, size, MAP_OP_ADD); + + return 0; } static long __lmb_free(phys_addr_t base, phys_size_t size) @@ -530,22 +562,39 @@ static long __lmb_free(phys_addr_t base, phys_size_t size) rgn[i].flags); } -long lmb_free(phys_addr_t base, phys_size_t size) +long lmb_free_flags(phys_addr_t base, phys_size_t size, + uint flags) { - return __lmb_free(base, size); + long ret; + + ret = __lmb_free(base, size); + if (ret < 0) + return ret; + + if (CONFIG_IS_ENABLED(MEM_MAP_UPDATE_NOTIFY) && lmb_notify(flags)) + lmb_map_update_notify(base, size, MAP_OP_FREE); + + return ret; } -long lmb_free_flags(phys_addr_t base, phys_size_t size, - __always_unused uint flags) +long lmb_free(phys_addr_t base, phys_size_t size) { return __lmb_free(base, size); } long lmb_reserve_flags(phys_addr_t base, phys_size_t size, enum lmb_flags flags) { + long ret = 0; struct alist *lmb_rgn_lst = &lmb.used_mem; - return lmb_add_region_flags(lmb_rgn_lst, base, size, flags); + ret = lmb_add_region_flags(lmb_rgn_lst, base, size, flags); + if (ret < 0) + return -1; + + if (CONFIG_IS_ENABLED(MEM_MAP_UPDATE_NOTIFY) && lmb_notify(flags)) + lmb_map_update_notify(base, size, MAP_OP_RESERVE); + + return ret; } long lmb_reserve(phys_addr_t base, phys_size_t size) @@ -607,6 +656,11 @@ static phys_addr_t __lmb_alloc_base(phys_size_t size, ulong align, if (lmb_add_region_flags(&lmb.used_mem, base, size, flags) < 0) return 0; + + if (CONFIG_IS_ENABLED(MEM_MAP_UPDATE_NOTIFY) && + lmb_notify(flags)) + lmb_map_update_notify(base, size, + MAP_OP_RESERVE); return base; } @@ -740,7 +794,7 @@ int lmb_is_reserved_flags(phys_addr_t addr, int flags) return 0; } -static int lmb_setup(void) +static int lmb_setup(bool test) { bool ret; @@ -758,6 +812,8 @@ static int lmb_setup(void) return -ENOMEM; } + lmb.test = test; + return 0; } @@ -777,7 +833,7 @@ int lmb_init(void) { int ret; - ret = lmb_setup(); + ret = lmb_setup(false); if (ret) { log_info("Unable to init LMB\n"); return ret; @@ -805,7 +861,7 @@ int lmb_push(struct lmb *store) int ret; *store = lmb; - ret = lmb_setup(); + ret = lmb_setup(true); if (ret) return ret; From patchwork Thu Sep 5 08:28:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 825622 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp186950wrb; Thu, 5 Sep 2024 01:30:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWg1JYQ6Mbou8CwWvlLJMrYE57ijHvtq1OnppATn1bGFVLUa/EIinwSMhQIP7MdcZIPnrqAEg==@linaro.org X-Google-Smtp-Source: AGHT+IFxN3s0RVGFZQCnGR6+623fI5E9C46ltHE3A2wjxsa6FEj9XCZQOIpo+7AOB/VkjtT2Zt/A X-Received: by 2002:a05:651c:1992:b0:2ef:2cdb:5053 with SMTP id 38308e7fff4ca-2f651e4c60emr43781851fa.37.1725525008196; Thu, 05 Sep 2024 01:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725525008; cv=none; d=google.com; s=arc-20240605; b=WOraINgcXJ2sWbtLxgKpjKBVLvgwHDs/y9uiC1E1oLahIhuUY3oji0ZVYrp7on6cNV p6lNYHsKltRRb3/VpZjO9VW4LSQEeJshtFvhA/qyzCIWWPMZMoAIAnW4vtqycV4E7NNc +cGs7pXU0ZfiSempYgdxbjlLIsPeO/tsHJRSsNqNSgtiVcyNqJX53/kTr/dLWtWnGxj0 NPmGhwdlf4MQP2xPrlulsDw+ZsTKNTiH8WJy/Fl1+b3IJXmn2p46OULv4vK3u/LXr6nS ACWSbyAsyWkTAsQdsHcWWKXqITTNTEaeXWYoWo0w2Wq3uNfpNLCCmRexGQnPS7fquayB Lj4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=SL16cX4D0ozq9CVN12JHtyc+ifnXDRc/37Cjk4bY4Fk=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=IoIZ7Nu4+f46+8e19ggXE71//oJXwsGXa6ntaNTIVat1Gb5VyMajIgtQk6cU/FipgC JtO+6a7DuhYzM1kPzKLO6k+IakIqP+6MSwsiJiwn9zG5PGOqa2dcjzdFFcoCc7ydqtBY 9B7fH3sUXEF0gDZl1j5rqEVtqpatMpYYQ0TeSnb5xjUA6KI0EwOjx/X7ozuSa2VLBUKl O9ACrTz93pgHPorV4fk8AtprxhhyVYUzhYGcLcOynrRg9x3YXRPH0Ox0sy5GDg3+Y9DV Lvm6ajSyYFaC/YI9XM3XBxpZLRDufNx1+uWvHekk8Xk86QtwDO4z0WtkKIXt1r1QJN48 XrIA==; 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-5c3cc699483si1175255a12.268.2024.09.05.01.30.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:30:08 -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 395F688CB8; Thu, 5 Sep 2024 10:29:06 +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 AC8FF88C91; Thu, 5 Sep 2024 10:29:04 +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_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 E94A088CA0 for ; Thu, 5 Sep 2024 10:28:57 +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 032A9FEC; Thu, 5 Sep 2024 01:29:24 -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 0FF0C3F66E; Thu, 5 Sep 2024 01:28:54 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 08/16] efi_memory: add an event handler to update memory map Date: Thu, 5 Sep 2024 13:58:03 +0530 Message-Id: <20240905082811.1585467-9-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-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 There are events that would be used to notify other interested modules of any changes in available and occupied memory. This would happen when a module allocates or reserves memory, or frees up memory. These changes in memory map should be notified to other interested modules so that the allocated memory does not get overwritten. Add an event handler in the EFI memory module to update the EFI memory map accordingly when such changes happen. As a consequence, any subsequent memory request would honour the updated memory map and only available memory would be allocated from. Signed-off-by: Sughosh Ganu --- lib/efi_loader/Kconfig | 2 ++ lib/efi_loader/efi_memory.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 911d4c6bbe..41d51987c3 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -16,9 +16,11 @@ config EFI_LOADER select CHARSET # We need to send DM events, dynamically, in the EFI block driver select DM_EVENT + select EVENT select EVENT_DYNAMIC select LIB_UUID select LMB + select MEM_MAP_UPDATE_NOTIFY imply PARTITION_UUIDS select REGEX imply FAT diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 90e07ed6a2..900d3c12f1 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -44,6 +44,10 @@ static LIST_HEAD(efi_mem); void *efi_bounce_buffer; #endif +#define MAP_OP_RESERVE (u8)0x1 +#define MAP_OP_FREE (u8)0x2 +#define MAP_OP_ADD (u8)0x3 + /** * struct efi_pool_allocation - memory block allocated from pool * @@ -919,3 +923,34 @@ int efi_memory_init(void) return 0; } + +#if CONFIG_IS_ENABLED(MEM_MAP_UPDATE_NOTIFY) +static int lmb_mem_map_update_sync(void *ctx, struct event *event) +{ + u8 op; + u64 addr; + u64 pages; + efi_status_t status; + struct event_lmb_map_update *lmb_map = &event->data.lmb_map; + + addr = (uintptr_t)map_sysmem(lmb_map->base, 0); + pages = efi_size_in_pages(lmb_map->size + (addr & EFI_PAGE_MASK)); + op = lmb_map->op; + addr &= ~EFI_PAGE_MASK; + + if (op != MAP_OP_RESERVE && op != MAP_OP_FREE && op != MAP_OP_ADD) { + log_debug("Invalid map update op received (%d)\n", op); + return -1; + } + + status = efi_add_memory_map_pg(addr, pages, + op == MAP_OP_RESERVE ? + EFI_BOOT_SERVICES_DATA : + EFI_CONVENTIONAL_MEMORY, + op == MAP_OP_RESERVE ? true : false); + + return status == EFI_SUCCESS ? 0 : -1; +} + +EVENT_SPY_FULL(EVT_LMB_MAP_UPDATE, lmb_mem_map_update_sync); +#endif /* MEM_MAP_UPDATE_NOTIFY */ From patchwork Thu Sep 5 08:28:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 825621 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp186901wrb; Thu, 5 Sep 2024 01:29:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVX8QpozE7adLklqfqG4jbyTC5fDUgxOvk2N0oA/D00rD5/WjBQa8jgkr7cjY2CNe7j1rXRWw==@linaro.org X-Google-Smtp-Source: AGHT+IEs1bSlf1sg4+BJ9z5+fN2ki6E26qwEKFTPocaY49vDKdIMyWvnOATf+VeTnB/YVkyjPV52 X-Received: by 2002:a17:907:97d4:b0:a86:aded:b09c with SMTP id a640c23a62f3a-a8a32fe141cmr587827966b.60.1725524997471; Thu, 05 Sep 2024 01:29:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725524997; cv=none; d=google.com; s=arc-20240605; b=QmK0lwoJO603KC9XJzYVliopP4IxC2ij8syG89bwtIl4Q7WNqMgaVsCW8LRkBxKB5R gWRB+iIIN6NR78uWhU/dVt2HF4Kkc7TLEC0fQriHiaxbN7InQyhmJlwJ/1nH1MRUGPAP vZJni3dd4Lf4+rqTc8Zj1ZZ509ErVnjT/S3hx6MuowdTpIAvsGN46ieMRK+6DU945f+p Jce6EsXS+98uWDLY0NOA553tSj67MObTaMVBKe6uObytTdxmZLlGnwm/ycQtOkhlH3S1 LIqH8yDxxmHkg4IAIghIgauModBVEcKMVbYx/CsOPg5//lDXME4uVwj8bIALxMsh4SMS fzog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=6x3RpPEG25nLrqvVFznJKHdw4bB47Y0Ef4fpaZB1dW0=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=Sc+i5SoBbPpTVn9J80uUks8KPFcHitgoua8Xsa85Ks1dg/BY5iiFD3Vy/und1cPiqC MIb08vvcytNT2cbz90W+gIoaBUpE1SNKEa2N8g6FKM3i7NwbhZg9nJ4v+AuaSK0leOec 41cUTx5HjJC2J7EG0zEOyqeZgyn1igVlIMZ467yV/pOuVlN7lIkgbl1w7XM77+w92rvQ YsTQuXGLKZb2nEPdQOj675puHgrcjUMBfdMcfcMEkzdolf+t0xaLY/T2dSvW7Pay7V7l X49NvkbeyhaWUKMDtu2+dKH6pgshT91dlHi/e9AG39gPgWuJvBnHg5VkiHzNxZIdPwbx DjiQ==; 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-a8a78b381dasi25497866b.447.2024.09.05.01.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:29:57 -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 A1EC388CCE; Thu, 5 Sep 2024 10:29:03 +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 EAB1E88CCB; Thu, 5 Sep 2024 10:29:02 +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_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 03E4288C6D for ; Thu, 5 Sep 2024 10:29:01 +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 E550BFEC; Thu, 5 Sep 2024 01:29:26 -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 F23013F66E; Thu, 5 Sep 2024 01:28:57 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 09/16] ti: k3: remove efi_add_known_memory() function definition Date: Thu, 5 Sep 2024 13:58:04 +0530 Message-Id: <20240905082811.1585467-10-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-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 efi_add_known_memory() function for the TI K3 platforms is adding the EFI_CONVENTIONAL_MEMORY type. This memory is now being handled through the LMB module -- the lmb_add_memory() adds this memory to the memory map. Remove the definition of the now superfluous efi_add_known_memory() function. Signed-off-by: Sughosh Ganu --- arch/arm/mach-k3/common.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index df48ec8d47..f2086cbdf5 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -310,14 +310,3 @@ void setup_qos(void) writel(qos_data[i].val, (uintptr_t)qos_data[i].reg); } #endif - -void efi_add_known_memory(void) -{ - if (IS_ENABLED(CONFIG_EFI_LOADER)) - /* - * Memory over ram_top can be used by various firmware - * Declare to EFI only memory area below ram_top - */ - efi_add_memory_map(gd->ram_base, gd->ram_top - gd->ram_base, - EFI_CONVENTIONAL_MEMORY); -} From patchwork Thu Sep 5 08:28:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 825623 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp187016wrb; Thu, 5 Sep 2024 01:30:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWjit1vAiKHcl9G7lgmerANaqEUj8X2io1GbgmRNivvvleac5Sjnr/Y8IKzT+iXt3XFmpg+kw==@linaro.org X-Google-Smtp-Source: AGHT+IEgm8lAdP/TMsJ+wHln9pheInYH4LB4PJnA8xIwY8Ft1OZzLSNJgnKHp/81r/my6UqzrSjF X-Received: by 2002:a17:907:9816:b0:a86:7e7f:69ab with SMTP id a640c23a62f3a-a897f8354bamr1798391366b.15.1725525019434; Thu, 05 Sep 2024 01:30:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725525019; cv=none; d=google.com; s=arc-20240605; b=VtdnoQe2kWGiPf2nTc42DXksqkIZO+pY+2itTVs20FXz2dDtpdgjNHTrjyuaWddxuj 6jkRwasJt3vy3KQl85k/0XtkbXfgHox3QBZ3VhECFNnE561b9RsmZE6OfYEYe0a8I6y8 9CnJdoU6O2IORbG8Fw5nCf/EetuE9peZZoQREMLSxeIwoamguGzM52Mxbwz1Nrub9M70 x4XbU/dkO88FgQdXzuBZ64Tg5Q0kuJ1QI9Ca+EjMQACVEpT8fsoZ7btq7O9UXBSelGtG xXFSjBTSeMIX5orf6ukTXFbD8jYoJBjRdssfAyJuB9c933OTeRKbkecXyZmY1sxuR2bI gXlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=UisRzynRlwSuKJl4+IjCX/HMbzgOxyXGtECc5XtluNY=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=BjF+j5DPSYPBnBGqQ/APd9pmSF/88PyY+2kadmYkFL2jkuZ1G+sBuGU36+nDOGdcul tVOqb136chdGfxCzXJapjcLdOevYQKSl0FmivgPfRlHy82EHIfBNa2efuOTQP3Mxi8tW OYxC/tTxJsu9dzMDKUkOn/7QlhYc5fU7WH2MA+Ydp9gHWB5nM76ZGY1HZJ5762sdCT90 qKVIUZfM9RLeY7ee0CxWHy3UYv3uHMHUi3fpiK9DA2juV5m1qgmvb+jHQR+fOOCpMQMD vZo8bGtXgvDDOrg48+vlrFPVOr/zhm6mneb9QqP5N356DBpL9qqg55AiWy6t5KNK6f20 jvGw==; 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-a8a61ff180bsi124330366b.42.2024.09.05.01.30.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:30:19 -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 96DE088C9C; Thu, 5 Sep 2024 10:29:07 +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 5CDEB88CBF; Thu, 5 Sep 2024 10:29:06 +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_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 C525988CD2 for ; Thu, 5 Sep 2024 10:29:03 +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 D304BFEC; Thu, 5 Sep 2024 01:29:29 -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 E06313F66E; Thu, 5 Sep 2024 01:29:00 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 10/16] stm32mp: remove efi_add_known_memory() function definition Date: Thu, 5 Sep 2024 13:58:05 +0530 Message-Id: <20240905082811.1585467-11-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-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 efi_add_known_memory() function for the stm32mp platforms is adding the EFI_CONVENTIONAL_MEMORY type. This memory is now being handled through the LMB module -- the lmb_add_memory() adds this memory to the memory map. Remove the definition of the now superfluous efi_add_known_memory() function. Signed-off-by: Sughosh Ganu --- arch/arm/mach-stm32mp/dram_init.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c index 198785353f..3698fc49bf 100644 --- a/arch/arm/mach-stm32mp/dram_init.c +++ b/arch/arm/mach-stm32mp/dram_init.c @@ -86,14 +86,3 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size) return reg + size; } - -void efi_add_known_memory(void) -{ - if (IS_ENABLED(CONFIG_EFI_LOADER)) - /* - * Memory over ram_top is reserved to OPTEE. - * Declare to EFI only memory area below ram_top - */ - efi_add_memory_map(gd->ram_base, gd->ram_top - gd->ram_base, - EFI_CONVENTIONAL_MEMORY); -} From patchwork Thu Sep 5 08:28: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: 825624 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp187067wrb; Thu, 5 Sep 2024 01:30:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU2DepDrOUwIIAGFc8tPU2n4mr2uOMauaPjXwCP8SOdZq9Z8KXOoPT3XxWMHQ1WopaUB7QYSw==@linaro.org X-Google-Smtp-Source: AGHT+IHezhVUB+v+t/bn39KLBAfoPX2bOJ3SduohVOv0uJ9Z+YmlSsWbND59GP9B/qIa1REMla8s X-Received: by 2002:a17:907:60c9:b0:a86:85eb:bdd1 with SMTP id a640c23a62f3a-a8a3f243750mr383685566b.31.1725525028704; Thu, 05 Sep 2024 01:30:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725525028; cv=none; d=google.com; s=arc-20240605; b=GviJZSyqjP6JoYauRoOtTZNJbIH4wHSLgYxz5TQf1SAdJbdRU28Ic9pufov1xxbEYd kh2K6ZeOEavlgLnC9lrrp7em8x2VENq93cIbWeot9NIL9RVNSsSwOVmNZe5LUFvALCaR pJNviYfi5BA1lkEpx9GPftfVJe5Xjh/aAaVwWIF9uDPi74Gtw6pLZs0fy2s2NQI4UXWo DfGUiPJIia5c5BnpUIEJ8Cfq/VOY7pGxDu9p4AafAdQ1gQhQLH3oSbQyun8vmqwZWgjp kqnKWWBkzc8qppuJ6xKoVNEp008eiJH8aS73AGitj8Qo8uVoFQXXHeG2PU4cwA1RqMxO 5U4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=ii6rqWpGfXz0wHbTtr9Ugq3q1qp6lju0K+w5Vw6Ocyk=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=TkQj31guHL2gOwQ/Qy82lCZH6S8YxSyK659U1A+7z9smimePOyd0WWON1vAvTPTRs0 C2FIYuMwneC+2U6LH8NVfszkR7x8wO+wTUtVvrH8Xx8Xxc0409lV1WxdlyLx+EtruJuU vUXuQNcgnZlXfFp/Rn/aYs5gKwOB2AEbu01G4+UCGhM6rgpbGVpT+bfGUHMqFCXnn0q5 RPs1OqQ9OH6jmFTMWMHNVDmF7+wk02YJ6wdsRnuKLtpo40L5vq0GzWTkBHrfzFSyF4GL Sb0f0tovgm4lt4mlz6FQGrETGkHEwLDYnEHFC63mIIt6OCOJN5BpGlNv6Q4srSC3Skzm nXjg==; 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-a8a623ce064si117289766b.681.2024.09.05.01.30.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:30:28 -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 F126788CC2; Thu, 5 Sep 2024 10:29:09 +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 B383888CA2; Thu, 5 Sep 2024 10:29:08 +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_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 B332188CC0 for ; Thu, 5 Sep 2024 10:29: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 C0EC2FEC; Thu, 5 Sep 2024 01:29:32 -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 CE1EE3F66E; Thu, 5 Sep 2024 01:29:03 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 11/16] lmb: allow for boards to specify memory map Date: Thu, 5 Sep 2024 13:58:06 +0530 Message-Id: <20240905082811.1585467-12-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-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 Some architectures have special or unique aspects which need consideration when adding memory ranges to the list of available memory map. Enable this config in such scenarios which allow architectures and boards to define their own memory map. Signed-off-by: Sughosh Ganu --- include/lmb.h | 2 ++ lib/Kconfig | 18 ++++++++++++++++++ lib/lmb.c | 3 +++ 3 files changed, 23 insertions(+) diff --git a/include/lmb.h b/include/lmb.h index f711b8fac8..6ef03f9b63 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -116,6 +116,8 @@ long lmb_free_flags(phys_addr_t base, phys_size_t size, uint flags); void lmb_dump_all(void); void lmb_dump_all_force(void); +void lmb_arch_add_memory(void); + struct lmb *lmb_get(void); int lmb_push(struct lmb *store); void lmb_pop(struct lmb *store); diff --git a/lib/Kconfig b/lib/Kconfig index 2e73cda580..f2fb90c12d 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1127,6 +1127,24 @@ config SPL_LMB SPL. This will require a malloc() implementation for defining the data structures needed for maintaining the LMB memory map. +config LMB_ARCH_MEM_MAP + bool "Add an architecture specific memory map" + depends on LMB + help + Some architectures have special or unique aspects which need + consideration when adding memory ranges to the list of available + memory map. Enable this config in such scenarios which allow + architectures and boards to define their own memory map. + +config SPL_LMB_ARCH_MEM_MAP + bool "Add an architecture specific memory map" + depends on SPL_LMB + help + Some architectures have special or unique scenarios which need + consideration when adding memory ranges to the list of available + memory map. Enable this config in such scenarios which allow + architectures and boards to define their own memory map. + config PHANDLE_CHECK_SEQ bool "Enable phandle check while getting sequence number" help diff --git a/lib/lmb.c b/lib/lmb.c index aff2830cb9..ec5078527e 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -309,6 +309,9 @@ void lmb_add_memory(void) u64 ram_top = gd->ram_top; struct bd_info *bd = gd->bd; + if (CONFIG_IS_ENABLED(LMB_ARCH_MEM_MAP)) + return lmb_arch_add_memory(); + /* Assume a 4GB ram_top if not defined */ if (!ram_top) ram_top = 0x100000000ULL; From patchwork Thu Sep 5 08:28: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: 825625 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp187136wrb; Thu, 5 Sep 2024 01:30:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXfONuDsW2l+X55HK+qkcUgkXaLGaukGsFbJOOAEp2SVlDGqAgZOTspouuCvKHwoaEMiD8mgg==@linaro.org X-Google-Smtp-Source: AGHT+IFVykVluZt/0GWa826r01ugVEr9csBe/HpvFv7HsjF9xBrmj8mYNFYZo+EkWGK+RiAo6XDC X-Received: by 2002:a17:907:72d6:b0:a80:788e:176c with SMTP id a640c23a62f3a-a89a35ceef6mr1708913866b.23.1725525039044; Thu, 05 Sep 2024 01:30:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725525039; cv=none; d=google.com; s=arc-20240605; b=Qri4ZbDF0cvhaFfmME20qxuTbr4bipFq4/tBrOzLb02MDnfc3Y15HzNmPcYyG4Fw6/ UWP5mnM8vWO3LOBSDiV7ysj4pRyYnHe12gzzXtu5yHvudlJjSkHdFRPdpPjtWMTlXOOh bd34YqRBRZhMNTSQlkG1Qn523lVhni3TYL8Ep/A5571VTlpgnHMFhd9vNfjuHuIp18k5 v7Zc6+yukN83wSy1DXQAKAqZqjq9qvqjCoIbfZDHt/1I7ChssK1tYgNG7PAm/D97RmWq 8c52jAKsysI3mEzQ0YZ9kdCnDa1YVxqGyBzb8CHebVnQlvMTwI34rfhZnjXL6YReIVYf OMAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=YVgs1cZqW4g2das9WbJ52f7/My1qh98To2QbSQmY8FQ=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=lJmvYodF+Jd5AgTC3BNFjwOAZuT7XB2RW9F00q1NqE/S7kfXPx/Md54ZCV5MqFs1Rw afz6Zpdx9sPuiEk2Uy7wv2vF59aXOmOmpXVW6Co4x8Dlb4oeALBynwOREHb9sr9qBpOY X8TDaIOSzNh7IFbz63Sv2hT6stTJI/Ae+r6SxzJk0keGDaffjJ48BUxZ/YNtb3u+t9f9 SOCF6OgYWJGNkpjV9mODomVEf9emJc3URulrBhohgx9UdN/4jhCOBeGwMQrGm+NZNM/G 5tKdQod1DrjlQX7TRCuvWFHEEOLNuzRw0gGbm5H0Z2g++yquthfpy/t8zjrDv8eZPV0G 2Ngg==; 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 a640c23a62f3a-a8a672a765asi89890266b.1015.2024.09.05.01.30.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:30:39 -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 5AA3288CE4; Thu, 5 Sep 2024 10:29:12 +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 9245F88C6D; Thu, 5 Sep 2024 10:29:11 +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_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 A0A2D88C1B for ; Thu, 5 Sep 2024 10:29:09 +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 AE96EFEC; Thu, 5 Sep 2024 01:29:35 -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 BBF173F66E; Thu, 5 Sep 2024 01:29:06 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 12/16] layerscape: use the lmb API's to add RAM memory Date: Thu, 5 Sep 2024 13:58:07 +0530 Message-Id: <20240905082811.1585467-13-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-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 EFI memory allocations are now being done through the LMB module, and hence the memory map is maintained by the LMB module. Use the lmb_arch_add_memory() API function to add the usable RAM memory to the LMB's memory map. Signed-off-by: Sughosh Ganu --- arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 8 ++++---- lib/Kconfig | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c index d2dbfdd08a..e7fb91a821 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1525,8 +1526,8 @@ int dram_init_banksize(void) return 0; } -#if CONFIG_IS_ENABLED(EFI_LOADER) -void efi_add_known_memory(void) +#if CONFIG_IS_ENABLED(LMB_ARCH_MEM_MAP) +void lmb_arch_add_memory(void) { int i; phys_addr_t ram_start; @@ -1548,8 +1549,7 @@ void efi_add_known_memory(void) gd->arch.resv_ram < ram_start + ram_size) ram_size = gd->arch.resv_ram - ram_start; #endif - efi_add_memory_map(ram_start, ram_size, - EFI_CONVENTIONAL_MEMORY); + lmb_add(ram_start, ram_size); } } #endif diff --git a/lib/Kconfig b/lib/Kconfig index f2fb90c12d..ee0b4d65f2 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1130,6 +1130,7 @@ config SPL_LMB config LMB_ARCH_MEM_MAP bool "Add an architecture specific memory map" depends on LMB + default y if FSL_LAYERSCAPE help Some architectures have special or unique aspects which need consideration when adding memory ranges to the list of available From patchwork Thu Sep 5 08:28:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 825626 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp187194wrb; Thu, 5 Sep 2024 01:30:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVuEVT8745mJWzKWdyiX4akj8R3rryLS4SlnMOe9Q0SuPZEhH9P6CK7c8Xtg7DdtaHVzYLkzg==@linaro.org X-Google-Smtp-Source: AGHT+IHGm44cwe4CvO4YdgAXbhpm/9U0Res6sTuBZnZBorqq0O/cThsWdGTyqNiuIjN5s596salR X-Received: by 2002:a17:907:1b97:b0:a89:b820:335 with SMTP id a640c23a62f3a-a89b820043cmr975122466b.65.1725525048376; Thu, 05 Sep 2024 01:30:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725525048; cv=none; d=google.com; s=arc-20240605; b=Y7KUHikK/5AguEgWKBubM3VB/AdrNTYyxb+KZ3rmWmyGtp6ywPCdrgVr4h23Z0bsUm S2WyDZAONlw1IKMGiSswORTEBZJreNMBZVtQ9QtUHQQ5QEhaAND/DW4SVjqtSMz2S6pc /kda986vdTfbk6x/d58dMxsbD3GvxDRskurFfrShpoYBV67zoDDzfLGIYmkU4ma3YQit AKkT8/XUlfUzVnMJ/fCYpb7wPWHV7meWy0yu4KMoaRfzZ1jCLIbIYSKaY8MXrszyEGm0 zyNq7BF5S+0fBjdDe0WdjUtkkMYqm+Ai03GgkmKHq1ooAsNcxcTScm2cA+JGN+XBODNg qW1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=ha6IqWRHhhu18/Sz2sJqgV1DvNuwhag5xpZbTjh4Ku8=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=ZAYtDo+iK5SbT/tsTJZ+U6GYMB4byYNqH9QF5PfrUXvmApcGDHQN8WN3UD56FnQwDq gRnBEbAlPoqDMn+jOrQBgF2KXUODzy/EC+y1Rl5IJdcKJkUGN9JFJSGbRfnoDFSBLjq/ Cv8weUgiXBExJKMLTNggIK065L4oaAq4vEWmTfSD8dsGpWsk4d9OuPXUPohNGvlmHitz EcSyTEWoonXYZ7H7w/x656HvwMa3vpIKEWzXOGwSs5eva51E9j1Glq1cbcv2lmfOSBFr GA65bFHUO3qBzeCbricGz/brLqYlunPb17arJwCaKfi3NovdxSubXp/T80ecYisM8ulB KNhg==; 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-a8a61fdd426si117300266b.184.2024.09.05.01.30.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:30:48 -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 B194088CA2; Thu, 5 Sep 2024 10:29:16 +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 63ABA88C6D; Thu, 5 Sep 2024 10:29:15 +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_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 8E8E388CE8 for ; Thu, 5 Sep 2024 10:29:12 +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 9C0F7FEC; Thu, 5 Sep 2024 01:29:38 -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 A9A0F3F66E; Thu, 5 Sep 2024 01:29:09 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 13/16] x86: e820: use the lmb API for adding RAM memory Date: Thu, 5 Sep 2024 13:58:08 +0530 Message-Id: <20240905082811.1585467-14-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-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 EFI_CONVENTIONAL_MEMORY type is now being managed through the LMB module. Add a separate function, lmb_arch_add_memory() to add the RAM memory to the LMB memory map. The efi_add_known_memory() function is now used for adding any other memory type to the EFI memory map. Signed-off-by: Sughosh Ganu --- arch/x86/lib/e820.c | 47 ++++++++++++++++++++++++++++++++++----------- lib/Kconfig | 2 +- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/arch/x86/lib/e820.c b/arch/x86/lib/e820.c index 122b4f7ca0..d478b7486e 100644 --- a/arch/x86/lib/e820.c +++ b/arch/x86/lib/e820.c @@ -4,6 +4,7 @@ */ #include +#include #include #include @@ -41,15 +42,11 @@ void efi_add_known_memory(void) { struct e820_entry e820[E820MAX]; unsigned int i, num; - u64 start, ram_top; + u64 start; int type; num = install_e820_map(ARRAY_SIZE(e820), e820); - ram_top = (u64)gd->ram_top & ~EFI_PAGE_MASK; - if (!ram_top) - ram_top = 0x100000000ULL; - for (i = 0; i < num; ++i) { start = e820[i].addr; @@ -72,13 +69,41 @@ void efi_add_known_memory(void) break; } - if (type == EFI_CONVENTIONAL_MEMORY) { - efi_add_conventional_memory_map(start, - start + e820[i].size, - ram_top); - } else { + if (type != EFI_CONVENTIONAL_MEMORY) efi_add_memory_map(start, e820[i].size, type); - } } } #endif /* CONFIG_IS_ENABLED(EFI_LOADER) */ + +#if CONFIG_IS_ENABLED(LMB_ARCH_MEM_MAP) +void lmb_arch_add_memory(void) +{ + struct e820_entry e820[E820MAX]; + unsigned int i, num; + u64 ram_top; + + num = install_e820_map(ARRAY_SIZE(e820), e820); + + ram_top = (u64)gd->ram_top & ~EFI_PAGE_MASK; + if (!ram_top) + ram_top = 0x100000000ULL; + + for (i = 0; i < num; ++i) { + if (e820[i].type == E820_RAM) { + u64 start, size, rgn_top; + + start = e820[i].addr; + size = e820[i].size; + rgn_top = start + size; + + if (start > ram_top) + continue; + + if (rgn_top > ram_top) + size -= rgn_top - ram_top; + + lmb_add(start, size); + } + } +} +#endif /* CONFIG_IS_ENABLED(LMB_ARCH_MEM_MAP) */ diff --git a/lib/Kconfig b/lib/Kconfig index ee0b4d65f2..75447dfa27 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1130,7 +1130,7 @@ config SPL_LMB config LMB_ARCH_MEM_MAP bool "Add an architecture specific memory map" depends on LMB - default y if FSL_LAYERSCAPE + default y if FSL_LAYERSCAPE || X86 help Some architectures have special or unique aspects which need consideration when adding memory ranges to the list of available From patchwork Thu Sep 5 08:28:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 825627 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp187246wrb; Thu, 5 Sep 2024 01:30:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXFVJTfNdVNeYo3dRVrxGfRi5sq1ZiLFYdHNRwIahtwC2LIL1jWqh3c5WmuNt3gfPW+8YcnWA==@linaro.org X-Google-Smtp-Source: AGHT+IHtV5Pe43Q6ZRNXnp/Dh4QEr70GnZ8GJPxcS/aRcJMZR90J/taFqIwhVb9aULzPaLMkz3i+ X-Received: by 2002:a05:6512:3d17:b0:535:6a4d:ed74 with SMTP id 2adb3069b0e04-5356a4def44mr2055701e87.51.1725525058603; Thu, 05 Sep 2024 01:30:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725525058; cv=none; d=google.com; s=arc-20240605; b=UguvW7vfnHiJcfg110yEKjBRihyllmB/YPrqmfBQFKhMS7Kd/QYaAD9EcbXAbJ99F7 dp6qzkqeKbXSnoY4DfPPghYL8Gx/n29xvRyesrQkW2jmVU2QXKAfcvDCyMl2XxzbYUkS Qx8Am+qECpPJN8C3bhKYWjjo8iqewxTcvdWuq8y7c4nDXZsUE6ws6TSN2ZshZ60uoaZA j2maIzmfz8940DgvxugMwA8CCtQPEZ1oy0JeBggOUyZHT0CU0x8b6flhotnDfBMoFBsm +usCcV0jVya/shCtwsFDawMj94gWdeYpUiKgZfB0YjMeaix6LtX4SUwEBlyRdTu2jyHo dLGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=7HjeVWPB2pOk5wt86htpclClknzlJQYZekwktS7MGtg=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=N7OeY65lq6+S8Ei7pMO8AMormnBqqHqaUUHAEEedJOqaVvh72412oRAAs1rciwSEAw jYYUHNxuUBDTFdyaKXUdyDanMn/nYGn0HPfPtefzy1OCukbgzTdt59YFIQe9NyTB9byS HS+1pMkx640cVdJAjfiUlIjrjmBYOd9poZ0X1V2AouCJHbAOs14fyphAYOWBL3mXzaKa 1VyJ2WkuhMWYDa5z3kLaQn3ouSE2+9OveLfS3mwbLIXnwi6qDQbbq2JI1ORWn85/+GsP kfOCed1SCqCsWRK9ttIfBeXf/hafuQ7P48WqAwZ4XA/atrJgRUm/8QZ4fLzh7rblM+3M KHCA==; 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-a8a6240fb32si116927566b.797.2024.09.05.01.30.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:30:58 -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 121B088C91; Thu, 5 Sep 2024 10:29:19 +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 ADD7C88CD9; Thu, 5 Sep 2024 10:29:17 +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_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 7E3B488C91 for ; Thu, 5 Sep 2024 10:29:15 +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 8A1FBFEC; Thu, 5 Sep 2024 01:29:41 -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 974163F66E; Thu, 5 Sep 2024 01:29:12 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 14/16] efi_memory: do not add RAM memory to the memory map Date: Thu, 5 Sep 2024 13:58:09 +0530 Message-Id: <20240905082811.1585467-15-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-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 EFI_CONVENTIONAL_MEMORY type, which is the usable RAM memory is now being managed by the LMB module. Remove the addition of this memory type to the EFI memory map. This memory now gets added to the EFI memory map as part of the LMB memory map update event handler. Signed-off-by: Sughosh Ganu Reviewed-by: Simon Glass --- include/efi_loader.h | 12 +++--- lib/efi_loader/efi_memory.c | 75 +++---------------------------------- 2 files changed, 12 insertions(+), 75 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index f84852e384..d68709f611 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -784,9 +784,6 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, uint32_t *descriptor_version); /* Adds a range into the EFI memory map */ efi_status_t efi_add_memory_map(u64 start, u64 size, int memory_type); -/* Adds a conventional range into the EFI memory map */ -efi_status_t efi_add_conventional_memory_map(u64 ram_start, u64 ram_end, - u64 ram_top); /* Called by board init to initialize the EFI drivers */ efi_status_t efi_driver_init(void); @@ -1172,9 +1169,14 @@ efi_status_t efi_console_get_u16_string efi_status_t efi_disk_get_device_name(const efi_handle_t handle, char *buf, int size); /** - * efi_add_known_memory() - add memory banks to EFI memory map + * efi_add_known_memory() - add memory types to the EFI memory map * - * This weak function may be overridden for specific architectures. + * This function is to be used to adding different memory types other + * than EFI_CONVENTIONAL_MEMORY to the EFI memory map. The conventional + * memory is handled by the LMB module, and gets added to the memory + * map through the LMB module. + * + * This function may be overridden for specific architectures. */ void efi_add_known_memory(void); diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 900d3c12f1..02f1682b54 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -784,82 +784,17 @@ efi_status_t efi_get_memory_map_alloc(efi_uintn_t *map_size, } /** - * efi_add_conventional_memory_map() - add a RAM memory area to the map + * efi_add_known_memory() - add memory types to the EFI memory map * - * @ram_start: start address of a RAM memory area - * @ram_end: end address of a RAM memory area - * @ram_top: max address to be used as conventional memory - * Return: status code - */ -efi_status_t efi_add_conventional_memory_map(u64 ram_start, u64 ram_end, - u64 ram_top) -{ - u64 pages; - - /* Remove partial pages */ - ram_end &= ~EFI_PAGE_MASK; - ram_start = (ram_start + EFI_PAGE_MASK) & ~EFI_PAGE_MASK; - - if (ram_end <= ram_start) { - /* Invalid mapping */ - return EFI_INVALID_PARAMETER; - } - - pages = (ram_end - ram_start) >> EFI_PAGE_SHIFT; - - efi_add_memory_map_pg(ram_start, pages, - EFI_CONVENTIONAL_MEMORY, false); - - /* - * Boards may indicate to the U-Boot memory core that they - * can not support memory above ram_top. Let's honor this - * in the efi_loader subsystem too by declaring any memory - * above ram_top as "already occupied by firmware". - */ - if (ram_top < ram_start) { - /* ram_top is before this region, reserve all */ - efi_add_memory_map_pg(ram_start, pages, - EFI_BOOT_SERVICES_DATA, true); - } else if (ram_top < ram_end) { - /* ram_top is inside this region, reserve parts */ - pages = (ram_end - ram_top) >> EFI_PAGE_SHIFT; - - efi_add_memory_map_pg(ram_top, pages, - EFI_BOOT_SERVICES_DATA, true); - } - - return EFI_SUCCESS; -} - -/** - * efi_add_known_memory() - add memory banks to map + * This function is to be used to adding different memory types other + * than EFI_CONVENTIONAL_MEMORY to the EFI memory map. The conventional + * memory is handled by the LMB module, and gets added to the memory + * map through the LMB module. * * This function may be overridden for specific architectures. */ __weak void efi_add_known_memory(void) { - u64 ram_top = gd->ram_top & ~EFI_PAGE_MASK; - int i; - - /* - * ram_top is just outside mapped memory. So use an offset of one for - * mapping the sandbox address. - */ - ram_top = (uintptr_t)map_sysmem(ram_top - 1, 0) + 1; - - /* Fix for 32bit targets with ram_top at 4G */ - if (!ram_top) - ram_top = 0x100000000ULL; - - /* Add RAM */ - for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { - u64 ram_end, ram_start; - - ram_start = (uintptr_t)map_sysmem(gd->bd->bi_dram[i].start, 0); - ram_end = ram_start + gd->bd->bi_dram[i].size; - - efi_add_conventional_memory_map(ram_start, ram_end, ram_top); - } } /** From patchwork Thu Sep 5 08:28:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 825628 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp187299wrb; Thu, 5 Sep 2024 01:31:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVX8ZkBRjkx4B/q2WCcFUymqp5+jSE0l9iBfwSyij10iJYradcO6vKZW7JfikvH8BOn/1IjsQ==@linaro.org X-Google-Smtp-Source: AGHT+IEV4HU+3RNwqDAdu65LqHq94wwJY4WX4xWVylDT5Np/bYDARgtdW6b/ofb2JdUeHOaqWC+h X-Received: by 2002:a2e:b8d6:0:b0:2f1:750d:53a7 with SMTP id 38308e7fff4ca-2f6105c4993mr230151951fa.8.1725525068171; Thu, 05 Sep 2024 01:31:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725525068; cv=none; d=google.com; s=arc-20240605; b=ABaGABrRMVIVsK75RF0ZYKRf7z+hq55T7hSaFOg5tgqmHdH4Mv9cJPJ/Zz/lePG5bw xwIXB7nzs7WQ1SeEkTJrkT2x8thGVO9Qm+oiDziF28glvSB9nVWL05Ya3BC91YhUXuWn fcuHxZkkJGPQ7RNxkRUqwTngGAigZGvA9D6Z4H5QSQsIZF/tDvK1XLvVOLIJl5G2Re9Z Z2DQNdGyJpW9sAoLFwjBLDBpZ7y1qs4L3WRRc4UQXueB5b1OYl366MVoC02a2oDsD5PS zhGZ62LC4nc83RTdq/TYAOEHM05NTgEOO6qX9EpF4bZoy4f/4jeqqtpn0aIvBxQTX+Yg kWzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=X/emLcIUDrY41XKW9AZ70Id/UkcE2c92PgJ7AH5uz1o=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=Xe+ff+6VHOw/kG9xgh/OyUqEANv7znKTflXp7fSISxbQ7Ws4oCygw4RbVH1x5oUXgU MG4Ws9N2/+pixE3+ii88P2eGJ2ioolvR1z2yR9oxBuYj26X6xqFAVhcAC7MQ6B8supMc acgm7QRh8CQP9uAMANvikmyrrFn6CMdxZ0eSpxHyzs3mMiMs9/MQocwRTDylTUQ0eCHY cM82qu52WgyGX64dTfvONKhXWN2phhnWU6GjDxs2d5/zn2tq6jGLnoxY0oQ0ioKQMERM 2gupGE1XgMEZv3fBzyy20II3nquN2/RxMK6brzFZog4pdkIsocwE6heX+/osOzDCqwT4 x8ZA==; 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-a8a74db09c3si47773966b.1006.2024.09.05.01.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:31:08 -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 6CA4D88C87; Thu, 5 Sep 2024 10:29:21 +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 5FD4088C6D; Thu, 5 Sep 2024 10:29: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.2 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 69E0B88C6D for ; Thu, 5 Sep 2024 10:29:18 +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 77D85FEC; Thu, 5 Sep 2024 01:29:44 -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 84DA93F66E; Thu, 5 Sep 2024 01:29:15 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 15/16] lmb: remove call to efi_lmb_reserve() Date: Thu, 5 Sep 2024 13:58:10 +0530 Message-Id: <20240905082811.1585467-16-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-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 EFI memory allocations are now being done through the LMB module. With this change, there is no need to get the EFI memory map and set aside EFI allocated memory. Signed-off-by: Sughosh Ganu --- lib/lmb.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index ec5078527e..7074217417 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -7,7 +7,6 @@ */ #include -#include #include #include #include @@ -186,38 +185,6 @@ static void lmb_fix_over_lap_regions(struct alist *lmb_rgn_lst, lmb_remove_region(lmb_rgn_lst, r2); } -/** - * efi_lmb_reserve() - add reservations for EFI memory - * - * Add reservations for all EFI memory areas that are not - * EFI_CONVENTIONAL_MEMORY. - * - * Return: 0 on success, 1 on failure - */ -static __maybe_unused int efi_lmb_reserve(void) -{ - struct efi_mem_desc *memmap = NULL, *map; - efi_uintn_t i, map_size = 0; - efi_status_t ret; - - ret = efi_get_memory_map_alloc(&map_size, &memmap); - if (ret != EFI_SUCCESS) - return 1; - - for (i = 0, map = memmap; i < map_size / sizeof(*map); ++map, ++i) { - if (map->type != EFI_CONVENTIONAL_MEMORY) { - lmb_reserve_flags(map_to_sysmem((void *)(uintptr_t) - map->physical_start), - map->num_pages * EFI_PAGE_SIZE, - map->type == EFI_RESERVED_MEMORY_TYPE - ? LMB_NOMAP : LMB_NONE); - } - } - efi_free_pool(memmap); - - return 0; -} - static void lmb_reserve_uboot_region(void) { int bank; @@ -264,9 +231,6 @@ static void lmb_reserve_common(void *fdt_blob) if (CONFIG_IS_ENABLED(OF_LIBFDT) && fdt_blob) boot_fdt_add_mem_rsv_regions(fdt_blob); - - if (CONFIG_IS_ENABLED(EFI_LOADER)) - efi_lmb_reserve(); } static __maybe_unused void lmb_reserve_common_spl(void) From patchwork Thu Sep 5 08:28:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 825629 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp187350wrb; Thu, 5 Sep 2024 01:31:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUykinU5hA7DbpqsLi02aGmv/Q94iYCS1hyMAthsnevRgAcD+677AQln0T33lnwhnpY2LBwlQ==@linaro.org X-Google-Smtp-Source: AGHT+IFAYXQ9q1XUV2IWOgbJuX8Np63QYLZP+6lroJ+ok/wK1A5WgV8+pUrcmk2WYAMFaoEn3fIT X-Received: by 2002:a17:907:3f9d:b0:a7a:8e98:890d with SMTP id a640c23a62f3a-a8a32e6d915mr556059166b.16.1725525077904; Thu, 05 Sep 2024 01:31:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725525077; cv=none; d=google.com; s=arc-20240605; b=LzYMeSB97NIWMS9P8+MZTDGJaWpJZ7Kq+S7HQFQ/gi3HLtDiUKuSVOyRrmgeM1DNXY aGVsuOJ8Rkx361TMG5bx1vlMv5pwhe9oqWY58kG4YjA+BDRH3KZOHGM91M0l0wfkcMG2 45VmovsD6x75EwJR2wc2ES06Kl6w8xEq87B/DEEKZSRSTG5g1/S9v/AFWI0JKWwwBSsI J6L3diROntghsFkagwGfpPkuggcvNhwWxB6d4Lu2RKZpKYYlw88T5he1B1CNbnRea9Iw mIla93GLSDpanITYQGVzQGnqykupnxPP6RmWfJ5F2PO+mEl1KcpkZ8pTVUXkg50glDvP vCCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=tbSwJnOH2327U5Tr7fHBMCHWGwVUgy2zwLex4Rzj6m4=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=J72kkltJ8pKvNHRymqss7SlVnkjWthIgb5/hTNtmSVCroUjxP1HY/TZYOQRf07H5CW VZQ6T4VzUVuKwrs7vLilcF1zyjsijSJ22m/poG2IShSmklnV7++9b/55u8lKj8FQnAAF TJiDY/FoVLji8nRzWKru4gLnaenUAKjCITOFOGliPKK+zg6KKKhwSkKrYStjiZ53g69c BsFfl9OpEhN05JvOk/FWO6VO74gRGtlYNQLGH+N0RiNMJ/Rf0LaSA+FCdNtwu+T8fuMG TGsQ2bOcj00dOFlyJwmso3GLZql6JjPbdkAFwWXWj/r55H6H81E35E7JJC8M+JEmhZ4w dBgA==; 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 a640c23a62f3a-a8a7aa58767si11578366b.919.2024.09.05.01.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:31:17 -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 CE8C488C6D; Thu, 5 Sep 2024 10:29:23 +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 48F9388CFA; Thu, 5 Sep 2024 10:29:23 +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_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 573E488C1B for ; Thu, 5 Sep 2024 10:29:21 +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 64F8BFEC; Thu, 5 Sep 2024 01:29:47 -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 726C23F66E; Thu, 5 Sep 2024 01:29:18 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 16/16] test: event: update the expected event dump output Date: Thu, 5 Sep 2024 13:58:11 +0530 Message-Id: <20240905082811.1585467-17-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-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 addition of two events for notification of any changes to memory that is occupied and is free, the output of the event_dump.py script has changed. Update the expected event log to incorporate this change. Signed-off-by: Sughosh Ganu --- test/py/tests/test_event_dump.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/py/tests/test_event_dump.py b/test/py/tests/test_event_dump.py index e282c67335..3537f0383c 100644 --- a/test/py/tests/test_event_dump.py +++ b/test/py/tests/test_event_dump.py @@ -19,6 +19,7 @@ def test_event_dump(u_boot_console): EVT_FT_FIXUP bootmeth_vbe_ft_fixup .*boot/vbe_request.c:.* EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup .*boot/vbe_simple_os.c:.* EVT_LAST_STAGE_INIT install_smbios_table .*lib/efi_loader/efi_smbios.c:.* +EVT_LMB_MAP_UPDATE lmb_mem_map_update_sync .*lib/efi_loader/efi_memory.c:.* EVT_MISC_INIT_F sandbox_early_getopt_check .*arch/sandbox/cpu/start.c:.* EVT_TEST h_adder_simple .*test/common/event.c:''' assert re.match(expect, out, re.MULTILINE) is not None