From patchwork Tue Oct 15 15:37:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835445 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp300441wrs; Tue, 15 Oct 2024 08:37:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX77ffJYww/QMppSVcndLe3oAN26pLzZTYA5w5p1p5cwmykK4EaHok9yrRI0zTAJ/wRBnLGdw==@linaro.org X-Google-Smtp-Source: AGHT+IFbFYzbDvDUIPbstsVPm+rP1sY8xdGCohzMaJybcPKd7lSU/gUOY4NOs6V7ZzpNnjj8/R9t X-Received: by 2002:a05:6602:641d:b0:834:f34d:859 with SMTP id ca18e2360f4ac-8379231994dmr1521279539f.3.1729006672965; Tue, 15 Oct 2024 08:37:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729006672; cv=none; d=google.com; s=arc-20240605; b=PUSDZzOQ6kLXgUO63uYn+MtcTfjtFw0TTwu5A5bFqemIJUS7h8DAJFMzCvFmUWgKh3 L2wk/BVQUWc+QnNP68dBBMxtoh55Qjh8eaxMs/iiK1wviWJ3Sf1CRcSLsfMFZXJtDmp9 xmZLLTPpMpmrIWTt6W/rzhE+TwP5fTZjSxw8d8EgrJLmYiX9aor8ts047+3SefQGDkT5 kcD29G3IUCMV58YMB6adI0S6a0mbQSSCiwO3fBTYCGdGeB5IfnCPl+n4JeYo8WTzAi9B J8cMkP0rZfAzLIvvTjYLoHz/W3/9bQ6mxFJ0tWQWwvYuMecIcQtf78vOmKNDhIR3Zuis 3kww== 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=Aug9tyaRK1tIMnJ4e2B908eK4nIlhaZXLCdtZsSa3ZU=; fh=MYvlzMqd61VHJORtkCu1tTA+qP9jRMJFkVEqSzDEdy8=; b=DQSAYXV1csI6R3UlR8/a2n+mruTzLJ+4VGvWY77aM428AJRZspF4u1s64/ZFLIFVYk aNsC2MGglTg79PVS27IxQY8zVIduTrF+BfaDnsHuUnbllXrQKD4HimS06QzovOMbHXXB wQDE/BwqK5Yaik+4tqKkRTUPzMvDAyJMVkhMX7YAG0EWenEorOw4aS4WmEGRwLCNNYFY X+DUMTc5Q9b3mfbjt9hDa1JI9nUA0cMI+LGR5LXr/D61cBMBN8ARJVUsAjc2hBW4mIZz TpCArFBvz/Vzb86PlskMuqSOu6BmyOjcuXTZoKw1IOORrQSf41zQmEF+5fAZToviikjc GrXg==; 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-83a8b20fcccsi72680239f.23.2024.10.15.08.37.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:37:52 -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 047F188753; Tue, 15 Oct 2024 17:37:45 +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 887558899C; Tue, 15 Oct 2024 17:37:44 +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_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_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 505B688730 for ; Tue, 15 Oct 2024 17:37:42 +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 63B5E1063; Tue, 15 Oct 2024 08:38:11 -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 E3A6F3F528; Tue, 15 Oct 2024 08:37:38 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Mark Kettenis , Sughosh Ganu Subject: [PATCH v4 01/15] lmb: add versions of the lmb API with flags Date: Tue, 15 Oct 2024 21:07:03 +0530 Message-Id: <20241015153717.401371-2-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015153717.401371-1-sughosh.ganu@linaro.org> References: <20241015153717.401371-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 V3: 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 aee2f9fcdaa..0e8426f4379 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 380d92a6718..a38537af9c3 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 Tue Oct 15 15:37:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835446 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp300551wrs; Tue, 15 Oct 2024 08:38:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX2ooNdkiD5WnGceMwHklmm9lcg0x9Wnbi4gk3CUUdNYyPBdAYQf/nkpBFQKeKG8uzMpZJ/Pw==@linaro.org X-Google-Smtp-Source: AGHT+IEV7FugqNfFxj8aup1U1wxAlY+yL42ym7Kw4UE9tPtggoUWLWaQGDAXa85v7G1VLEMDxe1a X-Received: by 2002:a05:6e02:17cd:b0:3a0:915d:a4a7 with SMTP id e9e14a558f8ab-3a3bcd962d8mr105374525ab.2.1729006683085; Tue, 15 Oct 2024 08:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729006683; cv=none; d=google.com; s=arc-20240605; b=df+V5qLp8D/I0rU8Xxt3XVKVSaMpbgYldyk5SvlN1mlumnP+vbzZvNAn2fYxcwqDo5 dbG/KCeZTZipYjdcVC0Wq2KpY1QRdmDLPtZ8V5m1jNKtaKdl8LF+XPDMigJv3phN3W9O bOEtEHbaCNasq1n5hRRW3QhRGvznFQhs818oUHq8Ksl8jRoTWHFC2ZrkLM6pWOk+oHaS 6lN6aKgelvl7xjNp5W7ptWn5DCBJYrhNONhjD+UNRmNsclX1TvcnH9s69rItz8OcFL1H eQfkZr3zLC2DzvI67coE5nyZF7JZvYSg0/CLAp5+6s8AVkr+bEGN2o2WqqRxKm2gCCbu j0KQ== 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=9CvQW9Zs/qwbX6AWJzVeVJk/zPhA8KEg+6kyl+v6fpg=; fh=MYvlzMqd61VHJORtkCu1tTA+qP9jRMJFkVEqSzDEdy8=; b=L9ayG/937YbKeADOjdAG/wfahEtt++CQJApd/6yTSmFgSDwoiyx0BpUK1GhisSqS+X AxRlpP4ySt8ZDXHWKiYyZTd7MGhiZmUx32Prrl8m0LA8Ljjf6fD/DUFr2OfiWpK6IuVf PckpVtwAldqvK8K8dKi50oto13oC3QeKWEQjPYUAiUuro/gU+5yT8HePxrCmb2tsbXxe tDCdgXrNqxNlYkBVCeScaCe5A+KZnoicnWN3nGjiPr8kasF0LpeyFLSfD8uNyZPLq9YX 5E+8R32k7B62TiQkJuALNYJEqp1cy8D7zfG0w1oh+1cwfxgd4SzHmNQud/o0o/qBENPa 2Yfw==; 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-3a3d71e2a0bsi7383905ab.188.2024.10.15.08.38.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:38:03 -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 7382988A47; Tue, 15 Oct 2024 17:37:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id AB3A388730; Tue, 15 Oct 2024 17:37: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_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_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 B7063889B3 for ; Tue, 15 Oct 2024 17:37: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 C474C1477; Tue, 15 Oct 2024 08:38: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 50E6E3F528; Tue, 15 Oct 2024 08:37:42 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Mark Kettenis , Sughosh Ganu Subject: [PATCH v4 02/15] lmb: add a flag to allow suppressing memory map change notification Date: Tue, 15 Oct 2024 21:07:04 +0530 Message-Id: <20241015153717.401371-3-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015153717.401371-1-sughosh.ganu@linaro.org> References: <20241015153717.401371-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. While here, also add a description of the memory attributes that the flags signify. Signed-off-by: Sughosh Ganu --- Changes since V3: * Add comments for the LMB_NOOVERWRITE and LMB_NONOTIFY flags include/lmb.h | 3 +++ lib/lmb.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/lmb.h b/include/lmb.h index 0e8426f4379..ec477c1f51d 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -18,11 +18,14 @@ * enum lmb_flags - definition of memory region attributes * @LMB_NONE: no special request * @LMB_NOMAP: don't add to mmu configuration + * @LMB_NOOVERWRITE: the memory region cannot be overwritten/re-reserved + * @LMB_NONOTIFY: do not notify other modules of changes to this memory region */ 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 a38537af9c3..e1e616679f0 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 Tue Oct 15 15:37:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835447 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp300622wrs; Tue, 15 Oct 2024 08:38:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXKoTcWqhOT1WEyzwclP0NWg3lLtqkWUgBZdcfzMFBTNmcaTN5T1+tmZ3eXdagF6RBSqHVvQA==@linaro.org X-Google-Smtp-Source: AGHT+IGkqz5yhpSQ/JhCOClkySyChydfxf2ixDasb3EOuDr/BSsZ0ZoVfcHJBDNhbf7zrwlP24bU X-Received: by 2002:a05:6e02:1d0c:b0:3a1:a26e:81a with SMTP id e9e14a558f8ab-3a3dc4a7b7fmr8370585ab.7.1729006692896; Tue, 15 Oct 2024 08:38:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729006692; cv=none; d=google.com; s=arc-20240605; b=PjlknAOjOpXxoEAP6xQ2Ko+8MSBLfL63ZI6F3FnZhQ8m51cvDE1rlXO6gjoO7f1F7x kh+QaRPxa/1aMLsxkz9z4TGN15/AktFC0JDMDPCaXUcCS4+KoMHDkMOjYRge9kwkhOoD cHrgVyUB9VUkStvgtZcBhiFYwVTsaNdtqH9lPjW1VIEy/12D6FHoKs5v0k3TqfcYVf8S QRpaOmkjbeb0UF0+FEPl4PVE2isaO2mwI9M5PvvwCMrktQVj/Zqnvw8D5/zDjAigHU7t 3k4AMyobnL01PWZuSkIBD02UzXLlHT6RjxKm+N7Sh1ywwO4upPDxChJYSlF+RQzSmMi4 ZWXQ== 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=/jPINX3FfJ6MU2DPrJW/EKNGj1YmWvrijZLhn6HC8F8=; fh=MYvlzMqd61VHJORtkCu1tTA+qP9jRMJFkVEqSzDEdy8=; b=BM3MRN8q7aEgUO1V1iV2M19fNkTHs5cBSZNefQoRPe3aTfrVI2uyQnRKaOezZoNXWq f4Rn3lZv4jl7viY4SjyetHtjBWadXQFTUBExdQXR+l68fGpfdTCPyi9dc2Qk0cpXKvyO OG8A7uAVdf/65fLGqLxe/Obp++y+zrl06tDc2j6i09Dtj65tRb7h8QKk6uxcr+de2NuU y98LL3DuDIxqYbEJg3A1OlM2ZDoqPmSPOg+kPqq91dGMjh+9yNtEKcS4hMS6rQshkA0c ZzB9hLiHgfRjC/aAtRPuwC3tiu3FFGDs6N/pm/k979Ur2aMpEaoiL8Yu6Ki/3+9oVDdh Jnqw==; 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-3a3d70feebasi7188645ab.23.2024.10.15.08.38.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:38:12 -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 0429C889B3; Tue, 15 Oct 2024 17:37:53 +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 8E65D889C3; Tue, 15 Oct 2024 17:37:52 +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_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_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 2580988A24 for ; Tue, 15 Oct 2024 17:37:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 311F9153B; Tue, 15 Oct 2024 08:38:18 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B26C43F528; Tue, 15 Oct 2024 08:37:45 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Mark Kettenis , Sughosh Ganu Subject: [PATCH v4 03/15] lmb: add and reserve memory above ram_top Date: Tue, 15 Oct 2024 21:07:05 +0530 Message-Id: <20241015153717.401371-4-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015153717.401371-1-sughosh.ganu@linaro.org> References: <20241015153717.401371-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 U-Boot does not use memory above ram_top. However, this memory does need to get registered as part of the memory map, so that subsystems like EFI pass it on to the operating system as part of the EFI memory map. Add memory above ram_top and reserve it with the LMB_NOOVERWRITE flag so that it does not get allocated or re-used. Signed-off-by: Sughosh Ganu Suggested-by: Mark Kettenis --- Changes since V3: New patch lib/lmb.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index e1e616679f0..0504a7b3407 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -281,7 +281,6 @@ void lmb_add_memory(void) { int i; phys_size_t size; - phys_addr_t rgn_top; u64 ram_top = gd->ram_top; struct bd_info *bd = gd->bd; @@ -292,16 +291,16 @@ void lmb_add_memory(void) for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { size = bd->bi_dram[i].size; if (size) { - if (bd->bi_dram[i].start > ram_top) - continue; - - rgn_top = bd->bi_dram[i].start + - bd->bi_dram[i].size; - - if (rgn_top > ram_top) - size -= rgn_top - ram_top; - lmb_add(bd->bi_dram[i].start, size); + + /* + * Reserve memory above ram_top as + * no-overwrite so that it cannot be + * allocated + */ + if (bd->bi_dram[i].start >= ram_top) + lmb_reserve_flags(bd->bi_dram[i].start, size, + LMB_NOOVERWRITE); } } } From patchwork Tue Oct 15 15:37:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835448 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp300739wrs; Tue, 15 Oct 2024 08:38:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUqOxKtxcWuMTN3k0twfZlF/kYnf9sPk/GVOMqsoBlFmuHIUai+/YGBrIOEjC9ryp5y49fUPQ==@linaro.org X-Google-Smtp-Source: AGHT+IHQNNlzt21a+jbdkekIX0kBaFIhWaZWuhrykySo2gGqgCj9e40YGPdNaU6H99DEoFhZ+G3j X-Received: by 2002:a05:6602:1503:b0:82b:40f:63c6 with SMTP id ca18e2360f4ac-83a64d161a3mr1383763939f.4.1729006706045; Tue, 15 Oct 2024 08:38:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729006706; cv=none; d=google.com; s=arc-20240605; b=dqXyD8MhOS0wyVjKNoIfCp4Fao0uGA5F58OpSEOETvFs5O2A5PKevBEHGyzmRiU4kq s1EFBj29qrGLLnHIV6OWP39UwzC+chL21knf3SJtD8eXcqyZl4VOBZ4gacn7Sw+reo9A 4ajguVWrXM5ELSbKr6B6vQtfLd49iQeHsazKX1uZiWmo6k05Onc7U6znWA8DS+fopoKp ypxs+I9bIbwYFpZx4nqs43hQzgsz7U3MI3WGF0Dtv7UdMm3nBMQbj7TG+MjkGN7zE/Ri uEQcZJWIvuALrWu8+hknSoHCVO20jlnQ0GPzPFYpguFPEMGKd5A1wPJZYjuy31GhoQwE Vj0w== 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=goID1hZMSZ8JD2hR1OH7HV85tGM3pRyAuvh7kf4XOUA=; fh=MYvlzMqd61VHJORtkCu1tTA+qP9jRMJFkVEqSzDEdy8=; b=YaQBH3mqK6pzJaLIl/2NlYYgR6LgCnAkklzavU45YtFtdPzsyEU6EYyQFZq0HHWnHn 9ZqQQOnpwnwfvZ23UOh6Ra201UZ9fBG8DPX4B+NWj6v5h4Dr92358ZE7dmSW7r8DGEUd v/1QqBJjo5qp6rT7YeeGTp59irhdjEJzA2gLRQTHAlmqAq1cOh6+hT/joLb+1Tj9nV+S Nf6oC6MNR9sMs5BShQIfeAIFbAU572gDNEcz0DuvrFFsuHqn798z1g+pqBqur5ipWTCB X+FbsIhywdXzTWQI/RO6ThSDeKR+/f1hToXmfcWc/euo0VdPey6XwoHKsh9vkgwxjh9u u23Q==; 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-83a8b2109ddsi72825439f.28.2024.10.15.08.38.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:38:26 -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 5BE9488A43; Tue, 15 Oct 2024 17:37:56 +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 B5B4E88A43; Tue, 15 Oct 2024 17:37:54 +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_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_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 8135088730 for ; Tue, 15 Oct 2024 17:37:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9695F1691; Tue, 15 Oct 2024 08:38:21 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1F6D83F528; Tue, 15 Oct 2024 08:37: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 , Mark Kettenis , Sughosh Ganu Subject: [PATCH v4 04/15] efi: memory: use the lmb API's for allocating and freeing memory Date: Tue, 15 Oct 2024 21:07:06 +0530 Message-Id: <20241015153717.401371-5-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015153717.401371-1-sughosh.ganu@linaro.org> References: <20241015153717.401371-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 V3: None 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 6f6fa8d629d..69b2c9360d8 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 c6f1dd09456..aa1da21f9f9 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 Tue Oct 15 15:37:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 835449 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp300798wrs; Tue, 15 Oct 2024 08:38:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXhH2UtGy9ZA6GTJxSBjeiBa3Mle2FsxtseHgstZiIfRS192s6VA9ZjOgS9fWxaYiAOPLFx4A==@linaro.org X-Google-Smtp-Source: AGHT+IFfLutHedq+iBSqdSmP1NwtYzI2MX2zJJoaf/kIHniZC6mkCUx4Qpz0jnC99LlKhQqyJL74 X-Received: by 2002:a92:c265:0:b0:3a3:76c3:fcb0 with SMTP id e9e14a558f8ab-3a3bce16c4fmr78847625ab.26.1729006712749; Tue, 15 Oct 2024 08:38:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729006712; cv=none; d=google.com; s=arc-20240605; b=gs/zdivs3VO75qQHwNlFft+jJ+kD11pTsdZwpqr2My0ThySos2M4Z2EHQ8s7R3SBW4 /ri2u5EKwXJGUET70cF1k4kcuMbrJzMoSUQNyt7PuLPiJv6R5qx9n7GCNePmpkesgDFV TLELxuv4967TXjbyl/edDytBM3AN1EKgPfN9VwIwzoJzfgwGrN0GEPL0EXjZ/yiUD7WV H4ReuBG7kmCg/FY7cFKdWVyLOsUuyh9G0r8KgpqEysun9Hy5dqITCq9YkTaD7ASDcie/ 2Advetff6y9/lFG87hf6irE3CSDm0aCVI8P3dAlOP7TEo8dkimC40j8dbuaiPpFDZPAk klnQ== 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=oRFr0q1SQJ0Pu1tg7pzuLzaAl8M4vyc2t4H5nWQwQZo=; fh=MYvlzMqd61VHJORtkCu1tTA+qP9jRMJFkVEqSzDEdy8=; b=iwXjlZ+YgwriOMWy7fX25mg+HijnN3x78xx6Og36PmzMf3O/StvQrP14bzUrz+TycQ hvKPBRM3ktRTYzwjx3cF8Y7mHaSW8NELb6DHcg2KR74ubsc8Jab6Vzl1gRbHKj4tmPIE 8FgzNAo6VP843VjSonAz3HKJdkCODFzK3V9NC5iCsF/BkK6LOM4QgnIqPJC+nPwAgleL cze3VbT727hqUNaaiUHgGy1eaU+/n8h3Ay9Dqi5h/8UvUr52OCMfa/lX4nB17iCioo+J lr2YXhGmqTY5MvRlfXhk9iyb4nJAPiMCQoYtXQya4nQBSjICRssx+4HmVM+44mZK4/BR CPtg==; 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-3a3d71e28a0si7060725ab.190.2024.10.15.08.38.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:38:32 -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 B730888C6D; Tue, 15 Oct 2024 17:37:59 +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 4519888C3D; Tue, 15 Oct 2024 17:37:58 +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_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_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 DE3AD88730 for ; Tue, 15 Oct 2024 17:37:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 005D6169C; Tue, 15 Oct 2024 08:38:25 -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 810D43F528; Tue, 15 Oct 2024 08:37:52 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Mark Kettenis , Sughosh Ganu Subject: [PATCH v4 05/15] lmb: notify of any changes to the LMB memory map Date: Tue, 15 Oct 2024 21:07:07 +0530 Message-Id: <20241015153717.401371-6-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015153717.401371-1-sughosh.ganu@linaro.org> References: <20241015153717.401371-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 V3: * Drop use of is_addr_in_ram() function * Drop use of CONFIG_MEM_MAP_UPDATE_NOTIFY symbol to check if the notification needs to be sent. * s/lmb_notify/lmb_should_notify * Put a check for EFI_LOADER in the lmb_should_notify() function include/efi_loader.h | 14 +++++ include/lmb.h | 2 + lib/efi_loader/efi_memory.c | 2 +- lib/lmb.c | 104 +++++++++++++++++++++++++++++++----- 4 files changed, 109 insertions(+), 13 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 511281e150e..ac203957181 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 ec477c1f51d..837002121d9 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -46,10 +46,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/efi_memory.c b/lib/efi_loader/efi_memory.c index aa1da21f9f9..41501e9d41b 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 0504a7b3407..e7167f858f0 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -22,11 +23,52 @@ 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; +static bool lmb_should_notify(enum lmb_flags flags) +{ + return !lmb.test && !(flags & LMB_NONOTIFY) && + CONFIG_IS_ENABLED(EFI_LOADER); +} + +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 (op != MAP_OP_RESERVE && op != MAP_OP_FREE && op != MAP_OP_ADD) { + log_err("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) { u64 bitpos; @@ -473,9 +515,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 (lmb_should_notify(LMB_NONE)) + return lmb_map_update_notify(base, size, MAP_OP_ADD); + + return 0; } static long __lmb_free(phys_addr_t base, phys_size_t size) @@ -529,11 +579,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 @@ -545,16 +590,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 (lmb_should_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 (lmb_should_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) @@ -586,6 +653,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; @@ -616,6 +685,15 @@ 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 (lmb_should_notify(flags)) { + op = MAP_OP_RESERVE; + ret = lmb_map_update_notify(base, size, + op); + if (ret) + return ret; + } + return base; } @@ -785,7 +863,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; @@ -803,6 +881,8 @@ static int lmb_setup(void) return -ENOMEM; } + lmb.test = test; + return 0; } @@ -822,7 +902,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; @@ -850,7 +930,7 @@ int lmb_push(struct lmb *store) int ret; *store = lmb; - ret = lmb_setup(); + ret = lmb_setup(true); if (ret) return ret; From patchwork Tue Oct 15 15:37: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: 835450 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp300874wrs; Tue, 15 Oct 2024 08:38:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUbBH9ZGgOuO1OrmL7wOb3YyYalzRq7aqeY+UGVMhBlrDro1I5RSkFYHjxiL916GqHGKMY1tQ==@linaro.org X-Google-Smtp-Source: AGHT+IGKCOzkuvsie7Q2ElhAsXkEGXmNJOlSoyM4iP+ONDG1P1bZEUZJER38QqzOqrpcg2XetDIc X-Received: by 2002:a05:6e02:13a8:b0:3a3:ab8f:a280 with SMTP id e9e14a558f8ab-3a3b5f784aemr150678475ab.1.1729006721888; Tue, 15 Oct 2024 08:38:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729006721; cv=none; d=google.com; s=arc-20240605; b=k9ETau1KGN9HnefrE4MLfOfzUKJzgSfaMXQ1J6tmbCb9tKfc2qBaQGI6M4Gsw3GoI4 Uvx+4E8jeCQnyF1J8jJODSRE4KLU2jRk2t/Vok7WEtodWUtS1P2g/QCBDTnyl+Z6eIoe ZzbiOUvAjZ3H9ovx/1fF86DDa136pF/BRsGongb9CNPaTUOe8uU18HMIEAz1KIsqbZTA 42yrZtGmPza4HkvzFFyd33A6ljPrT58ZRAsstfTbXyJH+BiAaso5GnttMrTi+lQRU9Sl FguJ9XDtKKsirQnm/kpoelifSPza/wjZ/vJJ4960IxPXF8ELPBehoCWerbZTAeIF+VRt yJ3w== 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=25DWLhJvjU7OudoBFUXhMMylWqhqfeRZ7LxflYfhYxA=; fh=MYvlzMqd61VHJORtkCu1tTA+qP9jRMJFkVEqSzDEdy8=; b=LzCawequgdx6rEc2wGY7nyTd+z/iIKQrMEblM9siIsXVeMyyITEaoksQlBlVkKE/+/ vEQioUK8bEz9kEb1Dkj8+h2KSGKGEwYSohPnpw2JPPwgYoZPKr+oj4DMacTil5zuuulz Xa479uJ0UgvSo+ds2dE38QAZnnjK1DcnUW2A+F6PYhY/Cg4cN7IHrrFqNchU+QcepAmV ObP7Sarkt4QYYP1o7mYhiTAfFkJZlLp1TfWVQUjc969T3qJRS1HQKR8zBLkiLWkkSEhn Flq0u4FlaGc6nHwpRyWLcl4026IdPQWzcGEgCoYHkhUpMAkAFmRKdQDKmPyKwSfnB6/v D5+w==; 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-3a3d70feb3csi7961595ab.34.2024.10.15.08.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:38:41 -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 1C47F88969; Tue, 15 Oct 2024 17:38:02 +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 72A6788730; Tue, 15 Oct 2024 17:38:01 +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_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_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 73CE2889C3 for ; Tue, 15 Oct 2024 17:37:59 +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 7C80D1692; Tue, 15 Oct 2024 08:38:28 -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 E25F73F528; Tue, 15 Oct 2024 08:37:55 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Mark Kettenis , Sughosh Ganu Subject: [PATCH v4 06/15] efi_memory: do not add U-Boot memory to the memory map Date: Tue, 15 Oct 2024 21:07:08 +0530 Message-Id: <20241015153717.401371-7-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015153717.401371-1-sughosh.ganu@linaro.org> References: <20241015153717.401371-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 V3: None 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 41501e9d41b..16e64987af7 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 Tue Oct 15 15:37: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: 835451 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp300962wrs; Tue, 15 Oct 2024 08:38:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXpShAAZfcEwXINzOidCBe2ZeieCqPVxVhCH1mq6VS5t0+RcOH95DdYzHBoW2ZIs3McubyiLg==@linaro.org X-Google-Smtp-Source: AGHT+IF8RxCnepoPoJpDUQkOOPk15xXo9H8hWRFL3TozDDkQnCDpCI1tJLrSmwQwXlfJXkfKFdca X-Received: by 2002:a05:6602:6d18:b0:835:42ce:933d with SMTP id ca18e2360f4ac-83a943d8943mr130024939f.1.1729006731702; Tue, 15 Oct 2024 08:38:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729006731; cv=none; d=google.com; s=arc-20240605; b=dBQFLMHsuG3WyF4tapk272eg1Gn4NhRQUPN1EfHNr1L77t0Up+NU3s6boRW7wJdde/ 9VokoZg9nlHEnXOZTaLSzfuIDaxRbX3kDCU9atmZ0IvqXhxCgZJdU+IwMQ9ADmvzQ9EK c+FuxdlI2352Isfpm8iMU7XEUEJsJzxh+dkhPvJQm5Cyuzzl93IOD6rYzBAJMerYLHDV QPAFrX/qMlSU5LprLSp2Lffssx5BWomXA/gxYv3nC/Fh82a7jEc60J0gPauAitt3w7or wHMtFFW9SRrFPAScrnO0Ag5JkgoCVMvKo9t2qE3myrZM6qvXs0JoV73F51Qz3wCQ6OH1 sNBw== 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=wgwlq+fU6DX1HsNbXjT6xBjmNB8tmStaTGTznCIcAG4=; fh=MYvlzMqd61VHJORtkCu1tTA+qP9jRMJFkVEqSzDEdy8=; b=FwN7w2JLqPV5kiokH5p/qaOZQPaFMlKJ0m+huaYy8Y9cUuFNehTlQ+bnbBxmru7G42 hXQC4T7SHeFNgj6g0yESm0nNCi98ZSn5fNsZJQO0K9yDeBz9SDdEyaeidVd1KO87pRE5 Xxd+qcFq9bzS/4Oy6T2jP3GOza2damCgNiIGdKdJgTne2BuPIkuTCbndAJb76f+0cDYo pghPMPljsLCMK1NaLFPmvWowtWURBup/2NHfDcA8f9t4Jd8ofTZg6W+T/nsWM7nFvWU4 b59d4Z7V7QP6TD6LGHrq6Hj4WBI8cx/4y+7k9EIUBfcb2P1Yj5ITG83Ug69z0A+GytaJ MCeA==; 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-4dbeccdf984si710828173.137.2024.10.15.08.38.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:38:51 -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 702CA88BB2; Tue, 15 Oct 2024 17:38:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 6144E88730; Tue, 15 Oct 2024 17:38: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_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_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 AB9D888BB2 for ; Tue, 15 Oct 2024 17:38:02 +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 C2D75169E; Tue, 15 Oct 2024 08:38:31 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4FCE43F528; Tue, 15 Oct 2024 08:37:59 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Mark Kettenis , Sughosh Ganu Subject: [PATCH v4 07/15] ti: k3: remove efi_add_known_memory() function definition Date: Tue, 15 Oct 2024 21:07:09 +0530 Message-Id: <20241015153717.401371-8-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015153717.401371-1-sughosh.ganu@linaro.org> References: <20241015153717.401371-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 V3: 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 df48ec8d479..f2086cbdf51 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 Tue Oct 15 15:37: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: 835452 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp301043wrs; Tue, 15 Oct 2024 08:39:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUwqIa4DL8y3GVd6bntucQkKPHKsfEFR8biij4fCG4+ztKPQs+BPELoNfM1Mid3o1Au+QXZ8A==@linaro.org X-Google-Smtp-Source: AGHT+IFrK1mvd9TvsELJFp0EXjQg+c3dkWoTfmvNoT5L4o8dD4AvOmwSBUdRlIA2vK8hBDo1kAid X-Received: by 2002:a05:6602:3f92:b0:82a:48c5:4d04 with SMTP id ca18e2360f4ac-83a64ce007amr872252339f.6.1729006741348; Tue, 15 Oct 2024 08:39:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729006741; cv=none; d=google.com; s=arc-20240605; b=J5M9teecGfvWpzA2YRmDZRCWKCG9p97zC76pH1ieL56t655UfZ87i6tiU4M67P7UJc r5d46UOZdkbfYcTry6VL/8SaC3SfL+YxZW2s7e4NWRmj6JZ0sR2lp5ga3TVDCrbhrx6K Hac/zMpeW410pL9IuwulYXMo+wDmknPuE1l2HcVE+OxLoXNY3F551g/9uWOof1y5tjL7 CYrwaHmVhoDXljRYu1y7HefObaC75z6Bhq3Pap3DcsVCPUNnEs0UUtCSiOvcbDVWzFM4 UIzCEDPFqADMwXL2kZHF8FjAZ3ivOgVIxx9071ONj18529s5VRYg0tKypdDC6ttpDPDO 64HA== 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=+yzPo8v/FaKUfNPHDH5/Bt7Ora2U6XDAytQ5zk11+FM=; fh=MYvlzMqd61VHJORtkCu1tTA+qP9jRMJFkVEqSzDEdy8=; b=RWDLrG0+7P29krBRXSwQApBKGR+5vCzB8nDkLPSoDT/Lmezm/HgZlQWPcLGJ28aYe3 gHUncS4SVwX2z86mvrVmNO7iHnLeefkAQOPgubOuUYgw9947whGtWB8p1MudqsaZulj+ b4TxqLKBpV5YvGT5xubjgQwv81VITvSdjJqGW2ANqfBYMnIakfl/2Gica45XCvYFHJaA DBEwcrUKuan/aPc6aFmwvb+DRapk/VrC4vD6Ate26g8UNXeqPHjAFEgz5hh5vI5TebsT MISvA3DpKlPgiZPxK/ZClX01MfA7GZJaftH/YOBPeHgHc9Vl8PyJia3a8FiBpuD0rvQJ rY9g==; 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-4dbecc66274si727945173.82.2024.10.15.08.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:39:01 -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 C41E588D14; Tue, 15 Oct 2024 17:38: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 1F18388BD2; Tue, 15 Oct 2024 17:38: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_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_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 1BEC488730 for ; Tue, 15 Oct 2024 17:38: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 309B516A3; Tue, 15 Oct 2024 08:38: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 B138F3F528; Tue, 15 Oct 2024 08:38:02 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Mark Kettenis , Sughosh Ganu Subject: [PATCH v4 08/15] stm32mp: remove efi_add_known_memory() function definition Date: Tue, 15 Oct 2024 21:07:10 +0530 Message-Id: <20241015153717.401371-9-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015153717.401371-1-sughosh.ganu@linaro.org> References: <20241015153717.401371-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 V3: 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 198785353f1..3698fc49bf1 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 Tue Oct 15 15:37: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: 835453 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp301142wrs; Tue, 15 Oct 2024 08:39:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWqKDDh2nAyY7T0uUyXTtavuoU8KUqxQ+g4CLZ6owmtmqIjRT/45p3MeDr8YNeHNmIBYbFv+A==@linaro.org X-Google-Smtp-Source: AGHT+IERqwPYhnyqCFU7lyv2HFU/qQ2j2vi9rhepHUPyFewi+UV9zbS4LtmJYHwmE6QztnMu0pHL X-Received: by 2002:a05:6602:611b:b0:82d:8a8:b9e with SMTP id ca18e2360f4ac-83a943dd5d1mr102933039f.3.1729006752450; Tue, 15 Oct 2024 08:39:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729006752; cv=none; d=google.com; s=arc-20240605; b=Ap96+P04BmY4U+prhAGr2o+hAj/CImDpL9eTaEuGB6HPDp1nCwvZK7mvWrneXm7SN5 jdsRE7adyQ69udauh+5IC1rlGnDfcvRGPhoyzIfxxK2cmqlV/d0AxeZSxKrHIYeUfYQV h6NHnvEV7yBTGJJv9TWQh3MRmRg7AjWOnUBkBaswimumOUYAIg3unO/agstkXGKGNmaj oXgy/NW4kNaz5V9phKJwO/H2dX1T0XlNvbysy5E7fzkMMK5PK1wiDyEbjZJu2PT+3XaP qVzVH7giTC/7c4Lxr9C4EZRNrJE1QlJEryd4i6JM1m1irQ1FFqlUw3rVyt2ezRMY/7Hu UmjA== 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=LfHOnBQBxGtz4ia58tXU60Mu5uSeXvEI/MXY7I2z37Y=; fh=MYvlzMqd61VHJORtkCu1tTA+qP9jRMJFkVEqSzDEdy8=; b=RQJpE/4JGnDweZKqF4DW4wW3LhKuU92F3fU/2JWZ+r01x1/eMohU36pTVGlTUAbToZ UeqF0FP04IGJuuXsQEJSZK5rC5h8FRYj+GvUYMXvfU2DZCm9lE1oPOAKhzeO0SNpEySG ruHA62qUxospFvpFD537b/RKClHPFAAUoSURHKyVtd37Zivas4rHS3n4xcPl/KaJRp/0 R21teZa7E6mquCdh0Nr44zIiY0WqPNAbxeE3kQdmXXKQIRGKejerf4HQt1nQIj5HULYm r10ZvG1M41u4EFnCUSp5Mc1oLNWR3zjDetornS1JFNHphOgFQ05ZIPK3k6lPKqf1w4oB RwKw==; 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-4dbecb38253si733359173.27.2024.10.15.08.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:39:12 -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 2294A88BD2; Tue, 15 Oct 2024 17:38:13 +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 9F07788B99; Tue, 15 Oct 2024 17:38:12 +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_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_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 84A8088CC9 for ; Tue, 15 Oct 2024 17:38:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 92AB016F2; Tue, 15 Oct 2024 08:38:38 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1E8DA3F528; Tue, 15 Oct 2024 08:38:05 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Mark Kettenis , Sughosh Ganu Subject: [PATCH v4 09/15] lmb: allow for boards to specify memory map Date: Tue, 15 Oct 2024 21:07:11 +0530 Message-Id: <20241015153717.401371-10-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015153717.401371-1-sughosh.ganu@linaro.org> References: <20241015153717.401371-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 V3: 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 837002121d9..e46abf400c6 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -168,6 +168,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 67a60160dac..3d2011ad4b7 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1119,6 +1119,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 e7167f858f0..ae69201d5b7 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -326,6 +326,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 Tue Oct 15 15:37: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: 835454 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp301296wrs; Tue, 15 Oct 2024 08:39:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUdIaWKrS7QECeEDFi9YFUL2sOOPT+nw7Z7csS1lA6kQWYzM9sgvpOuKjo2+vNmWf3OYHAwAQ==@linaro.org X-Google-Smtp-Source: AGHT+IFPbG+1gXPxxRpT+WHEMJH53dvFrytp1TQGtCZj7xur8DpbltF6e2KSWEc0z1PtBGUV+//h X-Received: by 2002:a05:6602:6d18:b0:835:40af:c45b with SMTP id ca18e2360f4ac-83a9447a320mr84957939f.7.1729006770710; Tue, 15 Oct 2024 08:39:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729006770; cv=none; d=google.com; s=arc-20240605; b=NguNY94dcdgEBUEyg1On/bpYHHnHT8Iszf3FZ3EgQhcZGuJAyRiBAiwDOAi4WroRqW NVUuXxV0U0jxP8/JhrsOl1XwNIuZWHMV5m5pPD8Dw34S80CnBzBCrsZcYp+yXdh5e6B6 BTGHRmWDwd/TREQdsrA//fil+ZEo9n1dL3gsL+l4s+IiuBZK6mVbV1U2cUiN5+eIXS+B v19zuOqc47QHnZKwqn37oQhM3Wk6NfaRZpXYC7/jzxPxcdjCpdGiZRDDz1lU465xf4w4 jW0RMDlRYhtJkX1hve9odsjIuxjMY2bvkUWq1Nq0qi/g2fdhrJr37LxOj5s9qRBtgIso G68Q== 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=kGV9/18JqWXdqMGsam1HBh5snqjFghVwn8PLHB5K184=; fh=MYvlzMqd61VHJORtkCu1tTA+qP9jRMJFkVEqSzDEdy8=; b=MPYCaCNEW07JrjaqA/2xkDMZImaYsPnHMnKMWgv74dVCYZLrTFJX0Jc+q7HBUSohLj Wy9g9ZX4zSlac8ikz/Jci3fkFgUiQys7Cn8mOgmTpYL9YIb8t+4wwW22lH9n6W821RAf L7+DVpU/b0fqxUuHd9rXG9YuBYp1Wd8MT0XbsNZQyM45duEJqz9PmXulX4raLfe/BYKR E50S76QXeMmVsXv/T+LPP/q67CurgbfNEPHFJvZ4BfJr1s5dm6u5rxqUgD+lu5bWnzhO TCf5tlhmoyQaLz7/LHihi3XT3GMbvdaXsyUQySUJ68litjQuR4TmRfVt4IkOqLf43x18 g+vg==; 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-4dbecc4a2b2si752917173.78.2024.10.15.08.39.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:39:30 -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 73F1988CC5; Tue, 15 Oct 2024 17:38: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 DBB8688CC5; Tue, 15 Oct 2024 17:38:14 +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_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_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 E5DCE88B99 for ; Tue, 15 Oct 2024 17:38:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F3FFF16F3; Tue, 15 Oct 2024 08:38:41 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8062D3F528; Tue, 15 Oct 2024 08:38: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 , Mark Kettenis , Sughosh Ganu Subject: [PATCH v4 10/15] layerscape: use the lmb API's to add RAM memory Date: Tue, 15 Oct 2024 21:07:12 +0530 Message-Id: <20241015153717.401371-11-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015153717.401371-1-sughosh.ganu@linaro.org> References: <20241015153717.401371-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 V3: 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 f9c2083677a..d2d3e346a36 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 3d2011ad4b7..b6b8b8d9c29 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1122,6 +1122,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 Tue Oct 15 15:37: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: 835455 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp301325wrs; Tue, 15 Oct 2024 08:39:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWaSLC6OCUWThnVLpZ164q+IKF1j70vYRBz7TO11lKTD6ZztF2kAzyUT3oYjfUxHY6cCV7dCQ==@linaro.org X-Google-Smtp-Source: AGHT+IHV/SNCeBDCluTS79hAIg4dO6Zb7cG4aLVJcRDqrVEKO8FLV0/lxNV39lkgGR6Y40slfksP X-Received: by 2002:a05:6602:6014:b0:83a:71c6:26fb with SMTP id ca18e2360f4ac-83a71c629ffmr863835839f.6.1729006774270; Tue, 15 Oct 2024 08:39:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729006774; cv=none; d=google.com; s=arc-20240605; b=RqwFhtsgp5hf07NF/wxNozJ/btI5gUle2aHxZMFGdOQnLg/i0tb6Bo5KdvrTvbGWc4 q2l4D3ifAu5dZ79PdPVL9SMfavp3JD2QN5pOchpBn1gkQRBEuPjOAt1n3ZLWtkoPYhSu diWYLlKN2sjPHPEdqaYDTUySFm1A3Nv7VztrKSyEuN3ALGMPj0E1oygBRbXrbZ3j3XAT 17Cji5YuylyVm0uXQp7yChqDtBpvtjg48NwkwophPQVVUl+P97ID2gXKkfgwE8ctmSnI suCpszKS3IvWs7T8O1BFS3Ez+KB11XQXR5SVF2lTKPaQTyqTh6sD7ZyeerfTCzPxQv1k QnzA== 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=hrUc77vnuSH1koBMfq7RJWL3KE7G67Hd60uOmSDf7NA=; fh=MYvlzMqd61VHJORtkCu1tTA+qP9jRMJFkVEqSzDEdy8=; b=LgEQI1Fk4TCsy3INXiL6Ohqf7cBoIn1GKfVmgGmjhW3xV4lRWdIMzxnvJ0hfNSeBL/ +b0XWpFgkXn2jPevFEAuTBpKEtGFvVOLrA8bqPi0rX/2+DMOviOm/TXb6OCrjNQzGXjv iJ9yhIdxUHA/LMlfh1mdusDnse3OYQTs7dhWELFngvNalwpeTmKfEn9rgfBsvqVc6rcf 3zs3wobxeWpJrlFNW5bG0qowbk/EUY73BIvxA/6lkub8d18k2bDCF/wueEX54XDOM6Ml L5tnKLKg3D69jMHZ6TmNS4BdQnUl0xWG+mtpAqI59wA1H2M5pPME/5D25NoQD2InqIta X1Hg==; 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-83a8b251cdbsi72506139f.75.2024.10.15.08.39.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:39:34 -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 CE29888D72; Tue, 15 Oct 2024 17:38: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 5D07288D54; Tue, 15 Oct 2024 17:38: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_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_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 4B44E88730 for ; Tue, 15 Oct 2024 17:38: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 60DFB1713; Tue, 15 Oct 2024 08:38: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 E1E893F528; Tue, 15 Oct 2024 08:38: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 , Mark Kettenis , Sughosh Ganu Subject: [PATCH v4 11/15] x86: e820: use the lmb API for adding RAM memory Date: Tue, 15 Oct 2024 21:07:13 +0530 Message-Id: <20241015153717.401371-12-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015153717.401371-1-sughosh.ganu@linaro.org> References: <20241015153717.401371-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 V3: 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 122b4f7ca01..d478b7486e3 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 b6b8b8d9c29..fc2db747dcc 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1122,7 +1122,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 Tue Oct 15 15:37: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: 835456 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp301428wrs; Tue, 15 Oct 2024 08:39:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWHNR72LWrEwTZ3l1YoWouTZc5Xau2TwzyI76N4sYnI9cG/Dgur4/Ha5K5BZF2iktXE0PnxJQ==@linaro.org X-Google-Smtp-Source: AGHT+IERFuxciBPaWo8OG2nfR1qKszmdgJnLDlWEGylKq8Gyf8yMR15MrYHt+QSdmJce+Sup9o+J X-Received: by 2002:a05:6e02:3b06:b0:3a3:be8a:8717 with SMTP id e9e14a558f8ab-3a3dc4d5afbmr7964595ab.15.1729006785210; Tue, 15 Oct 2024 08:39:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729006785; cv=none; d=google.com; s=arc-20240605; b=G/mNLETjoxUhy+0o1/rlTMDyxXGt8+cVi0jZcw5ERCZgqiTIQ5mEcpqQmaqMqgJpwJ gYe3VhhGYS80yzgIxHagpy6LYX6b5ftEJnjBZt2CjKOP/lB7BhUekAfUl3C85XNMlFNa iGDT2mBm0z7ZBhpzxw1dbNFmBGNRtQCCOGI3A1/Uf3MQEmPTc6rYyhEV+3IYA7DWDJV8 Xmu22UuHzdGr4umxWBZ0g6EJPSriUppoMoOV1eg+HRcYVZPBs0W1GdUYHqOV+G5Xyj9r 0lqPBY7BcXGHfERY+Ea33zg3Ol/U+EbtyX/07Or5oqT51rz3igEUlLWf4Z1m5r43j5gU u1Cw== 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=w1bvbcnfroRwNkgSmub0l2Jy149enjPK8Iu3LQ66kLM=; fh=MYvlzMqd61VHJORtkCu1tTA+qP9jRMJFkVEqSzDEdy8=; b=NlsGS+wOs0wumB8WJxNzF2QfQdi9YibHlLDloX+kj+mSOyFOe9JUu0lM3kRd3La6gK s7OYS0l3XpA63hCwe+nZzT0l1WT9oMLwb9adl2l41vZgzwXAkfXRAd+3wKj6ifH8sDVz eY9t9mdsIA+rE4Yr7nvWzuGIvTEW+/tEYN/vOZjJttOz33CfknumI7LgWRfwQF95jz1o h/plecG3++5S08qxjnr1vyyWiv662elLxvYCtdz7iMhKS03jmasqtBA7gy5X742QoZ8A Zx7EZ4cAtTs9n/DV89OIvuPOY/YAiCeQZyI50OF5w9bIPI2RRaF/rmrtPT6MXTvXJa70 4R6Q==; 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-3a3d71c00f3si7370785ab.104.2024.10.15.08.39.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:39:45 -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 6607988D3A; Tue, 15 Oct 2024 17:38:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 6F0CD88D56; Tue, 15 Oct 2024 17:38:22 +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_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_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 B3C1188D5C for ; Tue, 15 Oct 2024 17:38: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 C2CC21758; Tue, 15 Oct 2024 08:38: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 4F2A73F528; Tue, 15 Oct 2024 08:38:16 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Mark Kettenis , Sughosh Ganu Subject: [PATCH v4 12/15] efi_memory: do not add RAM memory to the memory map Date: Tue, 15 Oct 2024 21:07:14 +0530 Message-Id: <20241015153717.401371-13-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015153717.401371-1-sughosh.ganu@linaro.org> References: <20241015153717.401371-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 V3: None 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 ac203957181..6b9a66a06c0 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 16e64987af7..f59f7780e92 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 Tue Oct 15 15:37: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: 835457 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp301519wrs; Tue, 15 Oct 2024 08:39:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWhEELjgYg+EmsFqiS5GMOGb4DRccXEveHPIzjpTRMHAfGgyD3vpKz1eORBHhApyNep7oVtoQ==@linaro.org X-Google-Smtp-Source: AGHT+IGT152oseiMWsMZIriaa4CP21HHDtGsPTBIXhHFLfGJ0iaUkapJHXUjg7oqpzfYles8Lt8P X-Received: by 2002:a05:6602:2dc3:b0:82a:34da:72f7 with SMTP id ca18e2360f4ac-83a64db8b35mr770654939f.16.1729006796628; Tue, 15 Oct 2024 08:39:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729006796; cv=none; d=google.com; s=arc-20240605; b=R5lr8g1h/OCWlUrqyf+NwV4BKIXMiFc8EvKX9sIXz7MDNHHwDI0g63qPhilNoyeWqd zUM7zGhgjYaxm03107yFEHeLO03Jm8VOgS4kQzL/lEoDirT3oahK8NXDR1NaS6f75+TV lqNpRaG5/3Knsf0BbqGGB3QkVFbp/680eVGkQJ5UlyeViCKlsU2P31uQjeO1pmWDw34r En98hdQ3ctdIAt0tbdwOGRcY7MRNPfWJ+dKqcTx9VyUWtRezHBozKRUkmrGB9mjnT0/z galUXQpSAUP2bA+DC8PHsDf5affa/HEjIFwH9ww68BS+97zDsofvxPNvmP2cNDoBvoiS MpPQ== 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=lF33IEPx2uzm+dsebykytYuAyxbtTfpjBOcx8C7BM3s=; fh=MYvlzMqd61VHJORtkCu1tTA+qP9jRMJFkVEqSzDEdy8=; b=OsCze1oL3Y/gmRfY+pBJmeo7++kSr0TqPgcOKfGAKUk1e9fd63d8s6mV/GYT+vrSYb vur8FAzvetvNViGgqFu1IhlpJL0VQ6Zgz5d3r78miL6MR/xU7ZdbAakD+r3L2B15kQfN aWxJLF5otM3O693i0lPLMcu9fI57PpMgBHU1HiTrHgVkyNZveJcB8bvBsIwbqM3fgL1h /0o8mmZaWJCA80qDr1wbQy3P7kn0jpVapfsNiexA+9KZIk2hJr0Z2ysPvfxvi+Oa1rMX O7XMMOdVYOOHVCpCV8mShhuRw4RtUTXMZX1/OSuIccziD6L6wGNhSbDHouCPYmxiWkuA OKpg==; 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-83a8b2b7a4bsi70553439f.89.2024.10.15.08.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:39:56 -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 738D788753; Tue, 15 Oct 2024 17:38:25 +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 42F3788730; Tue, 15 Oct 2024 17:38:25 +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_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_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 3B0D388753 for ; Tue, 15 Oct 2024 17:38:23 +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 4A4C7175A; Tue, 15 Oct 2024 08:38:52 -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 B0E3D3F528; Tue, 15 Oct 2024 08:38:19 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Mark Kettenis , Sughosh Ganu Subject: [PATCH v4 13/15] lmb: remove call to efi_lmb_reserve() Date: Tue, 15 Oct 2024 21:07:15 +0530 Message-Id: <20241015153717.401371-14-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015153717.401371-1-sughosh.ganu@linaro.org> References: <20241015153717.401371-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 V3: None lib/lmb.c | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index ae69201d5b7..f3a1d8ca256 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -204,38 +204,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; @@ -282,9 +250,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 Tue Oct 15 15:37: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: 835458 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp301611wrs; Tue, 15 Oct 2024 08:40:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVFnE/CQDftNXD1sbR+aG1MxdcEwCGVj3BxexbEgrHYBwC+tIlGbpa2VDXO/Z3kCSaIzB5YIA==@linaro.org X-Google-Smtp-Source: AGHT+IFueqKMtmDANY8kVNo+xQdCsceTOnn6+214NS28376oUppaTwlVj6KjoPKH7ihiQnjwXM46 X-Received: by 2002:a05:6602:1342:b0:834:f6d2:bfca with SMTP id ca18e2360f4ac-837936cc6bfmr1703302139f.9.1729006808136; Tue, 15 Oct 2024 08:40:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729006808; cv=none; d=google.com; s=arc-20240605; b=jY0U8WygBo3BUno9DS/Tt5PSgJmMoIOcymfkNl9XNUqWrDP0TeGIfnpUXWqfKlBdca JfTk0XEb7oH4eQj7S6kYtnxzRB7VOJm+bU+/4noDC7k3Qtq+JEtAAHpRShFtuk7cwIZ7 vTHfu+LDKbdcKtxWlGpTOCHlFCQk9Ja36w+jp9NpopoXwKGpj3OzKugtxHcX5olTd3pW wgcqMf2OyFtP6In0hys6Ow+j5oYzgY/E22MjQfYS3sFjXHHqHttSzO1LfdcVOCGZN7GS npl5MhoYcJw0OjNF7jFXTwinUBruQbRhE4t2VPxPvgx6CVRHLn523Uk35mA6mE/ZzJA3 SetA== 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=3wm7pKb5h6rLaLfq/oVVqIx3Ex0oAVocBcyOHqVahz4=; fh=MYvlzMqd61VHJORtkCu1tTA+qP9jRMJFkVEqSzDEdy8=; b=BuEF7LRHFj62h/Hi3PYgwMIqVKUYIVrVia2c0mA4Yi96oiZpIQ7DjBC3YnKmrfqQlo ut/dcRSnlWhnxgaEcSsZv906AMFqdoP0I/TZG8SLiJIe+tWoRHpmIpY3emGUT0ftzQsJ FmZ3X+lxDR+JyQA3ukQ9DBhtLkx9hRv0mMLRfra2aCOfwsG7IRVFclYpe0drYjGHywud VJWuM3Al1yNi4iyfnROtV3dJBLHbS8TZUfqJGL3wFWJEF7clr3fq2idOQM9X3Fv0zUb6 PDJNvrfRYGf6Wrg7JUIz4gPW/yx6OAxeCECp+ai0OgO9ptaQNlTtCCAIEOCXETSiIY0f A1oQ==; 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-4dbecb382casi807926173.28.2024.10.15.08.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:40:08 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C6C1488D56; Tue, 15 Oct 2024 17:38:29 +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 3C89588730; Tue, 15 Oct 2024 17:38:29 +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_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_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 BDE9688D39 for ; Tue, 15 Oct 2024 17:38:26 +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 AD2C01756; Tue, 15 Oct 2024 08:38:55 -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 1E8933F7A6; Tue, 15 Oct 2024 08:38: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 , Mark Kettenis , Sughosh Ganu Subject: [PATCH v4 14/15] efi_memory: rename variable to highlight overlap with free memory Date: Tue, 15 Oct 2024 21:07:16 +0530 Message-Id: <20241015153717.401371-15-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015153717.401371-1-sughosh.ganu@linaro.org> References: <20241015153717.401371-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 V3: None 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 6b9a66a06c0..291eca5c077 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 f59f7780e92..b63b5cca71e 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. From patchwork Tue Oct 15 15:37: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: 835459 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp301708wrs; Tue, 15 Oct 2024 08:40:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV5fHIRUxKdxjHip+MJFTT5s1KSeJerOtmUd3hYEslnJsxXk/Er+m69ZgsJB3z910tuL0+KEw==@linaro.org X-Google-Smtp-Source: AGHT+IFVhpbKByfVyVx2CRPjJk7hmy3zttQlFQc3MdO8qFi0FXx7WnQ7WICilAElb8yEYhBVjTC0 X-Received: by 2002:a05:6602:3426:b0:82c:ee6d:a7ee with SMTP id ca18e2360f4ac-83a64cb6568mr698647639f.2.1729006819476; Tue, 15 Oct 2024 08:40:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729006819; cv=none; d=google.com; s=arc-20240605; b=hexR1FdTNDHZHKxtH542i+wAXGj+zYvcoi25JJrEUB/hIGDZkD0EEwrpP0hI0RAjqq RZhmw7eLbVe3Ai+b1W4h9wht/2P2Npp6EBlCFaHClzgIRkA3luIB9lpCY3zfOLlHznPR OfgubK+f6VzJXZ7tFoKF0cghZ34M997GPkBJCpwKphUi7/G34GMBgE1CGDJblu6mgqJz CapaMIh+4LWUjpoaGIa5CaEiTyWjrUlxrX3YsOyAVE6E9nJjN/DnRVWeIwJn2bNtfv2A 1n88BunSS36Zsc2/CK1faY7kqFTHWbI3lsFr0iN9Die78cRvKmCZgo+KeLiH1xLNe+lI SEPg== 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=P/OASq2S24YQW1CoLpDopPBQYjdgCALbONzwtlnvCoY=; fh=MYvlzMqd61VHJORtkCu1tTA+qP9jRMJFkVEqSzDEdy8=; b=hUZc2XuobVpPYUTnqXaahmIKBAbeXJJGRtxRVjTSX0cRaoAI4VsD7XLxItzEQWHiXu r4ou9K0wZDkbehCks6h1pI70O+3MbMqqT9m8IAGz0mpf7Xkj+GSEUetUEk5tTen3GJ+i RfzTRqfeYSUY5pCWa3g/ODSVDijGHMJWdaQplbOEmnO91IcwGZe1HBL/TyH3O6hY+4Oz lIsFJLrSJ/txk4MwPACNSvSUt5lKyukh2sJeusK4Syzk7vHfCSITK/ZI3UZWW9szw9/y igFp49TV1iN2ohlSX87T3/HfGiYwud63pcniL92nxZrL4rww9GZobklc1bY2klsQ+6TQ P7ug==; 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-4dbecd0bbdbsi729784173.191.2024.10.15.08.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 08:40:19 -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 29FF988D5C; Tue, 15 Oct 2024 17:38:33 +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 19E9E88730; Tue, 15 Oct 2024 17:38:32 +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_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_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 E4E2288D97 for ; Tue, 15 Oct 2024 17:38:29 +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 F27B7175D; Tue, 15 Oct 2024 08:38:58 -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 7FD7B3F528; Tue, 15 Oct 2024 08:38:26 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Caleb Connolly , Jonas Karlman , Mark Kettenis , Sughosh Ganu Subject: [PATCH v4 15/15] lmb: replace the double-underscore with single-underscore for all functions Date: Tue, 15 Oct 2024 21:07:17 +0530 Message-Id: <20241015153717.401371-16-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015153717.401371-1-sughosh.ganu@linaro.org> References: <20241015153717.401371-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 A bunch of static functions in the LMB module have used a double-undersore for the function names. It was suggested to use a single-underscore instead, as the double-underscore is usually used by library functions. Replace the double-underscore with single-underscore for all functions. Signed-off-by: Sughosh Ganu Suggested-by: Simon Glass --- Changes since V3: None lib/lmb.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index f3a1d8ca256..78fe2d4de7c 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -496,7 +496,7 @@ long lmb_add(phys_addr_t base, phys_size_t size) return 0; } -static 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; @@ -562,7 +562,7 @@ long lmb_free_flags(phys_addr_t base, phys_size_t size, { long ret; - ret = __lmb_free(base, size); + ret = _lmb_free(base, size); if (ret < 0) return ret; @@ -618,7 +618,7 @@ static phys_addr_t lmb_align_down(phys_addr_t addr, phys_size_t size) return addr & ~(size - 1); } -static phys_addr_t __lmb_alloc_base(phys_size_t size, ulong align, +static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr, enum lmb_flags flags) { u8 op; @@ -692,15 +692,15 @@ phys_addr_t lmb_alloc(phys_size_t size, ulong align) */ phys_addr_t lmb_alloc_flags(phys_size_t size, ulong align, uint flags) { - return __lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE, - 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; - alloc = __lmb_alloc_base(size, align, max_addr, LMB_NONE); + alloc = _lmb_alloc_base(size, align, max_addr, LMB_NONE); if (alloc == 0) printf("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n", @@ -727,7 +727,7 @@ phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align, { phys_addr_t alloc; - alloc = __lmb_alloc_base(size, align, max_addr, flags); + alloc = _lmb_alloc_base(size, align, max_addr, flags); if (alloc == 0) printf("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n", @@ -736,7 +736,7 @@ phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align, return alloc; } -static phys_addr_t __lmb_alloc_addr(phys_addr_t base, phys_size_t size, +static phys_addr_t _lmb_alloc_addr(phys_addr_t base, phys_size_t size, enum lmb_flags flags) { long rgn; @@ -767,7 +767,7 @@ static phys_addr_t __lmb_alloc_addr(phys_addr_t base, phys_size_t size, */ phys_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size) { - return __lmb_alloc_addr(base, size, LMB_NONE); + return _lmb_alloc_addr(base, size, LMB_NONE); } /** @@ -785,7 +785,7 @@ phys_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size) phys_addr_t lmb_alloc_addr_flags(phys_addr_t base, phys_size_t size, uint flags) { - return __lmb_alloc_addr(base, size, flags); + return _lmb_alloc_addr(base, size, flags); } /* Return number of bytes from a given address that are free */