From patchwork Thu Jul 4 07:35: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: 809927 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1042979wru; Thu, 4 Jul 2024 00:39:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXGc4e04yDlALuy/PzBPCYbt572EEUvt0/ysVPx6DJA1aF4AcT9zLvmYAzao4qgHhjoJLwo8/ABvozV6rMdPMYg X-Google-Smtp-Source: AGHT+IHQrT5Hf9NepBTaJKTp1mlNBNiL2sGz0fTH2eE+2WIMyMIjoFzz/bE5FBvBcqnomii1zy9y X-Received: by 2002:ac2:5f99:0:b0:52e:976a:b34b with SMTP id 2adb3069b0e04-52ea062063dmr647923e87.15.1720078796134; Thu, 04 Jul 2024 00:39:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720078796; cv=none; d=google.com; s=arc-20160816; b=O6OkzSWhG/kiMoRuomcSR5etMSjpF67eO6u4ppZRhQeP0lZw7sRkW7oFWMW+5weKdJ NnVOPF2R+j/FEtKG1A4qAcyrlKUIXBoyDMfj3gYP68DklgJUkgOfeZ1xOFqQY54+wcew 5Eq70jMxCs9ZyQcklP7Kug4iXkLZxZvcdr958rx7thoXY0yG1mcvxsFREP1cfqFDsO7l q5GkQQgPzXk+he1u2WrPq2s4Zm/I7AROjIwgtNAeAFdpsHK1hclFVFphFnzAqhQkF4OW 0vHqwm8NQpMHObXgVocZQUE/wX61KD1giaflV84rDkXJVvZf04FDEHq2xPJaHGNJJJYd sQJw== 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=LlCkFX4AhS9QwHFXijSACfJCgWFICvhNbzHa7jXynYI=; fh=ez1zzjhC0XWyqTp7tWutqrA/nFdALDnQKrnQnXYhk5Q=; b=jVuvCHTUWRKHFbOEWQvuS/69JtPddL/vkL2FT6FanifZOjQgDZnOzbBiO9pagBqY07 oGnCzGUl5xEV/MsdATGlZD0kfTz++7pd4MmuJ2uB2rrpj5hJFucQ5otahpdIMO/bzqBF glD/UlUqW1OYvhehSCAYX4f79j2JU0m8BltRcrCcC+d+TwlWE5r8xWVxx9bG2dpbgkK/ dRXamSHIFOIuf1hxxy01dTPWN4VINCsdDnX4Nk9BQ3rThbl0mlKSF44+faFc+i7pc7mm je/fo4b6nxmseh6FLUjLFgB1qw2wivUHmr1rza/WGso+SxVR39MQyK2TlZWvyL+jMQun JDlA==; 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-a72ab096bf8si692311766b.836.2024.07.04.00.39.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jul 2024 00: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 E2C9588915; Thu, 4 Jul 2024 09:37: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 4DDE08892C; Thu, 4 Jul 2024 09:37: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_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 7D04788910 for ; Thu, 4 Jul 2024 09:37:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 04CB6367; Thu, 4 Jul 2024 00:37:43 -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 D4F233F762; Thu, 4 Jul 2024 00:37:14 -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 20/48] lmb: reserve common areas during board init Date: Thu, 4 Jul 2024 13:05:16 +0530 Message-Id: <20240704073544.670249-21-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 LMB module provides API's for allocating and reserving chunks of memory which is then typically used for things like loading images for booting. Reserve the portion of memory that is occupied by the U-Boot image itself, and other parts of memory that might have been marked as reserved in the board's DTB. Mark these regions of memory with the LMB_NOOVERWRITE flag to indicate that these regions cannot be re-requested or overwritten. Signed-off-by: Sughosh Ganu Reviewed-by: Simon Glass --- Changes since V1: * Mark the reserved regions as LMB_NOOVERWRITE. * Call the lmb_reserve_common() function in U-Boot proper after relocation. lib/lmb.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index e1dde14a3c..456b64c00a 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -173,10 +174,11 @@ void arch_lmb_reserve_generic(ulong sp, ulong end, ulong align) if (bank_end > end) bank_end = end - 1; - lmb_reserve(sp, bank_end - sp + 1); + lmb_reserve_flags(sp, bank_end - sp + 1, LMB_NOOVERWRITE); if (gd->flags & GD_FLG_SKIP_RELOC) - lmb_reserve((phys_addr_t)(uintptr_t)_start, gd->mon_len); + lmb_reserve_flags((phys_addr_t)(uintptr_t)_start, + gd->mon_len, LMB_NOOVERWRITE); break; } @@ -739,5 +741,9 @@ int lmb_mem_regions_init(void) lmb_add_memory(); + /* Reserve the U-Boot image region once U-Boot has relocated */ + if (spl_phase() == PHASE_BOARD_R) + lmb_reserve_common((void *)gd->fdt_blob); + return 0; }