From 2ab908bcf2c7ad31a051cbdc47b346aa92aba0e5 Mon Sep 17 00:00:00 2001 From: Tim Lin Date: Mon, 1 Jul 2024 17:24:34 +0800 Subject: [PATCH] soc: it8xxx2: linker: Move kernel library to RAM to enhance performance Place kernel library in ILM. This can improve performance. test: Print the message 10000 times with 1ms sleep interval to compare the time difference before and after adding RAM code on the it82002bw evb. RAM code size save time original: 1954 bytes libkernel.a: +8941 bytes -649ms Signed-off-by: Tim Lin --- soc/ite/ec/it8xxx2/Kconfig | 7 +++++++ soc/ite/ec/it8xxx2/linker.ld | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/soc/ite/ec/it8xxx2/Kconfig b/soc/ite/ec/it8xxx2/Kconfig index 2dfe2d5afc9..6ddf099d026 100644 --- a/soc/ite/ec/it8xxx2/Kconfig +++ b/soc/ite/ec/it8xxx2/Kconfig @@ -197,6 +197,13 @@ config SOC_IT8XXX2_SERIAL_IN_RAM Place serial handling (Include uart_ns16550.c and uart_ite_it8xxx2.c) code in ILM. This can improve performance. +config SOC_IT8XXX2_KERNEL_IN_RAM + bool "Place kernel handling code in RAM" + select SOC_IT8XXX2_USE_ILM + select SOC_IT8XXX2_LIBRARY_TO_RAM + help + Place kernel handling code in ILM. This can significantly improve performance. + config SOC_IT8XXX2_SHA256_HW_ACCELERATE bool "HW SHA256 calculation" help diff --git a/soc/ite/ec/it8xxx2/linker.ld b/soc/ite/ec/it8xxx2/linker.ld index 0c4e3d483dd..6f1577a7930 100644 --- a/soc/ite/ec/it8xxx2/linker.ld +++ b/soc/ite/ec/it8xxx2/linker.ld @@ -176,6 +176,9 @@ SECTIONS #ifdef CONFIG_SOC_IT8XXX2_SERIAL_IN_RAM *libdrivers__serial.a:* #endif +#ifdef CONFIG_SOC_IT8XXX2_KERNEL_IN_RAM + *libkernel.a:* +#endif #ifdef CONFIG_SOC_IT8XXX2_LIBRARY_TO_RAM ) .text @@ -188,6 +191,9 @@ SECTIONS #ifdef CONFIG_SOC_IT8XXX2_SERIAL_IN_RAM *libdrivers__serial.a:* #endif +#ifdef CONFIG_SOC_IT8XXX2_KERNEL_IN_RAM + *libkernel.a:* +#endif #ifdef CONFIG_SOC_IT8XXX2_LIBRARY_TO_RAM ) .text.* @@ -219,6 +225,11 @@ SECTIONS *libdrivers__serial.a:*(.text .text.*) *libdrivers__serial.a:*(.rodata .rodata.*) *libdrivers__serial.a:*(.srodata .srodata.*) +#endif +#ifdef CONFIG_SOC_IT8XXX2_KERNEL_IN_RAM + *libkernel.a:*(.text .text.*) + *libkernel.a:*(.rodata .rodata.*) + *libkernel.a:*(.srodata .srodata.*) #endif __ilm_flash_end = .; /* ILM mapping is always a multiple of 4k size; ensure following