All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/3] ARM: tegra: support large RAM sizes
Date: Tue, 23 Dec 2014 13:34:04 -0700	[thread overview]
Message-ID: <5499D1BC.6030206@wwwdotorg.org> (raw)
In-Reply-To: <CAPnjgZ2fvXEc2GN7H9jH188Bhe4t=DQbja_QNoZvFAfSjtkaKg@mail.gmail.com>

On 12/23/2014 01:05 PM, Simon Glass wrote:
> Hi Stephen,
>
> On 23 December 2014 at 10:34, Stephen Warren <swarren@wwwdotorg.org> wrote:
>> From: Stephen Warren <swarren@nvidia.com>
>>
>> Some systems have so much RAM that the end of RAM is beyond 4GB. An
>> example would be a Tegra124 system (where RAM starts at 2GB physical)
>> that has more than 2GB of RAM.
>>
>> In this case, we want gd->ram_size to represent the actual RAM size, so
>> that the actual RAM size is passed to the OS. This is useful if the OS
>> implements LPAE, and can actually use the "extra" RAM.
>>
>> However, we can't use get_ram_size() to verify the actual amount of RAM
>> present on such systems, since some of the RAM can't be accesses, which
>> confuses that function. Avoid calling get_ram_size() when the RAM size
>> is too large for it to work correctly. It's never actually needed anyway,
>> since there's no reason for the BCT to report the wrong RAM size.
>>
>> In systems with >=4GB RAM, we still need to clip the reported RAM size
>> since U-Boot uses a 32-bit variable to represent the RAM size in bytes.

>> diff --git a/arch/arm/cpu/tegra-common/board.c b/arch/arm/cpu/tegra-common/board.c

>> @@ -40,7 +40,27 @@ unsigned int query_sdram_size(void)
>>          size_bytes = get_ram_size((void *)PHYS_SDRAM_1, emem_cfg * 1024);
>>   #else
>>          debug("mc->mc_emem_cfg (MEM_SIZE_MB) = 0x%08x\n", emem_cfg);
>> -       size_bytes = get_ram_size((void *)PHYS_SDRAM_1, emem_cfg * 1024 * 1024);
>> +       /*
>> +        * If >=4GB RAM is present, the byte RAM size won't fit into 32-bits
>> +        * and will wrap. Clip the reported size to the maximum that a 32-bit
>> +        * variable can represent (rounded to a page).
>> +        */
>> +       if (emem_cfg >= 4096) {
>> +               size_bytes = U32_MAX & ~(0x1000 - 1);
>
> Will this return 4GB - 4KB? Why not return the full size?

A U32 can only store 4GB-1 at most, so we can never put the full 4GB 
value into size_bytes.

I aligned the value down to page alignment rather than storing 4GB-1 
there to prevent surprises elsewhere. For example, not all adjustments 
to gd->relocaddr in board_f.c page-align the allocations. In particular, 
I have enabled reserve_pram() locally for other reasons, and it just 
blindly subtracts the size from the current value of gd->relocaddr. 
Arguably that's a bug in that code, but I figured it was simplest to 
return a sensibly aligned size irrespective of that.

  reply	other threads:[~2014-12-23 20:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-23 17:34 [U-Boot] [PATCH 1/3] common: board: support systems with where RAM ends beyond 4GB Stephen Warren
2014-12-23 17:34 ` [U-Boot] [PATCH 2/3] ARM: tegra: fix variable naming in query_sdram_size() Stephen Warren
2014-12-23 20:02   ` Simon Glass
2014-12-23 17:34 ` [U-Boot] [PATCH 3/3] ARM: tegra: support large RAM sizes Stephen Warren
2014-12-23 20:05   ` Simon Glass
2014-12-23 20:34     ` Stephen Warren [this message]
2014-12-23 22:18       ` Simon Glass
2014-12-23 20:01 ` [U-Boot] [PATCH 1/3] common: board: support systems with where RAM ends beyond 4GB Simon Glass
2014-12-23 20:22   ` Stephen Warren
2014-12-23 20:26     ` Simon Glass
2015-01-19 22:57 ` Stephen Warren
2015-01-20 15:28   ` Tom Warren
2015-01-20 15:56   ` Tom Warren
2015-01-22 18:06     ` Stephen Warren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5499D1BC.6030206@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.