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 750BDC4332F for ; Wed, 9 Nov 2022 07:40:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4790684D1E; Wed, 9 Nov 2022 08:40:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="NZANPh78"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A416F84FF4; Wed, 9 Nov 2022 08:40:13 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 770A184D1E for ; Wed, 9 Nov 2022 08:40:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B50416125A; Wed, 9 Nov 2022 07:40:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8E75C433D6; Wed, 9 Nov 2022 07:40:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667979606; bh=gI/c7sfbAj31rFmUAfSubHMYRALJGhHW7Ep0sHRhSvA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NZANPh78oa9ZKJ0BTRI8jCaLobULWvAoxu3Rh7jRycMwFaBgeWQZApB/pzoEE0lo7 0Lc+TjCgAujRXp1qWA9sng+BNIrQ/Umu1bkKu1Njj8p6XxlCOuThCpKIAOA7h5qdUL Rq2BfJpKqxdKi1JnKeTM0FQd0il4o17VNllJtydep6iI4mgas+uRzmyg/+oeUv3j1b B2RYwlhnfnBMej1fcBy7nngLa04gr6j4IcscglNAk14RRZK1RFrHn0TIWHVGZdvx4u xaDSHZ3qbMO3yTi/XB8dHtF1s4NCcURzqzA2IUt8i2dSa9Zn+t9ZLo7CvJ0Y3/YobH PTCqnRJmlOI6g== Received: by pali.im (Postfix) id A702A735; Wed, 9 Nov 2022 08:40:02 +0100 (CET) Date: Wed, 9 Nov 2022 08:40:02 +0100 From: Pali =?utf-8?B?Um9ow6Fy?= To: Peng Fan Cc: Peng Fan , "sbabic@denx.de" , "festevam@gmail.com" , dl-uboot-imx , "u-boot@lists.denx.de" Subject: Re: [PATCH 01/11] imx: implement get_effective_memsize Message-ID: <20221109074002.5kepiyjo2kogqtor@pali> References: <20221107080016.1304-1-peng.fan@oss.nxp.com> <20221107080016.1304-2-peng.fan@oss.nxp.com> <20221107075554.crfgaoubgzalx23g@pali> <779bcfdd-0914-a440-53e6-d346c85a168a@oss.nxp.com> <20221108075452.rdl3wktvrjgkszgm@pali> <20221108080325.rvq7szat65rqf36r@pali> <293668ed-4851-4472-918d-81be54a1cb48@oss.nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <293668ed-4851-4472-918d-81be54a1cb48@oss.nxp.com> User-Agent: NeoMutt/20180716 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.6 at phobos.denx.de X-Virus-Status: Clean On Wednesday 09 November 2022 09:48:53 Peng Fan wrote: > On 11/8/2022 4:03 PM, Pali Rohár wrote: > > On Tuesday 08 November 2022 07:56:59 Peng Fan wrote: > > > > Subject: Re: [PATCH 01/11] imx: implement get_effective_memsize > > > > > > > > On Tuesday 08 November 2022 09:38:01 Peng Fan wrote: > > > > > On 11/7/2022 3:55 PM, Pali Rohár wrote: > > > > > > On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote: > > > > > > > From: Peng Fan > > > > > > > > > > > > > > To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause > > > > > > > the top 1MB not mapped as normal memory, because ARMV7-A use > > > > > > > section mapping. So implement i.MX6/7 specific > > > > > > > get_effective_memsize to fix the issue. > > > > > > > > > > > > > > Fixes: 777aaaa706bc("common/memsize.c: Fix get_effective_memsize() > > > > > > > to check for overflow") > > > > > > > Signed-off-by: Peng Fan > > > > > > > > > > > > Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid > > > > that issue? > > > > > > > > > > No, unless I decrease PHYS_SDRAM_SIZE. > > > > > > > > So, what is the issue? I just do not see what happens after 777aaaa706bc > > > > that RAM size is calculated incorrectly in your case. I did not catch the > > > > description from commit message. What are your gd->ram_size and > > > > CONFIG_MAX_MEM_MAPPED values that current code does not work? > > > > > > The base is 2GB, the size is 2GB. With CONFIG_MAX_MEM_MAPPED, > > > the ram_size already decreased by 4KB. > > > > If base is 2GB and size is 2GB then ram_top is 4GB which cannot be > > represented in 32-bit phys_size_t type and hence some of other u-boot > > functions use 0 as ram_top. Mentioned commit tries to fix this issue. > > I guess that you have some other hidden problem and my change just > > showed implication of that. > > The issue is with higher 4KB cut off, the MMU mapping will cut off > 1MB or 2MB(section mapping), so after MMU enabled, the PC instruction will > not able to fetch instruction in the higher 1MB area because of U-Boot > relocated to > top of DRAM. But it is not possible to represent whole 4GB of RAM size in 32-bit phys_size_t type. So some cut-off for this storage is required. > Regards, > Peng. > > Could you check how is gd->ram_top > > configured with and without this change? Could you check this? > > > Regards, > > > Peng. > > > > > > > > > > > > Regards, > > > > > Peng. > > > > > > > > > > > > > > > > > > --- > > > > > > > arch/arm/mach-imx/cache.c | 14 ++++++++++++++ > > > > > > > 1 file changed, 14 insertions(+) > > > > > > > > > > > > > > diff --git a/arch/arm/mach-imx/cache.c b/arch/arm/mach-imx/cache.c > > > > > > > index ab9b621a2a6..69a085abee7 100644 > > > > > > > --- a/arch/arm/mach-imx/cache.c > > > > > > > +++ b/arch/arm/mach-imx/cache.c > > > > > > > @@ -7,10 +7,24 @@ > > > > > > > #include > > > > > > > #include > > > > > > > #include > > > > > > > +#include > > > > > > > #include > > > > > > > #include > > > > > > > #include > > > > > > > +DECLARE_GLOBAL_DATA_PTR; > > > > > > > + > > > > > > > +phys_size_t get_effective_memsize(void) { #ifndef > > > > > > > +CONFIG_MAX_MEM_MAPPED > > > > > > > + return gd->ram_size; > > > > > > > +#else > > > > > > > + /* limit stack to what we can reasonable map */ > > > > > > > + return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ? > > > > > > > + CONFIG_MAX_MEM_MAPPED : gd->ram_size); #endif } > > > > > > > + > > > > > > > void enable_ca7_smp(void) > > > > > > > { > > > > > > > u32 val; > > > > > > > -- > > > > > > > 2.36.0 > > > > > > >