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

Jernej Škrabec jernej.skrabec at gmail.com
Fri Jun 9 22:26:21 CEST 2023


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.

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

Best regards,
Jernej




More information about the U-Boot mailing list