[U-Boot] [linux-sunxi] Re: [PATCH 2/5] sunxi: add Kconfig option for the maximum accessible DRAM
Icenowy Zheng
icenowy at aosc.io
Thu Feb 8 06:43:36 UTC 2018
在 2018-02-08 10:14,Chen-Yu Tsai 写道:
> On Thu, Feb 8, 2018 at 8:35 AM, André Przywara <andre.przywara at arm.com>
> wrote:
>> On 07/02/18 19:35, Icenowy Zheng wrote:
>>> Allwinner 64-bit SoCs can use 4GiB DRAM chip, however their memory
>>> map
>>> has only allocated 3GiB for DRAM, so only 3GiB of the DRAM is
>>> accessible.
>>>
>>> Add a Kconfig option for the maximum accessible DRAM.
>>
>> That looks fine to me, but have you checked CONFIG_MAX_MEM_MAPPED?
>> get_effective_memsize() in common/memsize.c looks like it's solving
>> this
>> very problem.
get_effective_memsize() restricts memory size from gd->ram_size.
gd->ram_size
is defined as phys_size_t, which should be 32-bit on Allwinner SoCs
except
A80. (Although currently CONFIG_ARM64 selects CONFIG_PHYS_64BIT which
makes phys_size_t 64-bit, the high 32-bit doesn't physically exist on
those SoCs, and it's possible for a 32-bit SoC with 3GiB DRAM space to
appear).
A 32-bit data type cannot store a size of 4GiB. This is the first reason
that I doesn't rely on get_effective_memsize().
>>
>>> For A80 it should be a much higher value (8GiB), but as I have no A80
>>> device to test and originally U-Boot only supports 2GiB DRAM on A80,
>>> it
>>> currently still falls under the 2GiB situation.
>>
>> Well, that depends on how we will use SUNXI_DRAM_SIZE. If that's to
>> limit the size we eventually report in the DT, that should be indeed
>> 8GB
>> on the A80. But U-Boot itself can't use more than 3GB on sunxi/ARMv7
>> (due to the static 1:1 mapping).
>> I think we should separate those two numbers (actual DRAM size and
>> U-Boot's own DRAM size), if we really want to support >3GB on the A80.
Yes, and the CONFIG_MAX_MEM_MAPPED should be used in A80 case, and the
CONFIG_PHYS_64BIT option should be selected, as the internal bus of A80
is bigger than 4GiB.
So that the meaning of CONFIG_MAX_MEM_MAPPED is "maximum memory mapped
in U-Boot", in A80 case only 3.5G is mapped in U-Boot, but Linux can
use the other 4.5G.
(In this case another U-Boot stage code that doesn't scan DRAM size but
calculate it from memory controller is needed.)
In A64/H5/H6 case the whole 3G accessible memory is mapped to U-Boot,
and there's no memory that U-Boot cannot access but some other software
can. So the gd->ram_size should be restricted at 3GiB. (The 1GiB is
installed to the system, but it's not part of the system memory due to
it's totally not accessible.)
>>
>> But maybe we should not get carried away by something that doesn't
>> really exist.
>
> That was the first thing that popped up in my mind after seeing this
> series. A80 supports LPAE. However, the A80 is out of production, and
> no one produced any boards with more than 2GB of RAM. So >3GB on
> sunxi is going to go untested for a long time, if not forever.
>
> ChenYu
>
>>
>> Thanks,
>> Andre.
>>
>>>
>>> Signed-off-by: Icenowy Zheng <icenowy at aosc.io>
>>> ---
>>> arch/arm/mach-sunxi/Kconfig | 7 +++++++
>>> 1 file changed, 7 insertions(+)
>>>
>>> diff --git a/arch/arm/mach-sunxi/Kconfig
>>> b/arch/arm/mach-sunxi/Kconfig
>>> index 1fededd0a3..32739e0f33 100644
>>> --- a/arch/arm/mach-sunxi/Kconfig
>>> +++ b/arch/arm/mach-sunxi/Kconfig
>>> @@ -63,6 +63,13 @@ config MACH_SUNXI_H3_H5
>>> select SUNXI_GEN_SUN6I
>>> select SUPPORT_SPL
>>>
>>> +# TODO: try out A80's 8GiB DRAM space
>>> +config SUNXI_DRAM_MAX_SIZE
>>> + hex
>>> + default 0xC0000000 if MACH_SUN50I
>>> + default 0xC0000000 if MACH_SUN50I_H5
>>> + default 0x80000000
>>> +
>>> choice
>>> prompt "Sunxi SoC Variant"
>>> optional
>>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "linux-sunxi" group.
>> To unsubscribe from this group and stop receiving emails from it, send
>> an email to linux-sunxi+unsubscribe at googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
More information about the U-Boot
mailing list