soc/mediatek/common/emi: Cache SDRAM size
Optimize the `sdram_size` function by caching the calculated SDRAM size in a static variable. This prevents redundant calls to `mtk_dram_size()` or `mem_chip_info_total_density_bytes()` if the size has already been determined, improving performance in scenarios where `sdram_size` is called multiple times. BUG=none TEST=emerege-tanjiro coreboot Change-Id: I0ca0df80ee9cb781a5bb6d55ee28a2c1153be0ad Signed-off-by: Yidi Lin <yidilin@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/90485 Reviewed-by: Yu-Ping Wu <yupingso@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
This commit is contained in:
parent
9203cc827f
commit
1e8cea55a0
1 changed files with 4 additions and 1 deletions
|
|
@ -8,7 +8,10 @@
|
|||
size_t sdram_size(void)
|
||||
{
|
||||
const struct mem_chip_info *mc;
|
||||
size_t size = 0;
|
||||
static size_t size = 0;
|
||||
|
||||
if (size)
|
||||
return size;
|
||||
|
||||
if (ENV_RAMINIT) {
|
||||
size = mtk_dram_size();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue