Arthur Heymans has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36145 )
Change subject: arch/arm: Pass cbmem_top to ramstage via calling argument ......................................................................
Patch Set 4:
Patch Set 2:
(1 comment)
Hmmm... in general I agree it would be good to do something here, since this is a problem that annoys us a lot on Arm platforms (have to figure out a new way to pass this stuff for every new SoC). But just passing cbmem_top() wouldn't really solve it, because we still need to know the full DRAM size to write the correct memory tables (with ram_resource()). We can calculate cbmem_top() easily when we know the size of DRAM (it's essentially MIN(4GB, _dram + dram_size)), but not the other way round.
Would it make more sense to instead pass the size of DRAM as an argument?
One could call the dram size on x86 the current thing that cbmem_top returns and pass that as argument. However the 4G max rule does not seem to be applied on all SOC, so you can't implement cbmem_top based on total dram size alone in a platform independent way.
I'm in the process of writing some common code to make passing information from rom- to ram-stage more easy. If one needs to pass on total dram without recomputing it would boil down to:
save_romstage_info(&total_dram, sizeof(total)) and get_romstage_info(&total_dram).
which with my current implementation works regardless of whether cbmem is already initialized or not.