Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A0CEC433F5 for ; Thu, 14 Apr 2022 13:52:02 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7E5B283EB3; Thu, 14 Apr 2022 15:52:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1649944320; bh=Rlr5jVyBCBbD79j1jEIcYJbjKNTbuvX8jjHu4QRqpbg=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=y6TAjR6vDntMZaKpthWDcZqqmuyLtYZynsayxujtspBd41ULZJtRcXsLk1WtoK8MG +heqoyuss1WxP+svic75j+dPMPoEYoQpyZcRt3pzy0QUN16qoklDW8JNKCeou1r1Ox 81e2Gx0Wgaa0bbKz9LFNdENCKvUVDSZfQoE7XVAfHIHYFeYIv4qc7slDG9YK3nVlvI iiNBjqp4MMBrJFHxAKlTBSnA4c16k+R5py9ELe8e4+v2LjmgU9hiBUGMBRwWnOQ2oS SzOWFJnJ1f0Wt2IPGWj8A1mMOwui21PY4TgEkfLo8ALXgFEkv2zEvPWuzlDYXaCx9v gu6a3+M/Dh4bQ== Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 5C7FC83EA1; Thu, 14 Apr 2022 15:51:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1649944318; bh=Rlr5jVyBCBbD79j1jEIcYJbjKNTbuvX8jjHu4QRqpbg=; h=From:To:Cc:Subject:Date:From; b=dl1BClCbVpu45y8MGZxOk29ncZg1DWGyhhDZ38ISxM5G5q4O+YDwJWfmey1pzJYjM jq1/bNOAyXi9v2TDTNPxo8HFbWlmvJWVGX0+Np0+tppYKiK/PTl5OiaYwcOGUWmgCp PIkd6Fg9d4WRmNobL43+UDJvayrvy6oWGd6lRJTO10Rc3VYC17lUGX4v5mqYlTG7kV SMTjxk6OM6cdk1ia1teB6gboERNmYeMzLsbHXT6eTVNVeKbRuFuGYCvWwR7GCkmUhl 0wjsXybDXuAH2xDUdhEnunN3iTKEGkx/IbHohHmlH18JSNuurF/HbVOe0O79oCaX2S p0Wj4fc0ytCrg== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Fabio Estevam , Frieder Schrempf , Peng Fan , Stefano Babic Subject: [PATCH] ARM: imx: imx8m: Fix board_get_usable_ram_top() Date: Thu, 14 Apr 2022 15:51:46 +0200 Message-Id: <20220414135146.51352-1-marex@denx.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.5 at phobos.denx.de X-Virus-Status: Clean The 4 GiB boundary is at 0xffffffff+1 , not at 0x80000000, fix this. The PHYS_SDRAM of i.MX8M is at 0x40000000 , so to restrict ram_top below 4 GiB, the ram_top has to be set to 0xffffffff as it is not an offset from the start of PHYS_SDRAM, but rather a physical address marking the topmost allowed DRAM address. Fixes: e27bddff4b9 ("imx8m: Restrict usable memory to space below 4G boundary") Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: Frieder Schrempf Cc: Peng Fan Cc: Stefano Babic --- arch/arm/mach-imx/imx8m/soc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c index 8171631db10..e7fe7c2fd88 100644 --- a/arch/arm/mach-imx/imx8m/soc.c +++ b/arch/arm/mach-imx/imx8m/soc.c @@ -331,7 +331,7 @@ phys_size_t get_effective_memsize(void) ulong board_get_usable_ram_top(ulong total_size) { - ulong top_addr = PHYS_SDRAM + gd->ram_size; + ulong top_addr; /* * Some IPs have their accessible address space restricted by @@ -339,8 +339,7 @@ ulong board_get_usable_ram_top(ulong total_size) * space below the 4G address boundary (which is 3GiB big), * even when the effective available memory is bigger. */ - if (top_addr > 0x80000000) - top_addr = 0x80000000; + top_addr = clamp_val((u64)PHYS_SDRAM + gd->ram_size, 0, 0xffffffff); /* * rom_pointer[0] stores the TEE memory start address. -- 2.35.1