[PATCH 3/5] sunxi: H616: dram: split struct dram_para

Andre Przywara andre.przywara at arm.com
Sat Jun 10 00:48:23 CEST 2023


On Fri, 09 Jun 2023 22:26:21 +0200
Jernej Škrabec <jernej.skrabec at gmail.com> wrote:

Hi,

> Dne sreda, 07. junij 2023 ob 02:07:43 CEST je Andre Przywara napisal(a):
> > Currently there is one DRAM parameter struct for the Allwinner H616 DRAM
> > "driver". It contains many fields that are compile time constants
> > (set by Kconfig variables), though there are also some fields that are
> > probed and changed over the runtime of the DRAM initialisation.
> > 
> > Because of this mixture, the compiler cannot properly optimise the code
> > for size, as it does not consider constant propagation in its full
> > potential.
> > 
> > Help the compiler out by splitting that structure into two: one that only
> > contains values known at compile time, and another one where the values
> > will actually change. The former can then be declared "const", which will
> > let the compiler fold its values directly into the code using it.
> > 
> > We also add "const" tags for some new "struct dram_config" pointers, to
> > further increase code optimisation.
> > To help the compiler optimise the code further, the definition of the
> > now "const struct dram_para" has to happen at a file-global level, so
> > move that part out of sunxi_dram_init().
> > 
> > That results in quite some code savings (almost 2KB), and helps to keep
> > the code small with the LPDDR3 support added later.
> > 
> > Signed-off-by: Andre Przywara <andre.przywara at arm.com>  
> 
> Nice trick. It could be used also in other DRAM drivers.

You bet ;-)

I have a patch for the H6 already. It doesn't save as much there
(merely 500 bytes), I guess because we don't have as many build time
parameters, but the H6 SPL is very big, so every byte saved there is a
win. Will post this ASAP.

> Reviewed-by: Jernej Skrabec <jernej.skrabec at gmail.com>

Many thanks for that!

Cheers,
Andre


More information about the U-Boot mailing list