From patchwork Thu Sep 5 08:28:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 825626 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp187194wrb; Thu, 5 Sep 2024 01:30:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVuEVT8745mJWzKWdyiX4akj8R3rryLS4SlnMOe9Q0SuPZEhH9P6CK7c8Xtg7DdtaHVzYLkzg==@linaro.org X-Google-Smtp-Source: AGHT+IHGm44cwe4CvO4YdgAXbhpm/9U0Res6sTuBZnZBorqq0O/cThsWdGTyqNiuIjN5s596salR X-Received: by 2002:a17:907:1b97:b0:a89:b820:335 with SMTP id a640c23a62f3a-a89b820043cmr975122466b.65.1725525048376; Thu, 05 Sep 2024 01:30:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725525048; cv=none; d=google.com; s=arc-20240605; b=Y7KUHikK/5AguEgWKBubM3VB/AdrNTYyxb+KZ3rmWmyGtp6ywPCdrgVr4h23Z0bsUm S2WyDZAONlw1IKMGiSswORTEBZJreNMBZVtQ9QtUHQQ5QEhaAND/DW4SVjqtSMz2S6pc /kda986vdTfbk6x/d58dMxsbD3GvxDRskurFfrShpoYBV67zoDDzfLGIYmkU4ma3YQit AKkT8/XUlfUzVnMJ/fCYpb7wPWHV7meWy0yu4KMoaRfzZ1jCLIbIYSKaY8MXrszyEGm0 zyNq7BF5S+0fBjdDe0WdjUtkkMYqm+Ai03GgkmKHq1ooAsNcxcTScm2cA+JGN+XBODNg qW1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=ha6IqWRHhhu18/Sz2sJqgV1DvNuwhag5xpZbTjh4Ku8=; fh=xhhG27Jur2HVmyj6xWbgrQg2vRawqr6LmtjP4yz05ls=; b=ZAYtDo+iK5SbT/tsTJZ+U6GYMB4byYNqH9QF5PfrUXvmApcGDHQN8WN3UD56FnQwDq gRnBEbAlPoqDMn+jOrQBgF2KXUODzy/EC+y1Rl5IJdcKJkUGN9JFJSGbRfnoDFSBLjq/ Cv8weUgiXBExJKMLTNggIK065L4oaAq4vEWmTfSD8dsGpWsk4d9OuPXUPohNGvlmHitz EcSyTEWoonXYZ7H7w/x656HvwMa3vpIKEWzXOGwSs5eva51E9j1Glq1cbcv2lmfOSBFr GA65bFHUO3qBzeCbricGz/brLqYlunPb17arJwCaKfi3NovdxSubXp/T80ecYisM8ulB KNhg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a8a61fdd426si117300266b.184.2024.09.05.01.30.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:30:48 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B194088CA2; Thu, 5 Sep 2024 10:29:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 63ABA88C6D; Thu, 5 Sep 2024 10:29:15 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 8E8E388CE8 for ; Thu, 5 Sep 2024 10:29:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9C0F7FEC; Thu, 5 Sep 2024 01:29:38 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A9A0F3F66E; Thu, 5 Sep 2024 01:29:09 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Tom Rini , Bin Meng , Sughosh Ganu Subject: [PATCH 13/16] x86: e820: use the lmb API for adding RAM memory Date: Thu, 5 Sep 2024 13:58:08 +0530 Message-Id: <20240905082811.1585467-14-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905082811.1585467-1-sughosh.ganu@linaro.org> References: <20240905082811.1585467-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The EFI_CONVENTIONAL_MEMORY type is now being managed through the LMB module. Add a separate function, lmb_arch_add_memory() to add the RAM memory to the LMB memory map. The efi_add_known_memory() function is now used for adding any other memory type to the EFI memory map. Signed-off-by: Sughosh Ganu --- arch/x86/lib/e820.c | 47 ++++++++++++++++++++++++++++++++++----------- lib/Kconfig | 2 +- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/arch/x86/lib/e820.c b/arch/x86/lib/e820.c index 122b4f7ca0..d478b7486e 100644 --- a/arch/x86/lib/e820.c +++ b/arch/x86/lib/e820.c @@ -4,6 +4,7 @@ */ #include +#include #include #include @@ -41,15 +42,11 @@ void efi_add_known_memory(void) { struct e820_entry e820[E820MAX]; unsigned int i, num; - u64 start, ram_top; + u64 start; int type; num = install_e820_map(ARRAY_SIZE(e820), e820); - ram_top = (u64)gd->ram_top & ~EFI_PAGE_MASK; - if (!ram_top) - ram_top = 0x100000000ULL; - for (i = 0; i < num; ++i) { start = e820[i].addr; @@ -72,13 +69,41 @@ void efi_add_known_memory(void) break; } - if (type == EFI_CONVENTIONAL_MEMORY) { - efi_add_conventional_memory_map(start, - start + e820[i].size, - ram_top); - } else { + if (type != EFI_CONVENTIONAL_MEMORY) efi_add_memory_map(start, e820[i].size, type); - } } } #endif /* CONFIG_IS_ENABLED(EFI_LOADER) */ + +#if CONFIG_IS_ENABLED(LMB_ARCH_MEM_MAP) +void lmb_arch_add_memory(void) +{ + struct e820_entry e820[E820MAX]; + unsigned int i, num; + u64 ram_top; + + num = install_e820_map(ARRAY_SIZE(e820), e820); + + ram_top = (u64)gd->ram_top & ~EFI_PAGE_MASK; + if (!ram_top) + ram_top = 0x100000000ULL; + + for (i = 0; i < num; ++i) { + if (e820[i].type == E820_RAM) { + u64 start, size, rgn_top; + + start = e820[i].addr; + size = e820[i].size; + rgn_top = start + size; + + if (start > ram_top) + continue; + + if (rgn_top > ram_top) + size -= rgn_top - ram_top; + + lmb_add(start, size); + } + } +} +#endif /* CONFIG_IS_ENABLED(LMB_ARCH_MEM_MAP) */ diff --git a/lib/Kconfig b/lib/Kconfig index ee0b4d65f2..75447dfa27 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1130,7 +1130,7 @@ config SPL_LMB config LMB_ARCH_MEM_MAP bool "Add an architecture specific memory map" depends on LMB - default y if FSL_LAYERSCAPE + default y if FSL_LAYERSCAPE || X86 help Some architectures have special or unique aspects which need consideration when adding memory ranges to the list of available