From patchwork Thu Jul 4 07:35:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 809951 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1044115wru; Thu, 4 Jul 2024 00:44:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWG/l8C1+Dss+aNCnEj5/U2nl/XnAGOnEZJ/Eto5e1LcuyKOGuvw61PZVvfeeSEgtxh5NJNlU8Q3M7unD7Zf2Yi X-Google-Smtp-Source: AGHT+IEyNedKaPKuttom4I1ZO3bzcgWHo7fsm8eBVxJ0zibF06/fCh8lusvC/aH3qfk2gHiHzrYN X-Received: by 2002:a17:907:97c8:b0:a72:6b08:ab1a with SMTP id a640c23a62f3a-a77ba711897mr64147166b.46.1720079056526; Thu, 04 Jul 2024 00:44:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720079056; cv=none; d=google.com; s=arc-20160816; b=I2W3B0AhOLCqsZF8n3/Evu6if7jC7ccPGjT0WtbSMME/n4Q878Jxs1UGNxE3StRq5U T+KquoF5d/stZc05jPat+kdrnCPPtutz1a5j2kSNgg1kfbIfVpg8Jmm/pJfeeCJ3x54g R3RswGxouodsNcV8x6GOqks8V+AGsovsKBRXvltfUn/z61W6t947MlGu4g61+ls66FZX fcmIl1wJDHSXiswUmTO83wEw0g75MjtK+hfrm1mzlWQZrHC/8VXY3lKmJUr6X8mQsiR2 wQmcayitnvHtEDg0VYVQMeNQFyjBOCi+VqQJEJpXXSSmbSEZU29gDpv98VvUJrkQ6Kea CpHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=curk5gr44mPThjzShVf0VtCt+MsLUaTBtXo6KgAOyIg=; fh=ez1zzjhC0XWyqTp7tWutqrA/nFdALDnQKrnQnXYhk5Q=; b=FASJSsq5jeplFJ4/5iLvvWBr2sSalhK8VHXL7dSgpEumMqimQBd2GxdicnuA4RT047 0wA8pJHAFng4p8Cf8G/qhqqEamLfASytwbmq9ZkgErRiHfSaQj++9REyU4M/h5HuZypv H6FBtKZqGMZX87L4H4iXw4XPTJ2akr+IoarbS8CbiVrhYbX2CmEWoqEeiDi+DYGSVQSc LyHjMUT8ESJuXQmTvbSd2JeKifLn8qyMjNGk1kIrM2nTcHrr0DYbJ29lvma3A1m/sM2F MN6OJRRxvjHLXrFyAoK/8Wio5vpN6YZbTNKu2zTc+wIutJG1iPd5fOwViszGn+e8wDpm Jyyg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a77ba99435fsi35842466b.873.2024.07.04.00.44.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jul 2024 00:44:16 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5C03488966; Thu, 4 Jul 2024 09:38:50 +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 704BB888E7; Thu, 4 Jul 2024 09:38:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 2FBAD88974 for ; Thu, 4 Jul 2024 09:38:47 +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 B1CBADA7; Thu, 4 Jul 2024 00:39: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 75F883F762; Thu, 4 Jul 2024 00:38:43 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Tom Rini , Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Marek Vasut , Mark Kettenis , Fabio Estevam , Michal Simek , Sughosh Ganu Subject: [RFC PATCH v2 44/48] x86: e820: use the lmb API for adding RAM memory Date: Thu, 4 Jul 2024 13:05:40 +0530 Message-Id: <20240704073544.670249-45-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240704073544.670249-1-sughosh.ganu@linaro.org> References: <20240704073544.670249-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The EFI_CONVENTIONAL_MEMORY type is now being managed through the LMB module. Add a separate function, lmb_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 V1: New patch arch/x86/lib/e820.c | 47 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/arch/x86/lib/e820.c b/arch/x86/lib/e820.c index 122b4f7ca0..8b3ce8c6ec 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) +void lmb_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) */