All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Schinagl <oliver+list@schinagl.nl>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC] ARM: U-boot and 2 GiB of ram with get_ram_size only being long
Date: Sat, 19 Oct 2013 11:07:54 +0200	[thread overview]
Message-ID: <52624BEA.8080204@schinagl.nl> (raw)
In-Reply-To: <1382138723.7979.928.camel@snotra.buserror.net>

On 10/19/13 01:25, Scott Wood wrote:
> On Sat, 2013-10-19 at 01:07 +0200, Oliver Schinagl wrote:
>> On 10/18/13 18:43, Scott Wood wrote:
>>> On Fri, 2013-10-18 at 02:04 +0200, Oliver Schinagl wrote:
>>>> So now that that's settled, anything fundamentally wrong with my patch? :)
>>>
>>> Did you see my other mail in this thread?  This patch is sort of OK for
>> Sorry I did and I got distracted from it.
>>
>>> raising the get_ram_size() limit from 1 GiB to 2 GiB (with an increased
>>> risk of false positives from I/O), but it can't go beyond that on
>> I'd ask 'how so' but I'm not sure I'd understand anyway ;)
>
> Do you mean why it can't go beyond 2 GiB?  The next address to probe
> after 0x8000_0000 would be 0x1_0000_0000 which is beyond what can be
Yeah why can't it go beyond 2 GiB. It should be an unsigned long, so it 
should be able to go beyond 2 GiB, as you state, upto 4 GiB on a 32-bit 
environment.

What my patch fixes is, that u-boot passes ram parameters (ramsize) via 
the global data -> ramsize. Ramsize is a phys_size_t which is defined as 
unsigned long (yay for typedef :p). Nearly all platforms pass the memory 
size to the linux kernel as gd->ramsize = get_ram_size();

And here is the bug, (unsigned long)ramsize = (signed long)get_ram_size();

 > addressed in a 32-bit environment.  I suppose you could return 4 GiB > if
 > 0x8000_0000 tests OK, but nothing beyond that.  You'd need a larger
 > datatype than "unsigned long" if you want to return 4 GiB, though.
As for returning exactly 4 GiB, assuming that register space is 0 bytes 
(impossible but lets just say for arguments sake) we now have 
0x8000_0000 addresses available, so exactly 4 GiB. If for whatever 
reason it ends up being only 4 GiB -1 byte, I don't think anybody will 
care/notice (but it would have to be taken into account I suppose?

>
> And the one 64-bit environment that we're about to have in U-Boot
> (armv8) has discontiguous memory, which is another case where
> get_ram_size() won't work.
So get_ram_size() needs a brother, get_discont_ram_size? :)
>
>>> 32-bit.  A better approach would be to get the RAM size from the memory
>>> controller, which is what we do on many Freescale PPC boards.
>> Not possible for us at this moment. The memory controller is programed
>> with hard-coded values on a per board basis. I think we could
>> technically obtain values via/from the memory controller, but have no
>> knowledge at this moment. Allwinner has a tool, livesuit, which is used
>> to flash full disk images to a device. We currently guesstimate that
>> livesuit can somehow detect the memory parameters and injects it into
>> the stock bootloader. But we really have no clue if that really happens
>> or how it's done. So we rely on extracting the information from a
>> running stock android/linux and hardcode it into u-boot.
>
> So the issue is that you don't have documentation on what the values you
> program into the memory controller mean?  Can you extract the memory
> size as well from a running stock image?
Sort of, we bus-width, io-size and chip density, from those values we 
determine the chip-size/ram-size we can't exctract the actual number.

That said, io-size I think (or was it bus-width?) while programmed into 
the ram controller, isn't even highly important, it is expected that it 
is used for drive strength, 2 chips vs 4 chips, but physical examination 
of the tablet/board helps here.

Oliver
>
> BTW, shouldn't get_ram_size restore the original data in the final
> "return (maxsize)" case?  I know, patches welcome. :-)
>
> -Scott
>
>
>

  parent reply	other threads:[~2013-10-19  9:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-03 21:15 [U-Boot] [RFC] ARM: U-boot and 2 GiB of ram with get_ram_size only being long Oliver Schinagl
2013-10-07  2:41 ` Oliver Schinagl
2013-10-15  7:12   ` Albert ARIBAUD
2013-10-15 17:57     ` Scott Wood
2013-10-17  6:27       ` Albert ARIBAUD
2013-10-18  0:04         ` Oliver Schinagl
2013-10-18 16:43           ` Scott Wood
2013-10-18 20:26             ` Wolfgang Denk
2013-10-18 21:04               ` Scott Wood
2013-10-18 21:53                 ` Wolfgang Denk
2013-10-18 23:11               ` Oliver Schinagl
2013-10-18 23:07             ` Oliver Schinagl
2013-10-18 23:25               ` Scott Wood
2013-10-18 23:25                 ` Scott Wood
2013-10-19  9:21                   ` Oliver Schinagl
2013-10-19  9:07                 ` Oliver Schinagl [this message]
2013-10-19 18:25                   ` Tom Rini
2013-10-21 19:44                 ` Wolfgang Denk
2014-03-24 10:14                   ` Olliver Schinagl
2013-10-15 18:01 ` Scott Wood

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=52624BEA.8080204@schinagl.nl \
    --to=oliver+list@schinagl.nl \
    --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.