[PATCH] imx8m,imx9: Fix DRAM size calculation in SPL/dram_init_banksize()

Marek Vasut marex at denx.de
Mon Aug 7 17:58:32 CEST 2023


On 8/7/23 12:56, Elena Popa wrote:

Subject tags should be (per git log arch/arm/mach-imx/imx8m/soc.c):

arm: imx: imx8m: imx9: Fix DRAM .....

> If dram_init_banksize() is called from SPL, the rom_pointer, at that
> point, is not correctly initialized. This causes wrong calculation of
> DRAM start and size in dram_init_banksize(). The issue became apparent
> only in Falcon Mode. Added an extra condition to prevent using
> rom_pointer in SPL.

+CC Stefano, Fabio, Peng.

> Signed-off-by: Elena Popa <elena.popa at nxp.com>
> ---
>   arch/arm/mach-imx/imx8m/soc.c | 2 +-
>   arch/arm/mach-imx/imx9/soc.c  | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
> index d5254886be..dbb2154b08 100644
> --- a/arch/arm/mach-imx/imx8m/soc.c
> +++ b/arch/arm/mach-imx/imx8m/soc.c
> @@ -273,7 +273,7 @@ int dram_init_banksize(void)
>   	}
>   
>   	gd->bd->bi_dram[bank].start = PHYS_SDRAM;
> -	if (!IS_ENABLED(CONFIG_ARMV8_PSCI) && rom_pointer[1]) {
> +	if (!IS_ENABLED(CONFIG_ARMV8_PSCI) && !IS_ENABLED(CONFIG_SPL_BUILD) && rom_pointer[1]) {

Use ./scripts/checkpatch.pl , it should indicate line too long here.

There seem to be other places which likely also need similar fix:

$ git grep CONFIG_ARMV8_PSCI.*rom_pointer arch/arm/mach-imx/
arch/arm/mach-imx/imx8m/soc.c:  if (!IS_ENABLED(CONFIG_ARMV8_PSCI) && 
rom_pointer[1])
arch/arm/mach-imx/imx8m/soc.c:  if (!IS_ENABLED(CONFIG_ARMV8_PSCI) && 
rom_pointer[1]) {
arch/arm/mach-imx/imx8m/soc.c:          if 
(!IS_ENABLED(CONFIG_ARMV8_PSCI) && rom_pointer[1]) {
arch/arm/mach-imx/imx8m/soc.c:  if (!IS_ENABLED(CONFIG_ARMV8_PSCI) && 
rom_pointer[0] &&

>   		phys_addr_t optee_start = (phys_addr_t)rom_pointer[0];
>   		phys_size_t optee_size = (size_t)rom_pointer[1];
>   
> diff --git a/arch/arm/mach-imx/imx9/soc.c b/arch/arm/mach-imx/imx9/soc.c
> index f43b73a6c2..ca91f20fe7 100644
> --- a/arch/arm/mach-imx/imx9/soc.c
> +++ b/arch/arm/mach-imx/imx9/soc.c
> @@ -390,7 +390,7 @@ int dram_init_banksize(void)
>   	}
>   
>   	gd->bd->bi_dram[bank].start = PHYS_SDRAM;
> -	if (rom_pointer[1]) {
> +	if (!IS_ENABLED(CONFIG_SPL_BUILD) && rom_pointer[1]) {
>   		phys_addr_t optee_start = (phys_addr_t)rom_pointer[0];
>   		phys_size_t optee_size = (size_t)rom_pointer[1];

[...]


More information about the U-Boot mailing list