[PATCH] memsize: Make get_ram_size() work with arbitary RAM size
wd at denx.de
Tue Jul 21 08:51:26 CEST 2020
In message <4d5aaf77-378d-4ac2-0008-599ceeeb95ed at gmx.de> you wrote:
> > Are you sure? How is this supposed to work?
> > Running it with start = 0 and size = 0xC0000000 it will test the
> > memory locations
> > 0x80000000
> > 0xA0000000
> > 0xB0000000
> > 0xB8000000
> > 0xBC000000
> > 0xBE000000
> > 0xBF000000
> > 0xBF800000
> > 0xBFC00000
> > 0xBFE00000
> > 0xBFF00000
> > 0xBFF80000
> > 0xBFFC0000
> > 0xBFFE0000
> > 0xBFFF0000
> > 0xBFFF8000
> > 0xBFFFC000
> > 0xBFFFE000
> > 0xBFFFF000
> > 0xBFFFF800
> > 0xBFFFFC00
> > 0xBFFFFE00
> > 0xBFFFFF00
> > 0xBFFFFF80
> > 0xBFFFFFC0
> > 0xBFFFFFE0
> > 0xBFFFFFF0
> > 0xBFFFFFF8
> > 0xBFFFFFFC
> > 0xBFFFFFFE
> > 0xBFFFFFFF
> The last accessible byte is at 0xBFFFFFFF which matches (start + size -
> 1) in your example.
> The difference to the current logic is that it does not require start or
> size to be power of two.
Yes, I know, but your test strategy makes no sense. You have to
check memory at the power-of-two boudanries to find out how big the
ram actually is and whether your memory accesses may be mirrored at
other locations in the address room.
You are just testing the end of the expected size in some way for
which I cannot find a good explanation.
> If the size input is larger than the actually accessible memory size,
> you will get the actual memory size, e.g. lets assume that the last
> accessible address is 0x3333:
Please understand thtat this function is not a plain stupid size
test, but there is more intelligece in it. We have seen many cases
where for example the memory controller was set up for 256 MiB
address room, but only 64 MiB of memory were installed. The current
version of the test reliably detects that there are only 64 MiB of
memory presnet, clearly indicating the problem.
I think your test would happyly report to see 256 MiB of memory and
miss the fact that this is only one of the 4 mirrors of the real
memory - and of course any attempt to run Linux on such a system
would result in funny crashes...
> Now the algorithm returns that the last accessible memory location is
Come on. The purpose of this function as it was designed is to find
the size of installed memory in systems where this may change
because there may be several hardware configurations. And memory
chips tend to come in sizes that are a power of two.
And we not only test the size, we also verify basic functionality
(including errors like shorts of breaks in the data and address
lanes), and this really fast so it can be kept in the production
You drop all this very practical functionality for a feature which
is of hypothetical use at best?
> The algorithm runs in O(log(UINT_MAX)) which is the same time complexity
> as for the current algorithm.
Yes, but it makes absolutely no sense to me.
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I can't say I've ever been lost, but I was bewildered once for three
days. - Daniel Boone (Attributed)
More information about the U-Boot