From mboxrd@z Thu Jan 1 00:00:00 1970 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 00D3DC433EF for ; Tue, 17 May 2022 15:52:37 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7BA768426D; Tue, 17 May 2022 17:52:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="iZiBR+9I"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1918583AD0; Tue, 17 May 2022 17:52:22 +0200 (CEST) Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CA1B083A97 for ; Tue, 17 May 2022 17:52:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qk1-x72a.google.com with SMTP id 126so14864945qkm.4 for ; Tue, 17 May 2022 08:52:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=wscq886i/XMnZhggyV/R9ELijyjRRrby0my3E9T3DDg=; b=iZiBR+9InI8YWRK5fZAc5Y32EXbXODakTxRK6vgdAUP3JS9LJGnsEv170rDhRMAfI8 V2NOvRhrOaNZ6oXmeZylZKxQSkoXI8drX9dGEqKD4GSQ4Gag00tjwdwu7Wd/HgxkM33g RiBiGstpaVSiOqP8X/PAdlpZnMYz57VdSfSFI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wscq886i/XMnZhggyV/R9ELijyjRRrby0my3E9T3DDg=; b=Cs0MDMizkrYdh7fWK67NUBrohK8yXGA8TE/9QMc955DzQUpcEhEHkCUXbXlp85OOgk 1wA5zOafx57fSFq4HFzyB7bdnQ12jYc0Wcf33c8RsXZpbONxzw6vrZN7cy5f3fjcixnq UHqcX52XmDK1C9t2Oy/R7UEhpIWfI+p2+e1xsPl3aLlzAG4TU9gG3P4nVBTbP3dviIb8 1XBoYrk3g8AIGEKBmpSiaiuVyCVJjjLRKOYAlYBBML/CKS3oSb1X7swWFKDXE5xCJjSh TbFCoLb9elnKmovjbv8SFg+i23hNud1EkZMlD3tGQvqp31DRNjZmU0XS/q9/pZfLl/Yf zuAw== X-Gm-Message-State: AOAM530nImKSMh9K+D010ywIs2eMUHB9ouOKK0pff61gJHYxZNUkU+bc U94YpdwR+giOQJEuii2EwGLTZw== X-Google-Smtp-Source: ABdhPJx+/nJE8ShvlNE1JKEbGBQfRZucyHAyn34m69a9Jg7rICcCbEXDIvVx/Gfv7xBF4CqnywtWyg== X-Received: by 2002:a05:620a:28c1:b0:6a0:464a:a9c4 with SMTP id l1-20020a05620a28c100b006a0464aa9c4mr16253494qkp.397.1652802737491; Tue, 17 May 2022 08:52:17 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b01-4500-3558-7670-e34f-c790.res6.spectrum.com. [2603:6081:7b01:4500:3558:7670:e34f:c790]) by smtp.gmail.com with ESMTPSA id x11-20020a05620a0b4b00b0069fc13ce204sm7733128qkg.53.2022.05.17.08.52.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 08:52:16 -0700 (PDT) Date: Tue, 17 May 2022 11:52:14 -0400 From: Tom Rini To: Pali =?iso-8859-1?Q?Roh=E1r?= Cc: Simon Glass , u-boot@lists.denx.de Subject: Re: Broken support for 4GB DDR on 32-bit platforms Message-ID: <20220517155214.GS3901321@bill-the-cat> References: <20220513230006.ep5qdhuu6k5ado2l@pali> <20220516123143.GI3901321@bill-the-cat> <20220516215651.g4joz4p6atpv57h2@pali> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="2RPSo2VWgDbGU+zh" Content-Disposition: inline In-Reply-To: <20220516215651.g4joz4p6atpv57h2@pali> X-Clacks-Overhead: GNU Terry Pratchett 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 --2RPSo2VWgDbGU+zh Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, May 16, 2022 at 11:56:51PM +0200, Pali Roh=E1r wrote: > On Monday 16 May 2022 08:31:43 Tom Rini wrote: > > On Sat, May 14, 2022 at 01:00:06AM +0200, Pali Roh=E1r wrote: > >=20 > > > Hello! I tried to enable support for 2GB+ of DDR memory (with 4GB DDR= 3) > > > on powerpc P2020 board in 32-bit addressing mode and U-Boot crashed > > > during startup. > > >=20 > > > I figured out that issue is not powerpc specific, but rather generic = to > > > all 32-bit platforms. U-Boot stores memory size into phys_size_t type > > > (gd->ram_size) and last mapped memory address increased by one byte i= nto > > > phys_addr_t type (gd->ram_top). > > >=20 > > > Despite size 4GB fits into 32-bit addressing mode, it does not fit in= to > > > above two variables, and it overflows to zero. U-Boot then see zero R= AM > > > size and crashes. > > >=20 > > > I tried to workaround this issue by changing both phys_size_t and > > > phys_addr_t types to 64-bit. But it did not helped because U-Boot on > > > many places cast gd->ram_size or gd->ram_top to ulong type, which is > > > 32-bit on 32-bit platforms. > > >=20 > > > Next I changed ulong parameters of board_get_usable_ram_top() function > > > to u64. > > >=20 > > > This still was not enough because config value CONFIG_MAX_MEM_MAPPED = is > > > ignored on one important place -- in function get_effective_memsize(). > > > This config value takes effect only when also CONFIG_VERY_BIG_RAM is > > > set. > > >=20 > > > Finally With this change I was able to start U-Boot with more than 2GB > > > of DDR memory inserted in SODIMM slot on P2020. > > >=20 > > > How to fix issues with gd->ram_size and gd->ram_top? That +1 byte is > > > really stupid limitation. Changing phys_size_t and phys_addr_t types > > > unconditionally to 64-bit? Or something else? > > >=20 > > > And what is the purpose of CONFIG_VERY_BIG_RAM config option? Why is > > > CONFIG_MAX_MEM_MAPPED check skipped in get_effective_memsize() functi= on, > > > but is not skipped on many more places? > >=20 > > So, there's two parts to this, as I recall it all. First, even on 64bit > > platforms we contain ourselves to 32bit address space and even then > > something within the "old" 2GB window. We then set a CONFIG option to > > not mess with the memory node in DT which has the real value. Second, > > for 32bit platforms which can support 4GB memory, or more, some further > > games need to be played, typically I believe around initializing the > > memory controller (I'm more confident of that for dra7xx_evm, which I > > don't have the big memory version of, just a small memory one) so that > > Linux can do whatever needs doing to enable "36bit" typically address > > support. Looking at the other P*36BIT* configs might give you some more > > clues about what to do on your platform, or at least who might still be > > able to explain and test things on the PowerPC side. >=20 > I know about 36-bit addressing on e500v2 but I'm not going to enable it > due to performance reasons (see Freescale AN4064 [1]). So I want to > stick with 32-bit addressing for 2GB+ memory usage (around 3GB; it is > 4GB minus memory used by peripherals; which is still more than 2GB). >=20 > And due to 32-bit type for phys_size_t, phys_addr_t and casting these > types to ulong is an issue. Plus issue with CONFIG_VERY_BIG_RAM and > CONFIG_MAX_MEM_MAPPED as I already wrote. I'm not seeing the problem, sorry. You run U-Boot in the normal 2GB area and tell Linux there's 3GB available. I kinda recall now that yes, you can do a 3:1 split in Linux instead of 2:2 split, but in that case you still do 2:2 in U-Boot. As you have seen configuring for anything else doesn't work. --=20 Tom --2RPSo2VWgDbGU+zh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmKDxKsACgkQFHw5/5Y0 tyydFwv9HVaNNRF01hE7dg3EL9Hxr437feefnbHWpjEfC7ewJAzwbRlr2W/Aup5x vJ+Hhxn++irA1EYCk6TRTB0JQJYZPg68x0nbHJs81N2XEYzhQhJzdvoIEOvddxaH tcIjdrQZX24kHwalSy0ovBdvR6WW33c9HGoYOAuZ2hv8IQIqebOHhwShlmEFz7Nk l31PdwIBYyg3WIVZC6Bmpt8oIQiv2BOFoxRzCxL/nVcD+7Kpzx2hYQ8BH561D9wG 6O2/DGgcxICD8Y10zuXg1Os0c8N0zviOkmyecWQ/D8RvPjLFYf2QQKbR+KvMcYWS dtztsUy+XkSVjtI+hJT2azqaTonGToTYnN8wSEIOzaMmHzDrzMbRBg88M5ve4QAN VfVTCu8v0DUD+UshDt341gYjHw+pwzrUMaYfA+Cte0GtDvws0xufqSHhHJ/A8hT5 5Z6hyTl79Hje5MfkGN/h2YeNPj336R08owGGgLQrWakAzO0RUBCUrdNujcATpt1d k2ih2uTk =ZLDc -----END PGP SIGNATURE----- --2RPSo2VWgDbGU+zh--