[PATCH 0/2] sunxi: H616: Add LPDDR3 DRAM type

Andre Przywara andre.przywara at arm.com
Mon Jun 5 16:15:59 CEST 2023


On Sat,  3 Jun 2023 16:55:04 +0300
Mikhail Kalashnikov <iuncuim at gmail.com> wrote:

Hi Mikhail,

> From: iuncuim <iuncuim at gmail.com>
> 
> At the moment, the driver only supports DDR3 memory.
> Add support for a new type DRAM. 
> These changes have been successfully tested by me 
> with tvbox tra###eed t98-h2b-lp3.

Ah, many thanks for sending this! This looks very good, in general.
There is one newline issue introduced in patch 1, which gets fixed in
patch 2, but that's just a small thing.

There is one bigger problem, though:
The code size grows by a bit, when compiling for the OrangePi Zero2:
$ size spl/arch/arm/mach-sunxi/dram_sun50i_h616.o
   text    data     bss     dec     hex filename
   7463       0       0    7463    1d27 dram_sun50i_h616_before.o
   8155       0       0    8155    1fdb dram_sun50i_h616_after.o

This is somewhat surprising, given that the DRAM type is known at compile
time, so the compiler wouldn't need to include the other case in the binary.

Looking a bit closer at the disassembly, I saw that the constant
propagation isn't really working as we would hope for. I suspect it's due
to struct dram_para having both fixed, but also dynamic members, so the
compiler avoids optimising this further.
Just marking the fixed members as "const" in the struct declaration didn't
change anything, unfortunately, again I believe the constant propagation
is conservative here.
I then went ahead and split struct dram_para up into two structures: one
which is always constant, and one dynamic, with just cols, rows, banks, and
full_bus_width in it. Then putting "const" into the right places in the
function prototypes *and* moving the struct dram_para definition outside
of the sunxi_dram_init() function, resulted in quite a drop in code size:
for current mainline (without your patches) the size of the DRAM driver
goes down from the above mentioned 7463 bytes to 5723 bytes. Adding your
patches on top then didn't change the size at all, as expected.

So I will send out those changes soonish, and will put your rebased
patches on top.

Cheers,
Andre

> iuncuim (2):
>   sunxi: H616: add DRAM type selection
>   sunxi: H616: add LPDDR3 DRAM support
> 
>  .../include/asm/arch-sunxi/dram_sun50i_h616.h |   1 +
>  arch/arm/mach-sunxi/Kconfig                   |  18 +-
>  arch/arm/mach-sunxi/dram_sun50i_h616.c        | 215 ++++++++++++------
>  arch/arm/mach-sunxi/dram_timings/Makefile     |   4 +-
>  .../arm/mach-sunxi/dram_timings/h616_lpddr3.c |  95 ++++++++
>  configs/orangepi_zero2_defconfig              |   1 +
>  configs/x96_mate_defconfig                    |   1 +
>  7 files changed, 266 insertions(+), 69 deletions(-)
>  create mode 100644 arch/arm/mach-sunxi/dram_timings/h616_lpddr3.c
> 



More information about the U-Boot mailing list