From patchwork Sun Oct 13 10:55: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: 835067 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1536538wrd; Sun, 13 Oct 2024 03:55:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWznMATGCwchNa58K8H9aG5dX01qCPClHXXEC4Evg9Eg7CZRc1GCK8e4xIebLLEtCa511RJ1Q==@linaro.org X-Google-Smtp-Source: AGHT+IF9fw25I8JA9Y6tiBQ1ssUXBCh+GegtC45M9QAEH5j9FQLqrQjXKU0kfufBrf7yCC0KL9La X-Received: by 2002:a05:6602:16:b0:805:2048:a492 with SMTP id ca18e2360f4ac-835486c6fb2mr829355139f.6.1728816957927; Sun, 13 Oct 2024 03:55:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728816957; cv=none; d=google.com; s=arc-20240605; b=empXttkApscpEPvVTc70f0axHMT7wxDuE5vW0IGWqm8ajWbKsOf75j/Iu2Tu9FgIfB 2ZU7xMTrXHE7HVFNOeP5eV64uiHRWq9Cf/P3/6p0mGUPUybtgT0Fjmpyp91YDdKPU3bs OhzES+M0yTJugrX5efxxadzFUaWo68wdI5aksGIBIZ/zcHN5CV5t0Dzb5aShthCm0riC yg28mXIesY1Hxat2zHucnchzTEWb5CWitS2aH9UA64SPDOniSkA45dnwctG5i714XjH3 +BtCdmoUG+WeGAm/X7d5s/cp2fF0d2GwAJCfyQnutpKKcI+8RzS2lc+m/AIM6c2PgpQ7 R4RQ== 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=u8CzgDkJ5mo6FgjSO/qJDBAMn3oUodTZljZ/CxaZ6zg=; fh=DqKFq13hCy9hcb48ZltPVvgEKSF1g1c/m42wn0WwlIc=; b=D+9XTAGGGPbErL++kpuxQY2q4ZGwns15EPH7Jfm0QFP4MT1Vb+9b6ukbP/1DYc0v81 2//lBi6Efpi6Z0WzcydJFoUk4QKaA+f1sBZD0uBOHEfgzO4yf64NH85jHCxrunenrmrR XzFiaJtZotbgAbOtHEex5+eB85Oi9XZ89WGMX66PLhs9vaCDR16w8DPhXnxBqcNux6d5 AYnl5SKQ2CGkft16EnIAT5st7nhNLvk3MxwafKJmwIU0VL8Plh8x4H6Jz0P3Mn8XD/4X MazYjzFr/qoZb8YNmytqtS/ISW6f9bISM5OoO6FuqvG18DIvZT956FuoVNsjVZ8lqwdu OLVg==; 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 ca18e2360f4ac-8354ba7d4ddsi321534339f.147.2024.10.13.03.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 03:55: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 92E6088ECB; Sun, 13 Oct 2024 12:55:48 +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 6E8ED88EC9; Sun, 13 Oct 2024 12:55:47 +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_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 3246E88C7C for ; Sun, 13 Oct 2024 12:55:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3F5D51007; Sun, 13 Oct 2024 03:56:14 -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 18E653F71E; Sun, 13 Oct 2024 03:55:41 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v3 01/15] lmb: add versions of the lmb API with flags Date: Sun, 13 Oct 2024 16:25:08 +0530 Message-Id: <20241013105522.391414-2-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013105522.391414-1-sughosh.ganu@linaro.org> References: <20241013105522.391414-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 Reviewed-by: Simon Glass --- Changes since V2: None include/lmb.h | 56 +++++++++++++++++++++++++++++++++ lib/lmb.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 140 insertions(+), 1 deletion(-) diff --git a/include/lmb.h b/include/lmb.h index aee2f9fcda..0e8426f437 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -90,6 +90,50 @@ phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr); phys_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size); phys_size_t lmb_get_free_size(phys_addr_t addr); +/** + * lmb_alloc_flags() - Allocate memory region with specified attributes + * @size: Size of the region requested + * @align: Alignment of the memory region requested + * @flags: Memory region attributes to be set + * + * Allocate a region of memory with the attributes specified through the + * parameter. + * + * Return: base address on success, 0 on error + */ +phys_addr_t lmb_alloc_flags(phys_size_t size, ulong align, uint flags); + +/** + * lmb_alloc_base_flags() - Allocate specified memory region with specified attributes + * @size: Size of the region requested + * @align: Alignment of the memory region requested + * @max_addr: Maximum address of the requested region + * @flags: Memory region attributes to be set + * + * Allocate a region of memory with the attributes specified through the + * parameter. The max_addr parameter is used to specify the maximum address + * below which the requested region should be allocated. + * + * Return: base address on success, 0 on error + */ +phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align, + phys_addr_t max_addr, uint flags); + +/** + * lmb_alloc_addr_flags() - Allocate specified memory address with specified attributes + * @base: Base Address requested + * @size: Size of the region requested + * @flags: Memory region attributes to be set + * + * Allocate a region of memory with the attributes specified through the + * parameter. The base parameter is used to specify the base address + * of the requested region. + * + * Return: base address on success, 0 on error + */ +phys_addr_t lmb_alloc_addr_flags(phys_addr_t base, phys_size_t size, + uint flags); + /** * lmb_is_reserved_flags() - test if address is in reserved region with flag bits set * @@ -102,6 +146,18 @@ phys_size_t lmb_get_free_size(phys_addr_t addr); */ int lmb_is_reserved_flags(phys_addr_t addr, int flags); +/** + * lmb_free_flags() - Free up a region of memory + * @base: Base Address of region to be freed + * @size: Size of the region to be freed + * @flags: Memory region attributes + * + * Free up a region of memory. + * + * Return: 0 if successful, -1 on failure + */ +long lmb_free_flags(phys_addr_t base, phys_size_t size, uint flags); + long lmb_free(phys_addr_t base, phys_size_t size); void lmb_dump_all(void); diff --git a/lib/lmb.c b/lib/lmb.c index 380d92a671..a38537af9c 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,27 @@ 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); +} + +/** + * lmb_free_flags() - Free up a region of memory + * @base: Base Address of region to be freed + * @size: Size of the region to be freed + * @flags: Memory region attributes + * + * Free up a region of memory. + * + * Return: 0 if successful, -1 on failure + */ +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 +634,23 @@ phys_addr_t lmb_alloc(phys_size_t size, ulong align) return lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE); } +/** + * lmb_alloc_flags() - Allocate memory region with specified attributes + * @size: Size of the region requested + * @align: Alignment of the memory region requested + * @flags: Memory region attributes to be set + * + * Allocate a region of memory with the attributes specified through the + * parameter. + * + * Return: base address on success, 0 on error + */ +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 +664,33 @@ phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr) return alloc; } +/** + * lmb_alloc_base_flags() - Allocate specified memory region with specified attributes + * @size: Size of the region requested + * @align: Alignment of the memory region requested + * @max_addr: Maximum address of the requested region + * @flags: Memory region attributes to be set + * + * Allocate a region of memory with the attributes specified through the + * parameter. The max_addr parameter is used to specify the maximum address + * below which the requested region should be allocated. + * + * Return: base address on success, 0 on error + */ +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 +725,24 @@ phys_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size) return __lmb_alloc_addr(base, size, LMB_NONE); } +/** + * lmb_alloc_addr_flags() - Allocate specified memory address with specified attributes + * @base: Base Address requested + * @size: Size of the region requested + * @flags: Memory region attributes to be set + * + * Allocate a region of memory with the attributes specified through the + * parameter. The base parameter is used to specify the base address + * of the requested region. + * + * Return: base address on success, 0 on error + */ +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 Sun Oct 13 10:55: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: 835068 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1536564wrd; Sun, 13 Oct 2024 03:56:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUYrsdypcQqsHG4Y6lZ0WKHGtKxVzDvCVfdLn/57lIXuJ98Y8VixnXRzlvO76vrK/yXVUOqkA==@linaro.org X-Google-Smtp-Source: AGHT+IFnkVGcBxjtsV42Y2RlIv9i88speZek8EhwA4cSFdOlnl24tAk/tz2UDSb659u01q9r3iJM X-Received: by 2002:a05:6602:1541:b0:834:f2d5:c758 with SMTP id ca18e2360f4ac-83a64d854c3mr361980639f.13.1728816967784; Sun, 13 Oct 2024 03:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728816967; cv=none; d=google.com; s=arc-20240605; b=ibDlpgXEjBO5ZRWw9jr5DOXP7cU2i7Ep+RS1JkS4epnU9PWrtAZXQsKN0wtiWa50w1 GWiPXw2oO8f0V1g6mzZLgqk8lDeaW7ZXlbr7DtS+M15vaUucLlD4ntLqzv/M5NoSzCKe 83aoNAifZFlvsXZVIazbMlkwf4II0mdKei9IMi3xftCJ2UiSv+KTGBRmhwsotzu5IlVw 8VSomAxu8YOSfAYBWtizUbkAbcEtRMtSaRFyAriDCLnxmNJ7SRy79Q0ahmHdTH5GR+Og BVFi5TkhLqUM8+DJhZy+btrDlCCE2F9ICJv3HfrPxHCcwEXD7ou8KRkuxUPoQd9Qv9Eg 0Xeg== 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=g+hH+4Vj2Ce7a2KzoQ79z1gGvNEheErbil/aM7hguMU=; fh=DqKFq13hCy9hcb48ZltPVvgEKSF1g1c/m42wn0WwlIc=; b=feus4K/OxqssdDDnmNg40QLzxrPx49bVl9lSg7qZdqNIHOAU28ySVesBrsBjxD+r9K iqGWk+4lH7bB6GzL9hnbar2noZPoi+4aLzIDALFZyiqOqYrqQelLM2uXlM+iOb/I7Ss/ ORcGq0X3nryUzQYm6BM/EVx24s0p2ouEY05Mh1sCw1nZdhuQlceYaVvKsVFJeb2LJUXE ZYyioMQdebXiagOP6br4LbpXabo/s8gVb/n4nLksEhTvNH5iXvdkaWgMhPh/QXUFE1uU WeZIFQz7Bueco2m/dW/97F/wW8S3Df9yfBC8607q02myMUREqEgzLvOn06zflaiIrYCC Ouew==; 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 ca18e2360f4ac-8354ba662c3si329623939f.115.2024.10.13.03.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 03:56: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 0065388ED5; Sun, 13 Oct 2024 12:55: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 3A4C288E6F; Sun, 13 Oct 2024 12:55:50 +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_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 46D0E88C7C for ; Sun, 13 Oct 2024 12:55:48 +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 57D771007; Sun, 13 Oct 2024 03:56:17 -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 3002D3F71E; Sun, 13 Oct 2024 03:55:44 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v3 02/15] lmb: add a flag to allow suppressing memory map change notification Date: Sun, 13 Oct 2024 16:25:09 +0530 Message-Id: <20241013105522.391414-3-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013105522.391414-1-sughosh.ganu@linaro.org> References: <20241013105522.391414-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 --- Changes since V2: None 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 0e8426f437..a76262d520 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 a38537af9c..e1e616679f 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 Sun Oct 13 10:55: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: 835069 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1536599wrd; Sun, 13 Oct 2024 03:56:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUdGIbSKzXBu3kL+GOBcPR79hWtAVobIaFV1lG7wlmHhwkWzU/RAl8qRDtj4i6Pvllc0bS4Ww==@linaro.org X-Google-Smtp-Source: AGHT+IEiCc+rfeLAtd5pEOeZ1K1DQiuSmFNbsG+LVon2Z/5aoIxXh2hptfeAFMZNU03Vxe/PzfdT X-Received: by 2002:a05:6e02:3b0a:b0:3a1:a57a:40a1 with SMTP id e9e14a558f8ab-3a3b5f233a9mr64448785ab.5.1728816977904; Sun, 13 Oct 2024 03:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728816977; cv=none; d=google.com; s=arc-20240605; b=Ot6DhtDibDp2/pNzCiHJB98JRP7QfCyhwDs9M2daA98sjqOy9IKzeHrUVOw9Z1FkTd b8wI1LT7JMlAflOBTNWP/FsjsLe/zsLupBH+TT0GzSYwULRtE8XKx8OkeX6kM0Dkiy0o ItIyuqw3qku7pnVdQf06ATjTRWNj26hnB7PWvYPRtF86lrORXwnHhruc53YoXIwXiWXP 7JqeienlkoeIg3hUVhyfVm0J1DOD0Yf6J4vEF8reCaLJpxDXr2nIOVHbu8wE+8I+VbXi wZxi5PG2HLmlK3T04gaGMaMvjO4c56Xs261jOSelw+EUA4lGwri3ehuUjPOzj5ddqO3Z A1Zw== 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=ZtJZQtn82CGJtQRdbdC0Z3sCVx2wGszfYkbKJtvtF6I=; fh=DqKFq13hCy9hcb48ZltPVvgEKSF1g1c/m42wn0WwlIc=; b=HA+HqAgWKYchMeAUtAJ8M6gVBZTCjl9Ly6367emvChrm23tTp5pU9gWiE0J8F6HFEU O1tOlG8TJBvhc/c/p4mYsYbYmvqRILjiSgAavOFRV6GUGJgyucF4rXHI100QO5fMYmN0 XgkSFo0Dy9DVU/950RhrYcIK83F6x3abpf/MEkJpbMVsif8hoBXa5BJ68uePs/GI3B9r eIMmaURpxbSh96WgAOoQ/diD0StCawnnEtK/b7YgzY3OEJMtolZ9rpPGnCLY+xjRh9L/ tJb7M8iY8aRIyh7h4vXeugI9kCI+HmmaARMH0O91GQV+RH9grmmjzEi248Ke1YCJDHBW Z0iA==; 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 8926c6da1cb9f-4dbadaa9b30si3624523173.164.2024.10.13.03.56.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 03:56: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 678BA88EC9; Sun, 13 Oct 2024 12:55:54 +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 A4B1F88DF5; Sun, 13 Oct 2024 12:55:53 +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_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 7B4B888E12 for ; Sun, 13 Oct 2024 12:55:51 +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 6D8B61007; Sun, 13 Oct 2024 03:56:20 -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 46BB93F71E; Sun, 13 Oct 2024 03:55:48 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v3 03/15] efi: memory: use the lmb API's for allocating and freeing memory Date: Sun, 13 Oct 2024 16:25:10 +0530 Message-Id: <20241013105522.391414-4-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013105522.391414-1-sughosh.ganu@linaro.org> References: <20241013105522.391414-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 --- Changes since V2: * Use map_to_sysmem() to get the user-visible address to be shared with the lmb API's for sandbox. lib/efi_loader/Kconfig | 1 + lib/efi_loader/efi_memory.c | 77 +++++++++++-------------------------- 2 files changed, 24 insertions(+), 54 deletions(-) diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 6f6fa8d629..69b2c9360d 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -20,6 +20,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..aa1da21f9f 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,8 +447,9 @@ 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; + phys_addr_t addr; /* Check import parameters */ if (memory_type >= EFI_PERSISTENT_MEMORY_TYPE && @@ -508,33 +463,37 @@ 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 = map_to_sysmem((void *)(uintptr_t)*memory); + addr = (u64)lmb_alloc_base_flags(len, EFI_PAGE_SIZE, addr, + 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) + + addr = map_to_sysmem((void *)(uintptr_t)*memory); + addr = (u64)lmb_alloc_addr_flags(addr, len, flags); + if (!addr) return EFI_NOT_FOUND; - addr = *memory; 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 +514,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 +530,13 @@ 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(map_to_sysmem((void *)(uintptr_t)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 Sun Oct 13 10:55: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: 835070 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1536626wrd; Sun, 13 Oct 2024 03:56:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX2ZIP+RvfhgkXoBByI3Q+uLKnI4VFe2kMygEmOXkT40NWbvaEhQzNvdGrl9fEWdRgR9IKzBQ==@linaro.org X-Google-Smtp-Source: AGHT+IFzgzd6gy7Ow7iLh/6QoIlSnbCJnvi/lKBaGFEz3eWmrU7xv91RBRD4gsl1oE9FbnA+1msO X-Received: by 2002:a05:6602:48d:b0:82c:e4e1:2e99 with SMTP id ca18e2360f4ac-83794969502mr942276539f.11.1728816987195; Sun, 13 Oct 2024 03:56:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728816987; cv=none; d=google.com; s=arc-20240605; b=LH6k8qbF+Ye8hgrIULq/Q5WcJG/xbd3GSKf9/ktSbrG4ALybZjP/pZjrUoeKIsvaY5 ag9Scd41dbnfA9QotwL6qlMCsFip0Wlywf1nUuWKuNrbpTh3mpZIt6ZhVgrX9eLWx0QV DyCxkmZqp5rg+3JoyFHIpYjexbGoBdRr5xCQLtUuo7P0AZDv9nwhMNYRM8Wc4wmmbyR2 ZQMtLfFS+tbBMJY+EUJ0Je7SqvHfXIp9fIdiFcP0o32zvGZk2FdKhktGseq716v9VK6V D0BV5Vcs4CYix7EdLtLBbRJU+Knmd3ajB8E2xHMEa9xK27Gmhmv5kdiVzr3g++tarZ9F zfnA== 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=gtwFGHa0zMihlk4x/vl2WYGuIrLEOt0hCrdJcrNYESc=; fh=DqKFq13hCy9hcb48ZltPVvgEKSF1g1c/m42wn0WwlIc=; b=Mc63DPULTOGsIIKKBFfEUKsAz0BXm23m8gnvRfW1nNWU3vw0IVlkFVROuZ9rtc4zKp 3ziv4uqwLCVZJ4RnGP+iuV34olztfRKjFL55vMqaTwjSpdQGVjW7DABMoXPMouNw90dL aY/FO5oo7adlf5db+WuPYPNVx3L8CECpf66NMQDg0vQvu0QSAGS9PIA/ZL8nVWjF0gaL rua8FB1r21OiQ1H2lp0kPxS8NzM7xKxZpJ9vdpi07hZfZoL4hWrS0Io6nJBJden6bOPI KnE6T+HoFIUa09p9MbO/UQsWP25/K2eu/dzy424tOppEjw/9UXN8ZVC8dFTKQPSZlfSw yeSQ==; 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 8926c6da1cb9f-4dbc70bef1csi1300509173.1.2024.10.13.03.56.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 03:56: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 C443888EDA; Sun, 13 Oct 2024 12:55: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 7CE2688E12; Sun, 13 Oct 2024 12:55: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_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 7967688EF9 for ; Sun, 13 Oct 2024 12:55:54 +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 849FD1063; Sun, 13 Oct 2024 03:56:23 -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 5D8593F71E; Sun, 13 Oct 2024 03:55:51 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v3 04/15] lib: Kconfig: add a config symbol for getting lmb memory map updates Date: Sun, 13 Oct 2024 16:25:11 +0530 Message-Id: <20241013105522.391414-5-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013105522.391414-1-sughosh.ganu@linaro.org> References: <20241013105522.391414-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 --- Changes since V2: None lib/Kconfig | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/Kconfig b/lib/Kconfig index 1dd4f27159..61452f7ac9 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -75,6 +75,23 @@ config LIB_UUID bool select SHA1 +config MEM_MAP_UPDATE_NOTIFY + bool "Get notified of any changes to the LMB memory map" + default y if EFI_LOADER + 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 SPL_MEM_MAP_UPDATE_NOTIFY + bool "Get notified of any changes to the LMB memory map in SPL" + 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 Sun Oct 13 10:55:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835071 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1536655wrd; Sun, 13 Oct 2024 03:56:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWI6SJWffIaywhOqBvZZaK3aPpQOboArq1WNezE671vbBYqvzOpU/xyD6oVMpOtRyBhL5KJCQ==@linaro.org X-Google-Smtp-Source: AGHT+IFNHvAFffZ1JPhPs/7qH/SVE2jfIHKjUhEGrLFV+8ga2KIVv6JhvpKeJqe+0U2sfFSDdEjQ X-Received: by 2002:a05:6e02:1caa:b0:3a0:bc39:2d8c with SMTP id e9e14a558f8ab-3a3bce0fc22mr33961025ab.25.1728816996600; Sun, 13 Oct 2024 03:56:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728816996; cv=none; d=google.com; s=arc-20240605; b=MrrWf5oMIQqO1HDt5Rs5uQ87kH+zig0aPo7lRkq5F0eKW27FGveexp3KgA5qjs7okK mD2mxhhGZN8+WpCsyqBjP65MfzA3aUszwYkJu7RCbnCx49hcaEpP0XLEDiMlbzSX3nde VBuOVAMoGoxhskrlj57xEFOMQkTrVfAM78pgiXfOpC4RzPcMa0PDAWro+b6UEMKGh5Bc rmbk6c2A2PnjSjnf8Soy0bIOtwBH6gHYUooLogOsHtAONfsbXDAwBqizUJqWSZmw9g5O P+R9jTGuOqXIi1/mkX6MqMiEe6iLhXQYVfVqz1zaOpW0QApW72Hiz9BwHzCNJCtgzqrK B+3A== 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=r4V/azlZEZZiY372mP6kjIwTenlGqBB9hvsGrtN4WuY=; fh=DqKFq13hCy9hcb48ZltPVvgEKSF1g1c/m42wn0WwlIc=; b=Wni54MkYdNHKXCJ2dt6ZP2JzeSjumQOsiM5M0g84Hv3ZhmmoE6d1ifB1jcz1wx2kKq oGb0Gc1AvMsQ1Ek0rvHB1rBd42ys9jB9/Yu7qH6F7N4+Lyi8LFNLN+RTztCS5UShXPyv HiOj4ZEr9MiaW4fhB3ffbSy6Al9zvri2xVVy1k5PrkphfHXXFPA1OcNn+qqLdeoZWxzx 1yqODbZq4lnSElnJ9R7Gn0t7xv5l2qyrQBvpkzD9jFQqQ4eME/rbGj1LHh59lVEarXeO Xv0kZlPfbjyuYUirmRPGG+EgndutssiSCilvEcmAqDjymD4DgVqz2UQ30aB6yHyvWs0D mnNQ==; 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 e9e14a558f8ab-3a3afdfb489si32888915ab.121.2024.10.13.03.56.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 03:56:36 -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 362B388EEA; Sun, 13 Oct 2024 12:56:01 +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 8003588EE8; Sun, 13 Oct 2024 12:55:59 +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_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 8C22E88DF5 for ; Sun, 13 Oct 2024 12:55: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 9BC081007; Sun, 13 Oct 2024 03:56: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 74E793F71E; Sun, 13 Oct 2024 03:55:54 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v3 05/15] add a function to check if an address is in RAM memory Date: Sun, 13 Oct 2024 16:25:12 +0530 Message-Id: <20241013105522.391414-6-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013105522.391414-1-sughosh.ganu@linaro.org> References: <20241013105522.391414-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 --- Changes since V2: None common/board_r.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/board_r.c b/common/board_r.c index 1acad069d9..4694f49a43 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -73,6 +73,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 Sun Oct 13 10:55:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835072 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1536681wrd; Sun, 13 Oct 2024 03:56:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXrWRdx3R9N7/8fbx3nNfBsD94CMJypTnBFP3QgdkFVPH7tCtRd4umdnrBKvZdK8effARn7Og==@linaro.org X-Google-Smtp-Source: AGHT+IETgjCnAuW68ZT/JV+EqbmnLeAn/reC8RSNUp9XshNqoXqrsQ4y+L6eYQj/bJfxE6Mu0XJW X-Received: by 2002:a05:6602:14cb:b0:82d:754:5026 with SMTP id ca18e2360f4ac-837928028c5mr701093839f.4.1728817005538; Sun, 13 Oct 2024 03:56:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728817005; cv=none; d=google.com; s=arc-20240605; b=eniFJj6LrTBo5S3rauEqz+oSJ+u0DyAAVgYI+AOgNfMmEwZrfq6vVLI8y5pFimf1nD Ke5w1tk2xVVbr87+Fd83PeTWIRiQ3uDuPvkA//t6Votr3az8utIcAs3mIi0fp+zr5h0z J0bgyRcnnOOP6LSraAYjgDiaAYbJjp+OUdm6sDfA/CIWwLhnSRHgu7dUfXF8VRIr0W+s 8qSxlV+08jyelCnS9RIMAIScCkOtS+PxFvf1xNWAYxbQpH6aVu7jDweLYgsduVTd1pZJ 8Sh/OlMOQ0gppuq/0kB/QhB+2rer/vYBhhlN7QI6PlHsZHYA9jf/KrM5tXipqtUSr0gG dmWA== 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=zGM+c1qVyZrZlYn0KkxRxPM7MhlNW6gMk9EEJtb2b8c=; fh=DqKFq13hCy9hcb48ZltPVvgEKSF1g1c/m42wn0WwlIc=; b=NyXz0ebVUMEBqFfyqhR/9XYKq6Tj7Rbntro6XkEc2mT7hvQtbj+HwfmHrnmB3aOyIN nHV5FuzZ/JBJqMcAZj5OESXaqsv7JGMF+NeVxeKSd6+5i692nXZkoe0jAX1+QmZVdE0j GimkTCmulOv1vgdulv85NiVPqdgD8mtHbc6l+fiwd7K2k6Rn1bfxsT5DpHeoyezWl5ot GcHjCkbF64rS6htQPBxL/+iXD0rTkVkJrXwL8GH/7KbtZi5Gwx4ks60o6z9chr7Q0SEy AQlycjoP3vxlamm0bNYBmOojGrshePdF7gBfvUc0/61jsVurxLzgamSb4r8BPv7aLzAf cz4Q==; 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 ca18e2360f4ac-8354b94c675si321927139f.48.2024.10.13.03.56.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 03:56:45 -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 A04AD88E6F; Sun, 13 Oct 2024 12:56: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 E998688EFE; Sun, 13 Oct 2024 12:56: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_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id A0CF188DF5 for ; Sun, 13 Oct 2024 12:56:00 +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 B34961007; Sun, 13 Oct 2024 03:56: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 8C4D43F71E; Sun, 13 Oct 2024 03:55:57 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v3 06/15] lmb: notify of any changes to the LMB memory map Date: Sun, 13 Oct 2024 16:25:13 +0530 Message-Id: <20241013105522.391414-7-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013105522.391414-1-sughosh.ganu@linaro.org> References: <20241013105522.391414-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 --- Changes since V2: None include/efi_loader.h | 14 +++++ include/lmb.h | 2 + lib/efi_loader/Kconfig | 1 + lib/efi_loader/efi_memory.c | 2 +- lib/lmb.c | 109 ++++++++++++++++++++++++++++++++---- 5 files changed, 115 insertions(+), 13 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 511281e150..ac20395718 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -784,6 +784,20 @@ 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); + +/** + * efi_add_memory_map_pg() - add pages to the memory map + * + * @start: start address, must be a multiple of EFI_PAGE_SIZE + * @pages: number of pages to add + * @memory_type: type of memory added + * @overlap_only_ram: region may only overlap RAM + * Return: status code + */ +efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, + int memory_type, + bool overlap_only_ram); + /* 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); diff --git a/include/lmb.h b/include/lmb.h index a76262d520..92e9aead76 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/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 69b2c9360d..2282466ae9 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -21,6 +21,7 @@ config EFI_LOADER 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 aa1da21f9f..41501e9d41 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -264,7 +264,7 @@ static s64 efi_mem_carve_out(struct efi_mem_list *map, * @overlap_only_ram: region may only overlap RAM * Return: status code */ -static efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, +efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, int memory_type, bool overlap_only_ram) { diff --git a/lib/lmb.c b/lib/lmb.c index e1e616679f..a567c02784 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -22,10 +23,55 @@ 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 int __maybe_unused lmb_map_update_notify(phys_addr_t addr, + phys_size_t size, + u8 op) +{ + u64 efi_addr; + u64 pages; + efi_status_t status; + + if (!is_addr_in_ram((uintptr_t)addr)) + return 0; + + 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; + } + + efi_addr = (uintptr_t)map_sysmem(addr, 0); + pages = efi_size_in_pages(size + (efi_addr & EFI_PAGE_MASK)); + efi_addr &= ~EFI_PAGE_MASK; + + status = efi_add_memory_map_pg(efi_addr, pages, + op == MAP_OP_RESERVE ? + EFI_BOOT_SERVICES_DATA : + EFI_CONVENTIONAL_MEMORY, + false); + + if (status != EFI_SUCCESS) { + log_err("%s: LMB Map notify failure %lu\n", __func__, + status & ~EFI_ERROR_MASK); + return -1; + } else { + return 0; + } +} static void lmb_print_region_flags(enum lmb_flags flags) { @@ -474,9 +520,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)) + return lmb_map_update_notify(base, size, MAP_OP_ADD); + + return 0; } static long __lmb_free(phys_addr_t base, phys_size_t size) @@ -530,11 +584,6 @@ 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) -{ - return __lmb_free(base, size); -} - /** * lmb_free_flags() - Free up a region of memory * @base: Base Address of region to be freed @@ -546,16 +595,38 @@ long lmb_free(phys_addr_t base, phys_size_t size) * Return: 0 if successful, -1 on failure */ long lmb_free_flags(phys_addr_t base, phys_size_t size, - __always_unused uint flags) + 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)) + return lmb_map_update_notify(base, size, MAP_OP_FREE); + + return ret; +} + +long lmb_free(phys_addr_t base, phys_size_t size) +{ + return lmb_free_flags(base, size, LMB_NONE); } 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)) + return lmb_map_update_notify(base, size, MAP_OP_RESERVE); + + return ret; } long lmb_reserve(phys_addr_t base, phys_size_t size) @@ -587,6 +658,8 @@ static phys_addr_t lmb_align_down(phys_addr_t addr, phys_size_t size) static phys_addr_t __lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr, enum lmb_flags flags) { + u8 op; + int ret; long i, rgn; phys_addr_t base = 0; phys_addr_t res_base; @@ -617,6 +690,16 @@ 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)) { + op = MAP_OP_RESERVE; + ret = lmb_map_update_notify(base, size, + op); + if (ret) + return ret; + } + return base; } @@ -786,7 +869,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; @@ -804,6 +887,8 @@ static int lmb_setup(void) return -ENOMEM; } + lmb.test = test; + return 0; } @@ -823,7 +908,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; @@ -851,7 +936,7 @@ int lmb_push(struct lmb *store) int ret; *store = lmb; - ret = lmb_setup(); + ret = lmb_setup(true); if (ret) return ret; From patchwork Sun Oct 13 10:55:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835073 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1536723wrd; Sun, 13 Oct 2024 03:56:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXAmMDZcou1ZfAYdJMxgi5WISzaRcHBg1k6OhX1qwkc0nvxkLJVinmawtqU6DutWS10fMt4Bw==@linaro.org X-Google-Smtp-Source: AGHT+IHuiHqYupu8k8Pt9N5CWevOlQXY/ygZXfU57M0o8j/fjLIW0Rb/PHNFQDhrw4QmI3VFOJ0c X-Received: by 2002:a05:6e02:1786:b0:3a3:b1c4:8197 with SMTP id e9e14a558f8ab-3a3b6053e14mr59038565ab.23.1728817015286; Sun, 13 Oct 2024 03:56:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728817015; cv=none; d=google.com; s=arc-20240605; b=f8hzae5LI8qjRSY+nN7O1VivnREmgDK9DQVfTsheKaQMujT5JDii5ubGhdqjkBgKzQ 0bwD8CEnyPCrhWHPoe9+8Ko5mjQuKcILwR029/DfuueRVowb5yX9Lwy2z++Cmv8Oo2Ju SKkMOuv+fgX3BYVKkVeo0TfpYWUajUQaG/ZoULLh6xGfnLxaC6x2gAMN4hTRqRq4OIYr 3ICoaWK2h5YAKC9dnkgjZWuWjPfN+dUcPGMlcvbI/1hhmqOv2v9TCYcigEOmyAkY3rRY 5mv89OfPVDit7fEHbt+3+sDKYwTXRWq9t40NFZ8UAFGy0+yvD/WT2+DTyGnuWRPys55I P4Qg== 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=VshRzv1jIB03s2+pAVxUMWFpF9nITeXsGoA5eYGhIU4=; fh=DqKFq13hCy9hcb48ZltPVvgEKSF1g1c/m42wn0WwlIc=; b=MYjZkyG9KnD8GMxnVlquCGi3g/HkDBs3PSC0/pJ8I2SbAdLxwuNGBHPdBbnQbjV8uh W1FTXBdx3bAYfNsPVw1cYxO6henGTdAmr1u0A0/uGXIiH/dT2jRS8FxO6P+0OhdtxmRG N3cY/sI3dq/3/A1ecy6kapQi0zY84TBjA214B1+2yS+bceZVqpZeuesYsiydHTdvluB4 QX5HQllKIHtPBl6DsSAx+D9CO7xnac/fIa8VAWXPQOOayU0aeb0QX21Olc0AdTM0NtwA 11eNHXv0lfZ7zPbLa3wmShx1rnaOrKiQVfIArv/XjkEdfi193KxWFxE+9+aRse4Uv5XQ Rrtg==; 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 8926c6da1cb9f-4dbad9dadfcsi3643404173.78.2024.10.13.03.56.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 03:56:55 -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 21A5F88F16; Sun, 13 Oct 2024 12:56: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 D371288F1E; Sun, 13 Oct 2024 12:56:05 +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_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id D69BC88F0C for ; Sun, 13 Oct 2024 12:56: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 C94991007; Sun, 13 Oct 2024 03:56: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 A31933F71E; Sun, 13 Oct 2024 03:56:00 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v3 07/15] efi_memory: do not add U-Boot memory to the memory map Date: Sun, 13 Oct 2024 16:25:14 +0530 Message-Id: <20241013105522.391414-8-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013105522.391414-1-sughosh.ganu@linaro.org> References: <20241013105522.391414-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The memory region occupied by U-Boot is reserved by LMB, and gets added to the EFI memory map through a call from the LMB module. Remove this superfluous addition to the EFI memory map. Signed-off-by: Sughosh Ganu Reviewed-by: Ilias Apalodimas --- Changes since V2: New patch lib/efi_loader/efi_memory.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 41501e9d41..16e64987af 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -870,16 +870,6 @@ static void add_u_boot_and_runtime(void) { unsigned long runtime_start, runtime_end, runtime_pages; unsigned long runtime_mask = EFI_PAGE_MASK; - unsigned long uboot_start, uboot_pages; - unsigned long uboot_stack_size = CONFIG_STACK_SIZE; - - /* Add U-Boot */ - uboot_start = ((uintptr_t)map_sysmem(gd->start_addr_sp, 0) - - uboot_stack_size) & ~EFI_PAGE_MASK; - uboot_pages = ((uintptr_t)map_sysmem(gd->ram_top - 1, 0) - - uboot_start + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT; - efi_add_memory_map_pg(uboot_start, uboot_pages, EFI_BOOT_SERVICES_CODE, - false); #if defined(__aarch64__) /* From patchwork Sun Oct 13 10:55:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835074 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1536753wrd; Sun, 13 Oct 2024 03:57:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUritFRZRHJnpijFykv3q6kDLchpzq8WgtnR20GHYDh5ienXrkK5m07hm8ICXz3XNnYXwvNxg==@linaro.org X-Google-Smtp-Source: AGHT+IEWPpoOSJ8AAGNDA0lTCqs8baxtU3PbLcmKuCsff+NQgnR0zHvTzLslfy1LdjrNYM/ilY7m X-Received: by 2002:a05:6e02:1566:b0:3a3:a639:a594 with SMTP id e9e14a558f8ab-3a3b5865e13mr51559425ab.4.1728817025728; Sun, 13 Oct 2024 03:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728817025; cv=none; d=google.com; s=arc-20240605; b=G86EMEkxGJaDRSf9+75eHyrkHvYwYMYt1mhxnnFAYS8SscGzepfVDaYdmP/zfYgIjx LZ1GK0Yqph5XMxRr1j5Y7KMo0+snU01KDlNc65xFCHnORoF0popG4ECmT5im8ZOcHngf mVZYcp3DCj5wnM8aIf7aW1tBJVUxKSMadVwhHDx1JLC99rtSaX1ezYT+mXOKm8o5KhV7 fesoV8/W/gjG9nwhIz1c8SJ9QpyBvlf/gkdWC3r2GTta7BRmJ6TDEYuTF3n5Ovf7ATiu qEUALA2VpQ5dswAiF1TDWGdMTEwJMkvKYj7BTeRM2ytfMmRRnsNIwmhCr1djq3Eeh53K Lr9w== 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=tzxKT8u6JAbTmuPqCCvYHHam9KfzWCV76Qcq2S5lEns=; fh=DqKFq13hCy9hcb48ZltPVvgEKSF1g1c/m42wn0WwlIc=; b=aQi5I2Wr+bM94dhQiAKtMLOmt86QiRnObvXImazMV8DjbXelgene0ta9yll6fqYljQ dtzDVOF5Kb0jo0hVKuFI/cWF7P9fKN+DuQ/STFB1dcEUjC5g4V800o+wY3NbslBuAZQf ZAdb//M5pxNTad3u1UbMeCnZD02eyinx0J5++/RsCLQwohKAy7/7txlGi2SCyzfm28+w bhfsqADVV5Ysj34bug7BiaxSHVA1biIiUNjmuDYwgI8l+2o+/hYU/7/jix6zWWpc7tvl +DCEyLB+vVrAcRpAoO2zXAMqh1kyNlDsXXwV05+b1dXyDG063X7tqHdeoZRqfvpoPLXi sY1w==; 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 e9e14a558f8ab-3a3afdfb4d9si32379195ab.105.2024.10.13.03.57.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 03:57:05 -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 7F5EC88F44; Sun, 13 Oct 2024 12:56: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 BE98888F44; Sun, 13 Oct 2024 12:56: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_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id CD03D88DF5 for ; Sun, 13 Oct 2024 12:56: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 E09291007; Sun, 13 Oct 2024 03:56: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 B9C1F3F71E; Sun, 13 Oct 2024 03:56:03 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v3 08/15] ti: k3: remove efi_add_known_memory() function definition Date: Sun, 13 Oct 2024 16:25:15 +0530 Message-Id: <20241013105522.391414-9-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013105522.391414-1-sughosh.ganu@linaro.org> References: <20241013105522.391414-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 Reviewed-by: Ilias Apalodimas Reviewed-by: Simon Glass --- Changes since V2: None 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 Sun Oct 13 10:55:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835075 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1536799wrd; Sun, 13 Oct 2024 03:57:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXy9Q/RbQqgn9pRyXDSbGv+jctckrKP5Djj48ht5DRW0GDLUmXq/l99V/KSMtpO5MBJMlr8mA==@linaro.org X-Google-Smtp-Source: AGHT+IG3cJr+sC8/d190BjOLTmAxPPyn2MwWxX3ELSxQPycB9cBnRrWUtsbfMeALkAOUm3RVNMIU X-Received: by 2002:a05:6e02:1fc3:b0:3a3:4122:b56e with SMTP id e9e14a558f8ab-3a3b608711cmr46514385ab.26.1728817036655; Sun, 13 Oct 2024 03:57:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728817036; cv=none; d=google.com; s=arc-20240605; b=K5XvMqrkbIy8/1my1BGIJwwc59TvrVXo7xQKhqRRAHRsJVd7g1jtenJnHVDu9rjdop 6K+rikzuTspQ/aVpfEYu8Dkd8Ag0n7W6kGkj6Gxdbmxe50y7T6cWJqjNoW7BUhY+aKLv MCiAC9ZK2foDlaqIw9TVEiQZm9gnrkqt3La7M4GTNI8jNhqb/0cCFjk5VAOR9Yl2x5sV yiqGttFan1akuHn0JoUzIDhJGpopiljwnt3qcs63D/PzlQ8jEplejjNBFHp0zN5qMF/P SmXiPWL1FfbxYCaabJqaIjzvdhx105iMonw7+7XUx2UPKlfxu2D0ELQI7YJTqxBDZMMo 7Vmg== 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=i1sptK0Ecp2Af5IAIT+wepN4TX+iikAdUAt0bzVPDVw=; fh=DqKFq13hCy9hcb48ZltPVvgEKSF1g1c/m42wn0WwlIc=; b=e2PUF/JYk/BYHCFdY5pfwlobpvhqbNzd7nfydf1NLMl0NBF48BGY4kp6sDLlk8RPL1 jcrZmULs9ZvJEdFzYXDz6u41/6mbwLMaSSwjGGMqRbjkiyrYtrrjj3Ho4oFwLlHniELQ jcW8rOR08gBDi1QdI57hJ5yGOjzAk4TRGtv2XaUmttW+QRU2nK3ZJIhpUTEmZ6MRb1OW H5bhTE3mMXXxVbzwxPZTXuq7uBL4byCXkjIae2/E5xmfSaEf9sOcI483Xk0N27bD9Kau 1qh6hSInw/AdkaHKIzopGuhgDjD43QE6lSYWP0Jl3Psa4RHo3nXFnAFas5S98imrZrur g7kw==; 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 e9e14a558f8ab-3a3afe136desi33745425ab.177.2024.10.13.03.57.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 03:57:16 -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 C24C488F55; Sun, 13 Oct 2024 12:56:14 +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 60DCF88F4E; Sun, 13 Oct 2024 12:56:13 +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_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 661FB88F23 for ; Sun, 13 Oct 2024 12:56:10 +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 03E331007; Sun, 13 Oct 2024 03:56:39 -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 D068C3F71E; Sun, 13 Oct 2024 03:56:06 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v3 09/15] stm32mp: remove efi_add_known_memory() function definition Date: Sun, 13 Oct 2024 16:25:16 +0530 Message-Id: <20241013105522.391414-10-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013105522.391414-1-sughosh.ganu@linaro.org> References: <20241013105522.391414-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 Reviewed-by: Ilias Apalodimas Reviewed-by: Simon Glass --- Changes since V2: None 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 Sun Oct 13 10:55:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835076 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1536852wrd; Sun, 13 Oct 2024 03:57:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU+FBOrfAzZAVi2JJ+h4p3amOO3Z32ZhNJGzrZRvUB/SxbSp2NOd78+mom4DfDMH0kVzpz56A==@linaro.org X-Google-Smtp-Source: AGHT+IGrOLZG6GpL/CGgPadTNeHGx+oENoyceozN/qYO5kKux3AbmFUtUvccQQYV0xxVVXBo+CcZ X-Received: by 2002:a92:ca4d:0:b0:39f:5abe:ec25 with SMTP id e9e14a558f8ab-3a3b5fb3181mr52794235ab.19.1728817047256; Sun, 13 Oct 2024 03:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728817047; cv=none; d=google.com; s=arc-20240605; b=gkvxsEbV9PwZqomBh8+O/9TjtLZlhnHgg1Tf8NKqkjOOQWL8/IIgCeHHNy1oh8z/cn dm0Paw2zulwOvKG8PW9LmUwqsU7YQk2O4RMegJrXLyZpBzIfVaz8W7S40lb5/40YEw+c POkIHp5n0YwKtJnlRwxN3u3SM2cXWOImaIK3+hBsG/PIB5euMj32t/ljEIB38BSdqyIu bUwKzoeUr8jmkD3DOb2BW+t97HmPwvViYZP5tdjgOSt/BCpJBYobM2IrMkFErOs0lvXl aaDEuS2rodxG4MzExWUUAJNATFwDl1w/87GOpIBxOuoI/qvAyWhYsRSRX+lrcH9GVS72 xYdA== 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=Hdxa1jOr+Spacsb+CfP18+hsTSmzAaHOdCGOnEk9RuM=; fh=DqKFq13hCy9hcb48ZltPVvgEKSF1g1c/m42wn0WwlIc=; b=L5GssLjJavKgHn8CwBUcOC3CS/SaEQj/+qFkEXjG9AhdpTByW4SEEDpUsdUj1lo+VA h3KU2nEk9wCS0EY6s93u1kFE8mNdFTdN7VVticq7nB4Fi5tc32BB/y9i9bx7xJgW9sz+ mjTlIuXI3goC77q9wlFz66fPjx8vsz4kiWoEn1huIErHtdUmZ79pyPHpnREcROdowzB7 c1+LKVRhzX0QDRz/BA2mGjedzEgpyOQdZJbte8Y1EMln56q1nM3+GiYW2GHEFFX0Dkdc VXJhKbR5hIlH8hP7++Q85lQdHQgYWCGnC9+MDtVAHU2i7N+C4JOPeZ6of9Wt8E2wPKDA 4ePQ==; 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 e9e14a558f8ab-3a3afe0d91csi33364395ab.145.2024.10.13.03.57.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 03:57:27 -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 A267E88F3C; Sun, 13 Oct 2024 12:56: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 6EB3888F57; Sun, 13 Oct 2024 12:56: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_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 083B288F4D for ; Sun, 13 Oct 2024 12:56:13 +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 1ACBB1063; Sun, 13 Oct 2024 03:56:42 -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 E823A3F71E; Sun, 13 Oct 2024 03:56:09 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v3 10/15] lmb: allow for boards to specify memory map Date: Sun, 13 Oct 2024 16:25:17 +0530 Message-Id: <20241013105522.391414-11-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013105522.391414-1-sughosh.ganu@linaro.org> References: <20241013105522.391414-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 --- Changes since V2: None 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 92e9aead76..a63c75eda8 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -166,6 +166,8 @@ long lmb_free(phys_addr_t base, phys_size_t size); 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 61452f7ac9..100c4e5c25 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1132,6 +1132,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 a567c02784..c08ab2223a 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -331,6 +331,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 Sun Oct 13 10:55:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835077 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1536887wrd; Sun, 13 Oct 2024 03:57:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWzumuz9Ty8C1bfdhZ3wKciAzbPBbb6fagDQ1k8zfEIa3JDX3kp6bpjSJG0Xb95juOtoJSNLg==@linaro.org X-Google-Smtp-Source: AGHT+IFET1h5rEtWwdmjBuR+rApjUq8xm1maMG5yJYrTJlIj7qTkwOc4ujbkZJhueuRomp+rGn8c X-Received: by 2002:a05:6602:150c:b0:82a:4419:6156 with SMTP id ca18e2360f4ac-83794d484cfmr662106839f.14.1728817057546; Sun, 13 Oct 2024 03:57:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728817057; cv=none; d=google.com; s=arc-20240605; b=Z/qRrhCjVS09Ji4zpvF24XOA3qDco4pTlc611URqJvJRGUDnu0SRZ3TmM3MIN89z1B VM9OcFMtWOR5p4NT/LIobZKMD1G6hyeSunSIpgiUiRxJ8vT709GKfc3xP4EPOV9DbTKM R45CVZC+OfMOMPCw+nrWRp2ilngJiQHfghHDUJsbYARElglGI5KiiWrOJss9THHHheiy Nb9MqaPQToFW77Os12f7lSnJfJbVzSA2pu2EYFK5eTcIGmu+fztLhmmHO80ZNohGAiHL YJi6wF2bOuMWwpKjlMh7H7innewlJdUsvD0sxgLOoSSs3Nh0/KU7GLT1Y3OQI8PE2SNI sucA== 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=JNgKYH4N+pB0nMynAdn9XgDjfNLWGprMR14NGEGzfgE=; fh=DqKFq13hCy9hcb48ZltPVvgEKSF1g1c/m42wn0WwlIc=; b=S2GbxMy8zwVXi8FwID9jI1HVpnfdTpKpXv8W1CuyqhTOkJsfLLnBFyF2GNC+CstzPQ SdYvlOmhq6qO8adwTNuV37EBJ9qx3i1/KwxQHKuXyD72BOX3I1Jd2kQ7qXH69HOMLuE6 uwgSTvfrS0He9sqG37ik01JDf94qCmgniCdh3niz+msdmxUBJYdPn/HN/GT59eWPGwbV aBAzkk4CrOG3jjgyQcWYjScMeyYEBvr3pCdR/Y6A9SFTocuUK/TsWBkCj0BGVoC0iyHb cPT2qid33XvRLXSgviGRCz7lViBl1LChYr8+XhxHx0QCq49Vy3ng4W9c8ALGufpiZWw2 9jkg==; 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 ca18e2360f4ac-8354ba68764si324728439f.130.2024.10.13.03.57.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 03:57:37 -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 0BB9688ECB; Sun, 13 Oct 2024 12:56: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 259AE88F4E; Sun, 13 Oct 2024 12:56:18 +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_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 1F48588F24 for ; Sun, 13 Oct 2024 12:56:16 +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 321531007; Sun, 13 Oct 2024 03:56:45 -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 0B3713F71E; Sun, 13 Oct 2024 03:56:12 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v3 11/15] layerscape: use the lmb API's to add RAM memory Date: Sun, 13 Oct 2024 16:25:18 +0530 Message-Id: <20241013105522.391414-12-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013105522.391414-1-sughosh.ganu@linaro.org> References: <20241013105522.391414-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 --- Changes since V2: None 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 f9c2083677..d2d3e346a3 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 100c4e5c25..3796adc453 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1135,6 +1135,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 Sun Oct 13 10:55:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835078 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1536922wrd; Sun, 13 Oct 2024 03:57:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUphdW/1gbvdHxSWbbWDcXOxtvl1xxJipY6TKxIg4m8kSI1+VbpUPCcYqjXIbYBs1Di9fMrLQ==@linaro.org X-Google-Smtp-Source: AGHT+IFtGzyUqlGTlaCHd+st5oLV7QTFukdF0NYvDUrMl6pf5TScMgpOiUmCHSHkH2iVAG94KZuR X-Received: by 2002:a92:cda4:0:b0:3a0:98cd:3754 with SMTP id e9e14a558f8ab-3a3b5f237d3mr65154435ab.4.1728817067095; Sun, 13 Oct 2024 03:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728817067; cv=none; d=google.com; s=arc-20240605; b=ATTDARR+vF8A7J8Ibr2ksPc866LtxAtmm2bu6R3noiRuaZowmDpnahf/ZI2A1fBG+q bFsJaEkpxkezJb7TmRZf3+riwkJoL4CRmnbUbbr555bM6GdGe5yn0yJyxuscd0xhozzB clKVvdx8zskCgB3AgJ9xZJvBPzaGlx8EmljK2WPEjQTHeOz+lbzll6HCDJcDfCeQeuaF Xd63DNM6x84DH4FUxKhzIm967zWpU4xg/RyyJvhjvb1MiEaTbn2ykK66FKpA7nevpVgF 3WOcWH8WS70mo/+mdXJrghVMEEpW2r1owMgMb+rko1dbC7oVBLWp0XMDdBZO9jWla8uT cpuA== 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=bj780gN10bGrS8m+AIWDyNmAxTseqt+zCOcuhZuLrIQ=; fh=DqKFq13hCy9hcb48ZltPVvgEKSF1g1c/m42wn0WwlIc=; b=ik+0ahkCOdl/Y4My3ZE9CwFjuwV96truGz/nAavp3X4PtdeRzPzxCif+jiMVL6oFjK vxdckdoVRiI5t2et3cHJ54J3iX7Pdt5syV6noKhf/MgVX4tWl06rliYEu8Rkk6UIlgvL GBEd6vPWQMEt5Ol1CQgNvievwmK4aIaZiDrQlaU9veYqr6Ur2O3r9aguPfNw2O1CK642 +7petXRM1BKUuhztHlUwwerSSrZNZYNrUhXZBQq6jhxItcKCRLMrzk/D+7ebQ7xhnKOu jCk7z7wR5O0hwoowNKYPqQHa7MZX/Onxno3tBxhcaZJeT4BL4LyncEDR5WvuxlNvSyx6 L5/Q==; 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 e9e14a558f8ab-3a3afe13889si30003255ab.178.2024.10.13.03.57.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 03:57: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 71AC988F66; Sun, 13 Oct 2024 12:56:22 +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 357EA88F57; Sun, 13 Oct 2024 12:56:21 +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_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 36D0588F35 for ; Sun, 13 Oct 2024 12:56:19 +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 494621007; Sun, 13 Oct 2024 03:56:48 -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 21FEE3F71E; Sun, 13 Oct 2024 03:56:15 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v3 12/15] x86: e820: use the lmb API for adding RAM memory Date: Sun, 13 Oct 2024 16:25:19 +0530 Message-Id: <20241013105522.391414-13-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013105522.391414-1-sughosh.ganu@linaro.org> References: <20241013105522.391414-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 --- Changes since V2: None 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 3796adc453..269a952031 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1135,7 +1135,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 Sun Oct 13 10:55:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835079 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1536950wrd; Sun, 13 Oct 2024 03:57:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVIlC1R9CedFTNyEDUMR9Wh8ZNMRxxHe4ZKDyyBsYsBuGOij9Guw87lcYWjzB7TFJizptETtQ==@linaro.org X-Google-Smtp-Source: AGHT+IFGq5mqcr0xUqRo5/RgAtZHex607yfiUqTrAGdKOV9FafKtx16E2jc8hbRU/xwZ1WiDwz0U X-Received: by 2002:a05:6e02:2163:b0:3a3:b143:98 with SMTP id e9e14a558f8ab-3a3b5faabf5mr52630905ab.15.1728817076919; Sun, 13 Oct 2024 03:57:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728817076; cv=none; d=google.com; s=arc-20240605; b=OvXhr85D3m8sjSAVOLj//OelKx6EsOfQr0KwX0+w50eLFXt72GMu4pEa73IeYa7vOi LdiOGXl76BxtSnM5GtNoXxXKwuk65ZFwNmGX+CAmRBX7/le/UqijfWqGi7ZZsbkm+X0V tgO+JQr1NjQNAoMER/zJT5LkllL31YaTUYBw/6yi2bU+nr3uZPc4vbvv0Z135BW05NCY KoNbf2SIU3ik9yWpSluBGvmKCcgEqXxrI6OMo4ecTTlPAPW6VG2WIB2v9cwQyt6X18km ibnge7Dq/ZlI2CxAMQMoXtYNvP0zJyHabbEEoyBM+oVqMbLiuWrH6ZF7t87ozF8NtWdK ee0Q== 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=A2JD8iRvCXOGGOgX+t4+2GDvXO2KWhDkNu8VyU2Z9Js=; fh=DqKFq13hCy9hcb48ZltPVvgEKSF1g1c/m42wn0WwlIc=; b=hewnd/LnNbcFt7Ax5rCNjyMBiQwsYwJRvngkWtm87IclSKHU5PG6PjdVKh7pRzSsPC Y49eDDyncvNLrxykKTyv4VhQoJeQtnq2yFks9ri01I/AuZ095kzRLAbEK+Ykztt8UEFa 8qKq/G+sURsELEpg4MvahlPaDO0Xi8zyNGk8Vw3Pq1bL4tlohBDljkAQYKkHqV9DdHip exzTJU39a70zTfcBkeggtJTewUYMrtcDJKITEl/TYdfi15/3D2kbkpyIOBLa0sj0yJ1I W+o1XPZB0yZkm6O0QGNJws30odNa8PBolGavs1I9eHLG8nyNmh7vi65Znc4luhVTWl/y iLiQ==; 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 e9e14a558f8ab-3a3afdc7173si33021315ab.38.2024.10.13.03.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 03:57: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 D388888F3F; Sun, 13 Oct 2024 12:56:26 +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 79D0B88F3F; Sun, 13 Oct 2024 12:56:26 +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_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 4D28E88F5B for ; Sun, 13 Oct 2024 12:56:22 +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 604501007; Sun, 13 Oct 2024 03:56:51 -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 396B63F71E; Sun, 13 Oct 2024 03:56:18 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v3 13/15] efi_memory: do not add RAM memory to the memory map Date: Sun, 13 Oct 2024 16:25:20 +0530 Message-Id: <20241013105522.391414-14-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013105522.391414-1-sughosh.ganu@linaro.org> References: <20241013105522.391414-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 Reviewed-by: Ilias Apalodimas --- Changes since V2: * Fix the wording of some comments in efi_add_known_memory() as suggested by Ilias. include/efi_loader.h | 13 ++++--- lib/efi_loader/efi_memory.c | 77 +++---------------------------------- 2 files changed, 13 insertions(+), 77 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index ac20395718..6b9a66a06c 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -798,10 +798,6 @@ efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, int memory_type, bool overlap_only_ram); -/* 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); /* Called when a block device is added */ @@ -1186,9 +1182,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 function is to be used to add 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 weak function may be overridden for specific architectures. + * This function may be overridden for architectures specific purposes. */ void efi_add_known_memory(void); diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 16e64987af..f59f7780e9 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -783,82 +783,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 add 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. + * This function may be overridden for architectures specific purposes. */ __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 Sun Oct 13 10:55:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835080 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1536987wrd; Sun, 13 Oct 2024 03:58:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUR2XnIBdyPhJ0qoGIp18R3scAXZOy7GYZSheTHUcTtCcrHHNfLc4pn4t6p3WeuV+OH5cnKjA==@linaro.org X-Google-Smtp-Source: AGHT+IFMoP4iJwrmoILqhJ8x8APJ0X1q7MF/rqVbWBU2DlFJmoetYdfbbR+jlImYGKZlnpsBC5Y1 X-Received: by 2002:a05:6602:340b:b0:835:4cb5:4fa7 with SMTP id ca18e2360f4ac-83793fa4e1fmr634833939f.12.1728817086953; Sun, 13 Oct 2024 03:58:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728817086; cv=none; d=google.com; s=arc-20240605; b=ajLalcGO8oCQqnpAss3rSLrDlRLhaOQjvfLo68cRXKeOkrXCJbj6AjvjyKSbLPNkOU HcPo6TYKG8Fh1urDcnnERsvNIcY6/Ivl+4o+sLMyoZ9R/iNTa+JkpxPFYtXud34hycMJ eMPL6Kp7E945oRln8ul3Co7i04ZZHuOYh0JpUcqA+2zvhpA9Pct/WJPeof5tQeZM9HAZ kbw9DhOdu/rT+Ml39j2CqeV2d0cx0tYgBbpPT52jm7jympdYVSScrmjhYCKj1VnoQJRN YkT/bAjbTYaYBfpP56AhmjeHoFRqeOKiaTz7UfQeDtM3Al8PGkUss2cOrGgxtx/yxfl9 04bQ== 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=/wiNHYzjmcEvWRPlfzKkh71Qp5ObUpNfgBOhTdBjAac=; fh=DqKFq13hCy9hcb48ZltPVvgEKSF1g1c/m42wn0WwlIc=; b=b+IW6+FLJJI5UqS3Y0Z3PmOsi/USu4fDCTy3ugjRhdwqXjoq8tQr+AtX/GupfTMHUh 8Kl3kxdtII0AHQwrw/QR/TEYwLUHW0fwuDuBxyfEbCE1DlMn+jVYOALSaqitCrssv8IW OaDx7vHYjhBtMVpYtOvq0WClPh9Wm5U5yw8nQBMheB96CaGmEZrhUpnrTcZZiABDGQOP le4ZzujEMSFfFacVL/m//IysFXU76/UiCLbjoNovqaqjrmjhFNrHA3iVuOKtWsBdb14Z W2cCnSQDjcqwHohDL8wQe5fxN1gmSCC9KySoeWecM+h0YxB61u0ZhZXqSjkjAzSqez1B 5CvA==; 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 ca18e2360f4ac-8354ba3d318si306462639f.87.2024.10.13.03.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 03:58:06 -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 3F1F088F68; Sun, 13 Oct 2024 12:56:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 8B83688F82; Sun, 13 Oct 2024 12:56:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 76A7C88F5E for ; Sun, 13 Oct 2024 12:56:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 76EFB1007; Sun, 13 Oct 2024 03:56:54 -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 502F83F71E; Sun, 13 Oct 2024 03:56:22 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v3 14/15] lmb: remove call to efi_lmb_reserve() Date: Sun, 13 Oct 2024 16:25:21 +0530 Message-Id: <20241013105522.391414-15-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013105522.391414-1-sughosh.ganu@linaro.org> References: <20241013105522.391414-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 Reviewed-by: Ilias Apalodimas Reviewed-by: Simon Glass --- Changes since V2: None lib/lmb.c | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index c08ab2223a..ba9348dd31 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -208,38 +208,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; @@ -286,9 +254,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 Sun Oct 13 10:55:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835081 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1537025wrd; Sun, 13 Oct 2024 03:58:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX5/ggPO7glIgBfE6PP37ZuYmcffhKbd5fVzXEQDCOiYaFHQQRLGoV8pTxD2hpz+SU9ViTgSw==@linaro.org X-Google-Smtp-Source: AGHT+IHpUDmK68GII0OooXLXGeuPU5LXXG5q21XvJCyeRkcDutbS1ORZYni87K/1+F3QhLopWv+W X-Received: by 2002:a05:6602:3429:b0:82d:581:8860 with SMTP id ca18e2360f4ac-83794a62937mr551657839f.12.1728817096516; Sun, 13 Oct 2024 03:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728817096; cv=none; d=google.com; s=arc-20240605; b=JLitlrFhqc4IgW4nsVxKrdJHOFfQyvwOaU2MDt1She79RE4gWAH94TeO3fujY8QnWh BThcmC0hJfm54AKmd3D8L001ZduHHhfrenATz8rTjkXTekpydzuI7kRk1DGzw0fxy5mE KNGqiFbtSmhPc10v47He9gSXp1OSNd/qILJE/VBCU4ELHkVpdq0sA5dT3tqmUfElJaah DpPxzOkblxv0IwA9IcjzHf1UU/qyE1BOouRp1PjbszYQoH66uWQYLDTe1t7YdiXkO459 FXsLSDlhPTnXgjxISACBpb6x8JRYezaMOx/13HFx2BwW11IyyoeCvVrY5iOzdFMIQ90/ tCkg== 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=co8ivy0WdkY3el2fhyIGlv9vtcnUoTRRU6OyI6O7/R8=; fh=DqKFq13hCy9hcb48ZltPVvgEKSF1g1c/m42wn0WwlIc=; b=YByNxQiJJZ5iNnChUYisqZ0iTGGJ/qQrwwDxsJ0vp6ULscgaHk+QdzhhsixwYVrytw KY0N+DcIHT0UdgdetEH6hMnlfbkDP/XM/gCLn4422gh9xUPDhbAfx8/GXRrvmW9RF25y YpWaJQtVBzT5DTs3cJc2f8cRLm2gFQxHkvE7dPJSxzm1xstr/O1lK1BLoHuMXbB6mNR9 Js6MWIonq3mKd8+sfUTCI+RtCaMShqM+eE3dP5fPQipQ30cJPzb3mRz2HPs9K9MamEOv AuS4jfxAcl1JL07S5gIvUP5S5uMesBwh/0UOnmR131wTvOcrSPi2NLjNtCmdgYvV+TzI rxiQ==; 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 ca18e2360f4ac-8354ba6764bsi319344939f.119.2024.10.13.03.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 03:58:16 -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 BA50888FB7; Sun, 13 Oct 2024 12:56:32 +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 AF07188F5E; Sun, 13 Oct 2024 12:56:30 +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_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 7BB9A88F85 for ; Sun, 13 Oct 2024 12:56:28 +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 8DC6A1007; Sun, 13 Oct 2024 03:56:57 -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 674DD3F71E; Sun, 13 Oct 2024 03:56:25 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Sughosh Ganu Subject: [PATCH v3 15/15] efi_memory: rename variable to highlight overlap with free memory Date: Sun, 13 Oct 2024 16:25:22 +0530 Message-Id: <20241013105522.391414-16-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013105522.391414-1-sughosh.ganu@linaro.org> References: <20241013105522.391414-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 variable overlap_only_ram is used to specify that the new memory region that is being created needs to come from the free memory pool -- this is done by carving out the memory region from the free memory. The name is a bit confusing though, as other allocated memory regions, like boot-services code and data are also part of the RAM memory. Rename the variable to overlap_conventional to highlight the fact that it is the free/conventional memory that is being referred to in this context. Signed-off-by: Sughosh Ganu Reviewed-by: Ilias Apalodimas Reviewed-by: Simon Glass --- Changes since V2: * Rename overlap_no_freemem to overlap_conventional as suggested by Ilias. include/efi_loader.h | 16 +++++++----- lib/efi_loader/efi_memory.c | 51 ++++++++++++++++++++----------------- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 6b9a66a06c..291eca5c07 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -788,15 +788,17 @@ efi_status_t efi_add_memory_map(u64 start, u64 size, int memory_type); /** * efi_add_memory_map_pg() - add pages to the memory map * - * @start: start address, must be a multiple of EFI_PAGE_SIZE - * @pages: number of pages to add - * @memory_type: type of memory added - * @overlap_only_ram: region may only overlap RAM - * Return: status code + * @start: start address, must be a multiple of + * EFI_PAGE_SIZE + * @pages: number of pages to add + * @memory_type: type of memory added + * @overlap_conventional: region may only overlap free(conventional) + * memory + * Return: status code */ efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, - int memory_type, - bool overlap_only_ram); + int memory_type, + bool overlap_conventional); /* Called by board init to initialize the EFI drivers */ efi_status_t efi_driver_init(void); diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index f59f7780e9..b63b5cca71 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -173,17 +173,19 @@ static void efi_mem_sort(void) /** * efi_mem_carve_out() - unmap memory region * - * @map: memory map - * @carve_desc: memory region to unmap - * @overlap_only_ram: the carved out region may only overlap RAM - * Return: the number of overlapping pages which have been - * removed from the map, - * EFI_CARVE_NO_OVERLAP, if the regions don't overlap, - * EFI_CARVE_OVERLAPS_NONRAM, if the carve and map overlap, - * and the map contains anything but free ram - * (only when overlap_only_ram is true), - * EFI_CARVE_LOOP_AGAIN, if the mapping list should be - * traversed again, as it has been altered. + * @map: memory map + * @carve_desc: memory region to unmap + * @overlap_conventional: the carved out region may only overlap free, + * or conventional memory + * Return: the number of overlapping pages which have been + * removed from the map, + * EFI_CARVE_NO_OVERLAP, if the regions don't + * overlap, EFI_CARVE_OVERLAPS_NONRAM, if the carve + * and map overlap, and the map contains anything + * but free ram(only when overlap_conventional is + * true), + * EFI_CARVE_LOOP_AGAIN, if the mapping list should + * be traversed again, as it has been altered. * * Unmaps all memory occupied by the carve_desc region from the list entry * pointed to by map. @@ -193,7 +195,7 @@ static void efi_mem_sort(void) */ static s64 efi_mem_carve_out(struct efi_mem_list *map, struct efi_mem_desc *carve_desc, - bool overlap_only_ram) + bool overlap_conventional) { struct efi_mem_list *newmap; struct efi_mem_desc *map_desc = &map->desc; @@ -208,7 +210,7 @@ static s64 efi_mem_carve_out(struct efi_mem_list *map, return EFI_CARVE_NO_OVERLAP; /* We're overlapping with non-RAM, warn the caller if desired */ - if (overlap_only_ram && (map_desc->type != EFI_CONVENTIONAL_MEMORY)) + if (overlap_conventional && (map_desc->type != EFI_CONVENTIONAL_MEMORY)) return EFI_CARVE_OVERLAPS_NONRAM; /* Sanitize carve_start and carve_end to lie within our bounds */ @@ -258,15 +260,17 @@ static s64 efi_mem_carve_out(struct efi_mem_list *map, /** * efi_add_memory_map_pg() - add pages to the memory map * - * @start: start address, must be a multiple of EFI_PAGE_SIZE - * @pages: number of pages to add - * @memory_type: type of memory added - * @overlap_only_ram: region may only overlap RAM - * Return: status code + * @start: start address, must be a multiple of + * EFI_PAGE_SIZE + * @pages: number of pages to add + * @memory_type: type of memory added + * @overlap_conventional: region may only overlap free(conventional) + * memory + * Return: status code */ efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, - int memory_type, - bool overlap_only_ram) + int memory_type, + bool overlap_conventional) { struct efi_mem_list *lmem; struct efi_mem_list *newlist; @@ -275,7 +279,8 @@ efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, struct efi_event *evt; EFI_PRINT("%s: 0x%llx 0x%llx %d %s\n", __func__, - start, pages, memory_type, overlap_only_ram ? "yes" : "no"); + start, pages, memory_type, overlap_conventional ? + "yes" : "no"); if (memory_type >= EFI_MAX_MEMORY_TYPE) return EFI_INVALID_PARAMETER; @@ -312,7 +317,7 @@ efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, s64 r; r = efi_mem_carve_out(lmem, &newlist->desc, - overlap_only_ram); + overlap_conventional); switch (r) { case EFI_CARVE_OUT_OF_RESOURCES: free(newlist); @@ -348,7 +353,7 @@ efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, } } while (carve_again); - if (overlap_only_ram && (carved_pages != pages)) { + if (overlap_conventional && (carved_pages != pages)) { /* * The payload wanted to have RAM overlaps, but we overlapped * with an unallocated region. Error out.