mach-k3: common: init gd->bd before dram_init_banksize
Subsystems (2)
PATCH 1/1 mach-k3: common: init gd->bd before dram_init_banksize
The dram_init_banksize API configures the dram banks inside gd->bd, so ensure bd is initialized by calling spl_set_bd as part of spl_enable_cache.
--- arch/arm/mach-k3/common.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/mach-k3/common.c +3 -0
@@ -418,6 +418,9 @@ void spl_enable_cache(void) gd->ram_top =CFG_SYS_SDRAM_BASE ;int ret =0 ; +/* dram_init_banksize populates bd, so init it first */ +spl_set_bd (); +dram_init ();dram_init_banksize ();
---
base-commit: 1e240f7206fccde4ec73ea432ab8360d321c5fe5
change-id: 20260310-init_bd_before_dram_init-7a9c3ad0b311
Best regards,
Signature · 1 line
Anshul Dalal <[email protected]>
Hi Anshul
Quoted 14 lines · Anshul Dalal
The
dram_init_banksizeAPI configures the dram banks insidegd->bd, so ensure bd is initialized by callingspl_set_bdas part ofspl_enable_cache.Signed-off-by Anshul Dalal <[email protected]>--- arch/arm/mach-k3/common.c | 3 +++ 1 file changed, 3 insertions(+)arch/arm/mach-k3/common.c +0
-0
arch/arm/mach-k3/common.c void spl_enable_cache(void) · line 423
Quoted 6 lines
arch/arm/mach-k3/common.c +3
-0@@ -418,6 +418,9 @@ void spl_enable_cache(void) gd->ram_top =CFG_SYS_SDRAM_BASE ;int ret =0 ; +/* dram_init_banksize populates bd, so init it first */ +spl_set_bd (); +
I think we really need to evaluate where all we are calling dram_init_banksize, else we keep finding related debugs confusing [0]
We have to stick as closely as possible to the common SPL flow: board_init_r --> spl_set_bd .. dram_init_banksize
Problem is we need dram_init_banksize calls even before relocation because of spl_enable_cache. For my knowledge, do we have a specific reason why we are calling spl_enable_cache before relocation? I am guessing some MMU setup happening before we relocate partly to DDR as being the reason?
I think it's better you move calling spl_set_bd() up a level into board_init_f for now (similar to what arch/arm/cpu/armv8/fsl-layerscape/spl.c does). We should be calling this before we call dram_init (or in our case k3_mem_init) so that we are sure it is setup prior to any dram_init_banksize calls.
Quoted 9 lines
arch/arm/mach-k3/common.c +0
-1dram_init ();dram_init_banksize (); ---base-commit:
1e240f7206fccde4ec73ea432ab8360d321c5fe5
change-id: 20260310-init_bd_before_dram_init-7a9c3ad0b311Best regards,
[0] https://lore.kernel.org/u-boot/[email protected]/
Signature · 2 lines
Thanking You Neha Malcom Francis
Quoted 27 lines · Neha Francis
Hi Anshul
Quoted 14 lines · Anshul Dalal
The
dram_init_banksizeAPI configures the dram banks insidegd->bd, so ensure bd is initialized by callingspl_set_bdas part ofspl_enable_cache.Signed-off-by Anshul Dalal <[email protected]>--- arch/arm/mach-k3/common.c | 3 +++ 1 file changed, 3 insertions(+)arch/arm/mach-k3/common.c +0
-0arch/arm/mach-k3/common.c void spl_enable_cache(void) · line 423
Quoted 6 lines
arch/arm/mach-k3/common.c +3
-0@@ -418,6 +418,9 @@ void spl_enable_cache(void) gd->ram_top =CFG_SYS_SDRAM_BASE ;int ret =0 ; +/* dram_init_banksize populates bd, so init it first */ +spl_set_bd (); +I think we really need to evaluate where all we are calling
dram_init_banksize, else we keep finding related debugs confusing [0]
Quoted 2 lines
We have to stick as closely as possible to the common SPL flow:
board_init_r-->spl_set_bd..dram_init_banksize
spl_set_bd should not re-init bd if it has been initialized already so the second call to spl_set_bd as part of board_init_r shouldn't effect anything.
Quoted 6 lines
Problem is we need
dram_init_banksizecalls even before relocation because ofspl_enable_cache. For my knowledge, do we have a specific reason why we are callingspl_enable_cachebefore relocation? I am guessing some MMU setup happening before we relocate partly to DDR as being the reason?
SPL does not relocate to my knowledge, we largely need spl_enable_cache to speed up boot especially in A-Core falcon mode where the large kernel image needs to be authenticated and uncompressed by the SPL.
Quoted 2 lines
I think it's better you move calling
spl_set_bd()up a level intoboard_init_ffor now (similar to whatarch/arm/cpu/armv8/fsl-layerscape/spl.cdoes). We
We could do that too but it'd have to be change in every SoC's init file and the dependency between spl_set_bd and dram_init_banksize would not be enforced (i.e someone can call spl_enable_cache while not calling spl_set_bd first).
Quoted 15 lines
should be calling this before we call
dram_init(or in our casek3_mem_init) so that we are sure it is setup prior to anydram_init_banksizecalls.Quoted 9 lines
arch/arm/mach-k3/common.c +0
-1dram_init ();dram_init_banksize (); ---base-commit:
1e240f7206fccde4ec73ea432ab8360d321c5fe5
change-id: 20260310-init_bd_before_dram_init-7a9c3ad0b311Best regards,
A message that is not in the archive (sent off-list or not yet received): [email protected]
Thanks for ropping me in Anshul
Quoted 6 lines · Anshul Dalal
Quoted 4 lines · Anshul Dalal
The
dram_init_banksizeAPI configures the dram banks insidegd->bd, so ensure bd is initialized by callingspl_set_bdas part ofspl_enable_cache.
Quoted 7 lines
Quoted 1 line
Signed-off-by Anshul Dalal <[email protected]>This patch can be dropped in favour of "treewide: move bi_dram[] from bd to gd"[1]. The patch fixes the issue since
dram_init_banksizeonly modifiesbi_dramfield of bd which now gets moved to gd.
Yes please.
/Ilias
Quoted 28 lines
CC + IliasQuoted 24 lines
--- arch/arm/mach-k3/common.c | 3 +++ 1 file changed, 3 insertions(+)arch/arm/mach-k3/common.c +3
-1@@ -418,6 +418,9 @@ void spl_enable_cache(void) gd->ram_top =CFG_SYS_SDRAM_BASE ;int ret =0 ; +/* dram_init_banksize populates bd, so init it first */ +spl_set_bd (); +dram_init ();dram_init_banksize (); ---base-commit:
1e240f7206fccde4ec73ea432ab8360d321c5fe5
change-id: 20260310-init_bd_before_dram_init-7a9c3ad0b311Best regards,