From patchwork Mon Aug 26 11:59:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 822460 Delivered-To: patch@linaro.org Received: by 2002:adf:e044:0:b0:367:895a:4699 with SMTP id w4csp1478830wrh; Mon, 26 Aug 2024 05:04:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXDt9Y/mp6mTZmwodn2Kc2gWMH3LGMGl3S897yVat4Hk3N/NY+KE1Z/gfHDrQYV4wWqUtNtyA==@linaro.org X-Google-Smtp-Source: AGHT+IHbfCRnSOdhFk97A2Sa2mqY7T5GXczNRJXgnghVj4voEqFuEQ+hmn5vYVA7pWXe1Kyv5luq X-Received: by 2002:a5d:5246:0:b0:371:72a8:155 with SMTP id ffacd0b85a97d-373118d2728mr6100310f8f.49.1724673872512; Mon, 26 Aug 2024 05:04:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724673872; cv=none; d=google.com; s=arc-20160816; b=wMpxQrIPHQPM5YgYkRCguO+OAKiJo8k70xdPA/WRVwDAzmWxYjuqHJm6GcluX1vfOS 2DABvZurfkvpQF6Sxim0d1hi9HUXiCb2y4gKi1kDYXYVrALOQWOKh0w0rAmUNjEWz0mI GS86C0MMVM0BcFGC41TU4ulzgBHDVnuT7fi11jDS7fzTb/zDaQqttUu6qFRpFhSoXpQD s/qMkeWdRZFCW5rLStf1kLApYbsMfusi/b/utCPiZJQ0B4N9VEuukzfXgFiJy5SeMJ/S jJlSgltm42uyZPPBQL0t1d59Vm2+ZChULv/x0wVVCXmzS6t/w8sapBC9e7v/GxsIs4a+ zg3w== 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=N+O+61m6ZlALuBxhkaA4lCuTXMMWRA5nVErxYEYidZg=; fh=8IbOOFAUJYCfGYrzM0jWqtoOP7AaZuPOmdHZ5mvNk1Q=; b=LDew8GVT3RgTu8odVW+m+NW0KQ3L68spFzl/KoZUSIXltiLp+Fupzyz5puQkeTflBu 8rwnNrqiRqPeZ90LJ08ybK4DXR8d3sBMk+XgHpHNV81uDUOoM4aoJ8021vvGHXWuhIKz q+qz7TJfaJLWThtpiDxzkbD6YPWjDAzi7f6DfBOJkEZ+v8hvJLboiRSrLdyvZeuilJVo Hqly/AEpDbmrMiCcfaoKR7k6G0O2Ba6k1oArsGyYH/yNpo4U+wejyHbCq71IatlF7Qz2 lIlPFxnM2dtPsXGcX7shnumFp3OvUKQ4dyzNmWeyEpWlTZRxDwamtC+fMoc5/enPZJIL SA1w==; 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 ffacd0b85a97d-3730828c7f5si3819950f8f.894.2024.08.26.05.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 05:04:32 -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 C4FDA889FC; Mon, 26 Aug 2024 14:02:00 +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 3306988AD7; Mon, 26 Aug 2024 14:01:59 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_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 360F4889FC for ; Mon, 26 Aug 2024 14:01:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D6EA211FB; Mon, 26 Aug 2024 05:02:22 -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 018B23F762; Mon, 26 Aug 2024 05:01:52 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Simon Glass , Tom Rini , Ilias Apalodimas , Heinrich Schuchardt , Marek Vasut , Mark Kettenis , Michal Simek , Patrick DELAUNAY , Patrice CHOTARD , =?utf-8?q?Marek_Beh=C3=BAn?= , Sughosh Ganu Subject: [PATCH v4 26/27] stm32mp: compute ram_top based on the optee base address Date: Mon, 26 Aug 2024 17:29:39 +0530 Message-Id: <20240826115940.3233167-27-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240826115940.3233167-1-sughosh.ganu@linaro.org> References: <20240826115940.3233167-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 value of ram_top address currently gets computed in an indirect manner. The boot_fdt_add_mem_rsv_regions() function gets called first to reserve the memory region occupied by OP-TEE in the LMB memory map. This is followed by a call to the lmb_alloc() API, which returns an address which is below the OP-TEE base address. This address is the value of ram_top returned by the board_get_usable_ram_top() function. This has now changed, as the LMB memory map, which is no longer local, gets set up after relocation. Get the OP-TEE base address by reading the device tree, and set the ram_top from this value. Signed-off-by: Sughosh Ganu --- Changes since V3: None arch/arm/mach-stm32mp/dram_init.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c index 286791be2e..198785353f 100644 --- a/arch/arm/mach-stm32mp/dram_init.c +++ b/arch/arm/mach-stm32mp/dram_init.c @@ -62,8 +62,10 @@ int dram_init(void) phys_addr_t board_get_usable_ram_top(phys_size_t total_size) { + int ret; phys_size_t size; phys_addr_t reg; + u32 optee_start, optee_size; if (!total_size) return gd->ram_top; @@ -73,16 +75,10 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size) * if the effective available memory is bigger */ gd->ram_top = clamp_val(gd->ram_top, 0, SZ_4G - 1); + size = ALIGN(SZ_8M + CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE); - /* found enough not-reserved memory to relocated U-Boot */ - lmb_add(gd->ram_base, gd->ram_top - gd->ram_base); - boot_fdt_add_mem_rsv_regions((void *)gd->fdt_blob); - /* add 8M for reserved memory for display, fdt, gd,... */ - size = ALIGN(SZ_8M + CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE), - reg = lmb_alloc(size, MMU_SECTION_SIZE); - - if (!reg) - reg = gd->ram_top - size; + ret = optee_get_reserved_memory(&optee_start, &optee_size); + reg = (!ret ? optee_start : gd->ram_top) - size; /* before relocation, mark the U-Boot memory as cacheable by default */ if (!(gd->flags & GD_FLG_RELOC))