Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/79990?usp=email )
Change subject: soc/mediatek: Add EARLY_MMU_INIT kconfig option ......................................................................
soc/mediatek: Add EARLY_MMU_INIT kconfig option
Accessing RAM before mmu initialized is time consuming. During mmu initialization, `mmu_init()` and `mmu_config_range()` write logs to the console buffer and contribue the extra boot time.
This patch adds a kconfig option to move `mtk_mmu_init()` to `bootblock_soc_early_init()`. When `EARLY_MMU_INIT` is enabled, mmu is initialized before `console_init()` ready. So `mmu_init()` and `mmu_config_range()` won't write logs to the console buffer and save the boot time.
It saves about 65ms on Geralt with EARLY_MMU_INIT enabled.
Before: 0:1st timestamp 239,841 (0) 11:start of bootblock 239,920 (79) 12:end of bootblock 323,191 (83,271)
After: 0:1st timestamp 239,804 (0) 11:start of bootblock 239,884 (80) 12:end of bootblock 258,846 (18,962)
BUG=b:320381143 TEST=check timestamps in cbmem
Change-Id: I7f4c3c6c836f7276119698c6de362794cf4222a6 Signed-off-by: Yidi Lin yidilin@chromium.org Reviewed-on: https://review.coreboot.org/c/coreboot/+/79990 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Yu-Ping Wu yupingso@google.com --- M src/soc/mediatek/common/Kconfig A src/soc/mediatek/common/bootblock.c M src/soc/mediatek/common/mmu_operations.c M src/soc/mediatek/mt8188/Makefile.inc 4 files changed, 25 insertions(+), 1 deletion(-)
Approvals: build bot (Jenkins): Verified Yu-Ping Wu: Looks good to me, approved
diff --git a/src/soc/mediatek/common/Kconfig b/src/soc/mediatek/common/Kconfig index 8092aa7..268f2f3 100644 --- a/src/soc/mediatek/common/Kconfig +++ b/src/soc/mediatek/common/Kconfig @@ -91,4 +91,11 @@ When this option is enabled, the DEVAPC driver prints the settings after initialization.
+config EARLY_MMU_INIT + bool + default n + help + When this option is enabled, `mtk_mmu_init()` will be done in + `bootblock_soc_early_init()` to reduce the boot time. + endif diff --git a/src/soc/mediatek/common/bootblock.c b/src/soc/mediatek/common/bootblock.c new file mode 100644 index 0000000..6474a8f --- /dev/null +++ b/src/soc/mediatek/common/bootblock.c @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <bootblock_common.h> +#include <soc/mmu_operations.h> + +void bootblock_soc_early_init(void) +{ + if (CONFIG(EARLY_MMU_INIT)) + mtk_mmu_init(); +} diff --git a/src/soc/mediatek/common/mmu_operations.c b/src/soc/mediatek/common/mmu_operations.c index 340f9ec..cbd6c09 100644 --- a/src/soc/mediatek/common/mmu_operations.c +++ b/src/soc/mediatek/common/mmu_operations.c @@ -9,6 +9,13 @@
void mtk_mmu_init(void) { + static bool mmu_inited; + + if (mmu_inited) + return; + + mmu_inited = true; + mmu_init();
/* diff --git a/src/soc/mediatek/mt8188/Makefile.inc b/src/soc/mediatek/mt8188/Makefile.inc index 4731fab..14f7d38 100644 --- a/src/soc/mediatek/mt8188/Makefile.inc +++ b/src/soc/mediatek/mt8188/Makefile.inc @@ -9,7 +9,7 @@ all-y += timer.c ../common/timer_prepare.c all-y += ../common/uart.c
-bootblock-y += bootblock.c +bootblock-y += ../common/bootblock.c bootblock.c bootblock-y += ../common/eint_event.c bootblock-y += ../common/lastbus_v2.c lastbus.c bootblock-y += ../common/mmu_operations.c