All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] arm: mediatek: run SPL and pre-relocation U-Boot with caches
@ 2026-11-20 16:29 Steffen Dirkwinkel
  2026-11-20 16:29 ` [PATCH v3 1/2] arm: mediatek: enable the caches in SPL Steffen Dirkwinkel
  2026-11-20 16:29 ` [PATCH v3 2/2] arm: mediatek: run board_init_f() with the caches on Steffen Dirkwinkel
  0 siblings, 2 replies; 5+ messages in thread
From: Steffen Dirkwinkel @ 2026-11-20 16:29 UTC (permalink / raw)
  To: GSS_MTK_Uboot_upstream, u-boot
  Cc: Tom Rini, Ilias Apalodimas, Ryder Lee, Weijie Gao, Chunfeng Yun,
	Igor Belwon, David Lechner, Julien Stephan, Steffen Dirkwinkel,
	Carlo Caione, Chris Chen, Julien Masson, Johan Jonker

Running u-boot without caches is slow, especially if using rsa
signatures. This series turns the caches in u-boot spl and proper on
early.

Measured on an MT8370 module (Beckhoff SM0101, not upstream yet) with TF-A
BL2 as DDR loader and SPL loading a 2.7 MB FIT (BL31, OP-TEE, U-Boot,
SHA-256 hashes) from SPI NOR:

SPL, from its banner and from selecting the FIT to the first BL31
output:

  caches   signature   SPL total              FIT -> BL31
  off      -           848.3 / 848.6 ms       792.3 / 793.1 ms
  on       -           95.7 / 118.8 ms        95.7 / 118.8 ms
  off      RSA-3072    1903.6 / 1903.0 ms     1836.7 / 1837.2 ms
  on       RSA-3072    128.3 / 143.3 ms       128.3 / 143.3 ms

U-Boot proper, from bootstage marks before each initcall:

  initcall          caches off       caches on
  initf_dm          349.8 / 349.7    4.6 / 4.6 ms
  serial_init       204.7 / 204.7    3.0 / 3.0 ms
  dram_init         162.2 / 162.1    2.3 / 2.3 ms
  relocation copy    22.0 / 22.0     0.4 / 0.4 ms
  board_init_f() to main_loop()
                    819 / 819        87 / 87 ms

Autoboot prompt after power-on, which includes a 5 s USB download wait
in the BootROM:

                    unsigned FIT            RSA-3072 signed FIT
  without series    8369 / 8373 ms          9447 / 9437 ms
  patch 1           7634 / 7633 ms          7659 / 7658 ms
  both patches      6901 / 6903 ms          6933 / 6932 ms

The module tests used a v2026.10 based tree with the Genio SPL support
cherry picked.

The early page tables (32K) are at a fixed address, MTK_EARLY_TLB_ADDR,
instead of in a static array. On MT8188 the default is 0x401f8000, the
last 32K of the first 2 MiB of DRAM, as David suggested.

I used an LLM to help write and test the patches.

---
Changes in v3:
- Add MTK_EARLY_CACHES and SPL_MTK_EARLY_CACHES, enabled by default
  only on MT8188
- Use GPL-2.0-only
- Explain the early page table size
- Explain the I-cache handling around cleanup_before_linux()
- Put the early page tables at MTK_EARLY_TLB_ADDR instead of into a
  static array, so we don't increase binary size
- Link to v2: https://patch.msgid.link/20261109-std-upstream-mt8188-spl-caches-v2-0-78cfb3e90c55@beckhoff.com

Changes in v2:
- Make it generic for MediaTek ARM64 instead of MT8188 specific
- Put the early page tables into a static allocation
- Enable the I-cache in SPL as well
- Turn the MMU and the caches off with cleanup_before_linux() before
  leaving SPL
- Use if (IS_ENABLED()) instead of #if
- Link to v1: https://patch.msgid.link/20261030-std-upstream-mt8188-spl-caches-v1-0-b45905cb19c1@beckhoff.com

To: GSS_MTK_Uboot_upstream <GSS_MTK_Uboot_upstream@mediatek.com>
To: u-boot@lists.u-boot-project.org
Cc: Tom Rini <trini@konsulko.com>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Ryder Lee <ryder.lee@mediatek.com>
Cc: Weijie Gao <weijie.gao@mediatek.com>
Cc: Chunfeng Yun <chunfeng.yun@mediatek.com>
Cc: Igor Belwon <igor.belwon@mentallysanemainliners.org>
Cc: David Lechner <dlechner@baylibre.com>
Cc: Julien Stephan <jstephan@baylibre.com>
Cc: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Cc: Carlo Caione <ccaione@baylibre.com>
Cc: Julien Masson <jmasson@baylibre.com>
Cc: Johan Jonker <jbx6244@gmail.com>
Cc: Chris Chen <chris-qj.chen@mediatek.com>

---
Steffen Dirkwinkel (2):
      arm: mediatek: enable the caches in SPL
      arm: mediatek: run board_init_f() with the caches on

 arch/arm/include/asm/arch-mediatek/misc.h |  3 +++
 arch/arm/mach-mediatek/Kconfig            | 25 +++++++++++++++++++++++++
 arch/arm/mach-mediatek/Makefile           |  1 +
 arch/arm/mach-mediatek/cpu.c              |  6 ++++++
 arch/arm/mach-mediatek/early_caches.c     | 31 +++++++++++++++++++++++++++++++
 arch/arm/mach-mediatek/spl.c              | 14 ++++++++++++++
 6 files changed, 80 insertions(+)
---
base-commit: 810d7132c6f03430588ff45dacf62e62f3906598
change-id: 20261027-std-upstream-mt8188-spl-caches-2f4271625329

Best regards,
--  
Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/2] arm: mediatek: enable the caches in SPL
  2026-11-20 16:29 [PATCH v3 0/2] arm: mediatek: run SPL and pre-relocation U-Boot with caches Steffen Dirkwinkel
@ 2026-11-20 16:29 ` Steffen Dirkwinkel
  2026-11-21 16:29   ` Carlo Caione
  2026-11-20 16:29 ` [PATCH v3 2/2] arm: mediatek: run board_init_f() with the caches on Steffen Dirkwinkel
  1 sibling, 1 reply; 5+ messages in thread
From: Steffen Dirkwinkel @ 2026-11-20 16:29 UTC (permalink / raw)
  To: GSS_MTK_Uboot_upstream, u-boot
  Cc: Tom Rini, Ilias Apalodimas, Ryder Lee, Weijie Gao, Chunfeng Yun,
	Igor Belwon, David Lechner, Julien Stephan, Steffen Dirkwinkel,
	Carlo Caione, Chris Chen, Julien Masson, Johan Jonker

From: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>

Running through spl without the dcache is very slow, especially when
hashing or checking signatures.

Time from the SPL banner to entering BL31 on an MT8370 module loading a
2.7 MB FIT with SHA-256 hashes from SPI NOR, two boots each:

  FIT                    caches off            caches on
  unsigned               848.3 / 848.6 ms      95.7 / 118.8 ms
  RSA-3072 signature     1903.6 / 1903.0 ms    128.3 / 143.3 ms

EARLY_TLB_SIZE is 32K, the largest get_page_table_size() of all
MediaTek mem maps.

The page tables are at MTK_EARLY_TLB_ADDR. On MT8188 the default is the
last 32K of the first 2 MiB of DRAM. This is above the SPL image, BSS
and stack, which end at 0x4013b800, and below the download agent FIT at
0x41000000.

U-Boot on ARMv8 can't run with the I-cache on and the D-cache off: with
SPL_SYS_DCACHE_OFF the cache functions aren't built at all and with
SPL_SYS_ICACHE_OFF the I-cache functions are empty. So calling
cleanup_before_linux() only with SPL_MTK_EARLY_CACHES is fine.
rockchip spl.c does the same.

Signed-off-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
---
 arch/arm/include/asm/arch-mediatek/misc.h |  2 ++
 arch/arm/mach-mediatek/Kconfig            | 17 +++++++++++++++++
 arch/arm/mach-mediatek/Makefile           |  1 +
 arch/arm/mach-mediatek/early_caches.c     | 21 +++++++++++++++++++++
 arch/arm/mach-mediatek/spl.c              | 14 ++++++++++++++
 5 files changed, 55 insertions(+)

diff --git a/arch/arm/include/asm/arch-mediatek/misc.h b/arch/arm/include/asm/arch-mediatek/misc.h
index 2530e78a5f11..dd248d222b97 100644
--- a/arch/arm/include/asm/arch-mediatek/misc.h
+++ b/arch/arm/include/asm/arch-mediatek/misc.h
@@ -14,4 +14,6 @@
 #define APHW_VER		0x08
 #define APSW_VER		0x0c
 
+void mtk_early_enable_caches(void);
+
 #endif /* __MEDIATEK_MISC_H_ */
diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
index cdbcb6b3bc18..9e36b2a2c82d 100644
--- a/arch/arm/mach-mediatek/Kconfig
+++ b/arch/arm/mach-mediatek/Kconfig
@@ -221,6 +221,23 @@ config MTK_BROM_HEADER_INFO
 	default "media=emmc" if TARGET_MT8516 || TARGET_MT8365 || TARGET_MT8366 || TARGET_MT8183 || TARGET_MT8189 || TARGET_MT8195
 	default "lk=1" if TARGET_MT7623
 
+config SPL_MTK_EARLY_CACHES
+	bool "Enable caches in SPL"
+	depends on SPL && ARM64 && !SPL_SYS_DCACHE_OFF
+	default y if TARGET_MT8188
+	help
+	  Enable the MMU and caches in SPL and disable them before
+	  jumping to the next stage.
+
+config MTK_EARLY_TLB_ADDR
+	hex "Address of the early page tables"
+	depends on SPL_MTK_EARLY_CACHES
+	default 0x401f8000 if TARGET_MT8188
+	help
+	  Address of the 32 KiB of page tables used while the early
+	  caches are on. Nothing else may use this memory during that
+	  time.
+
 config SPL_MTK_FIRMWARE_AB
 	bool "MediaTek firmware A/B boot in SPL"
 	depends on TARGET_MT8188 && SPL_MMC && SPL_LOAD_FIT && SPL_BLK
diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile
index 4b1524e5e2f1..55bf8790cc92 100644
--- a/arch/arm/mach-mediatek/Makefile
+++ b/arch/arm/mach-mediatek/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_MTK_TZ_MOVABLE)	+= tzcfg.o
 obj-$(CONFIG_XPL_BUILD)	+= spl.o
 obj-$(CONFIG_$(PHASE_)MTK_FIRMWARE_AB) += spl_ab.o mtk_ab.o
 obj-$(CONFIG_$(PHASE_)MTK_BROM_DOWNLOAD_AGENT_FASTBOOT) += download_agent.o
+obj-$(CONFIG_$(PHASE_)MTK_EARLY_CACHES) += early_caches.o
 
 obj-$(CONFIG_TARGET_MT7622) += mt7622/
 obj-$(CONFIG_TARGET_MT7623) += mt7623/
diff --git a/arch/arm/mach-mediatek/early_caches.c b/arch/arm/mach-mediatek/early_caches.c
new file mode 100644
index 000000000000..003393d2f681
--- /dev/null
+++ b/arch/arm/mach-mediatek/early_caches.c
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * MMU and caches before U-Boot sets up its final page tables
+ */
+
+#include <cpu_func.h>
+#include <asm/global_data.h>
+#include <asm/arch/misc.h>
+#include <linux/sizes.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* get_page_table_size() for the largest MediaTek mem_map */
+#define EARLY_TLB_SIZE	SZ_32K
+
+void mtk_early_enable_caches(void)
+{
+	gd->arch.tlb_addr = CONFIG_MTK_EARLY_TLB_ADDR;
+	gd->arch.tlb_size = EARLY_TLB_SIZE;
+	dcache_enable();
+}
diff --git a/arch/arm/mach-mediatek/spl.c b/arch/arm/mach-mediatek/spl.c
index 95e2157b507d..2fe1b4e6c524 100644
--- a/arch/arm/mach-mediatek/spl.c
+++ b/arch/arm/mach-mediatek/spl.c
@@ -5,9 +5,11 @@
  */
 
 #include <clk.h>
+#include <cpu_func.h>
 #include <hang.h>
 #include <init.h>
 #include <spl.h>
+#include <asm/arch/misc.h>
 
 __weak int mtk_soc_early_init(void)
 {
@@ -18,6 +20,12 @@ void board_init_f(ulong dummy)
 {
 	int ret;
 
+	if (CONFIG_IS_ENABLED(MTK_EARLY_CACHES)) {
+		/* SPL skips arch_cpu_init(), which enables the I-cache */
+		icache_enable();
+		mtk_early_enable_caches();
+	}
+
 	ret = spl_early_init();
 	if (ret)
 		hang();
@@ -31,6 +39,12 @@ void board_init_f(ulong dummy)
 		hang();
 }
 
+void spl_board_prepare_for_boot(void)
+{
+	if (CONFIG_IS_ENABLED(MTK_EARLY_CACHES))
+		cleanup_before_linux();
+}
+
 u32 spl_boot_device(void)
 {
 	if (IS_ENABLED(CONFIG_MTK_BROM_DOWNLOAD_AGENT_FASTBOOT))

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 2/2] arm: mediatek: run board_init_f() with the caches on
  2026-11-20 16:29 [PATCH v3 0/2] arm: mediatek: run SPL and pre-relocation U-Boot with caches Steffen Dirkwinkel
  2026-11-20 16:29 ` [PATCH v3 1/2] arm: mediatek: enable the caches in SPL Steffen Dirkwinkel
@ 2026-11-20 16:29 ` Steffen Dirkwinkel
  2026-11-21 16:30   ` Carlo Caione
  1 sibling, 1 reply; 5+ messages in thread
From: Steffen Dirkwinkel @ 2026-11-20 16:29 UTC (permalink / raw)
  To: GSS_MTK_Uboot_upstream, u-boot
  Cc: Tom Rini, Ilias Apalodimas, Ryder Lee, Weijie Gao, Chunfeng Yun,
	Igor Belwon, David Lechner, Julien Stephan, Steffen Dirkwinkel,
	Carlo Caione, Chris Chen, Julien Masson, Johan Jonker

From: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>

Device tree walks and other setup is very slow without caches, so turn
them on before relocation.

On an MT8370 module, from bootstage marks before each initcall, two
boots each:

  step                            caches off        caches on
  initf_dm                        349.8 / 349.7     4.6 / 4.6 ms
  serial_init                     204.7 / 204.7     3.0 / 3.0 ms
  dram_init                       162.2 / 162.1     2.3 / 2.3 ms
  relocate_code                   22.0 / 22.0       0.4 / 0.4 ms
  board_init_f() to main_loop()   819 / 819         87 / 87 ms

and from the serial console, after power-on (includes 5s debug usb wait):

  U-Boot banner                   7336 / 7335 ms    6772 / 6775 ms

Signed-off-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
---
 arch/arm/include/asm/arch-mediatek/misc.h |  1 +
 arch/arm/mach-mediatek/Kconfig            | 10 +++++++++-
 arch/arm/mach-mediatek/cpu.c              |  6 ++++++
 arch/arm/mach-mediatek/early_caches.c     | 10 ++++++++++
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-mediatek/misc.h b/arch/arm/include/asm/arch-mediatek/misc.h
index dd248d222b97..517fbe7842ff 100644
--- a/arch/arm/include/asm/arch-mediatek/misc.h
+++ b/arch/arm/include/asm/arch-mediatek/misc.h
@@ -15,5 +15,6 @@
 #define APSW_VER		0x0c
 
 void mtk_early_enable_caches(void);
+void mtk_early_disable_caches(void);
 
 #endif /* __MEDIATEK_MISC_H_ */
diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
index 9e36b2a2c82d..a91422de95d2 100644
--- a/arch/arm/mach-mediatek/Kconfig
+++ b/arch/arm/mach-mediatek/Kconfig
@@ -221,6 +221,14 @@ config MTK_BROM_HEADER_INFO
 	default "media=emmc" if TARGET_MT8516 || TARGET_MT8365 || TARGET_MT8366 || TARGET_MT8183 || TARGET_MT8189 || TARGET_MT8195
 	default "lk=1" if TARGET_MT7623
 
+config MTK_EARLY_CACHES
+	bool "Enable caches before relocation"
+	depends on ARM64 && !SYS_DCACHE_OFF
+	default y if TARGET_MT8188
+	help
+	  Enable the MMU and caches before relocation, using temporary
+	  page tables.
+
 config SPL_MTK_EARLY_CACHES
 	bool "Enable caches in SPL"
 	depends on SPL && ARM64 && !SPL_SYS_DCACHE_OFF
@@ -231,7 +239,7 @@ config SPL_MTK_EARLY_CACHES
 
 config MTK_EARLY_TLB_ADDR
 	hex "Address of the early page tables"
-	depends on SPL_MTK_EARLY_CACHES
+	depends on MTK_EARLY_CACHES || SPL_MTK_EARLY_CACHES
 	default 0x401f8000 if TARGET_MT8188
 	help
 	  Address of the 32 KiB of page tables used while the early
diff --git a/arch/arm/mach-mediatek/cpu.c b/arch/arm/mach-mediatek/cpu.c
index 04ede8823b07..c69a46dd0284 100644
--- a/arch/arm/mach-mediatek/cpu.c
+++ b/arch/arm/mach-mediatek/cpu.c
@@ -8,6 +8,7 @@
 #include <init.h>
 #include <wdt.h>
 #include <dm/uclass-internal.h>
+#include <asm/arch/misc.h>
 #include <linux/arm-smccc.h>
 #include <linux/types.h>
 
@@ -17,12 +18,17 @@
 int arch_cpu_init(void)
 {
 	icache_enable();
+	if (CONFIG_IS_ENABLED(MTK_EARLY_CACHES))
+		mtk_early_enable_caches();
 
 	return 0;
 }
 
 void enable_caches(void)
 {
+	if (CONFIG_IS_ENABLED(MTK_EARLY_CACHES))
+		mtk_early_disable_caches();
+
 	/* Enable D-cache. I-cache is already enabled in start.S */
 	dcache_enable();
 }
diff --git a/arch/arm/mach-mediatek/early_caches.c b/arch/arm/mach-mediatek/early_caches.c
index 003393d2f681..f4489cb8ba26 100644
--- a/arch/arm/mach-mediatek/early_caches.c
+++ b/arch/arm/mach-mediatek/early_caches.c
@@ -19,3 +19,13 @@ void mtk_early_enable_caches(void)
 	gd->arch.tlb_size = EARLY_TLB_SIZE;
 	dcache_enable();
 }
+
+/*
+ * Turn the data cache off and clear tlb_fillptr, so that the next
+ * dcache_enable() sets up the page tables reserved by arch_reserve_mmu()
+ */
+void mtk_early_disable_caches(void)
+{
+	dcache_disable();
+	gd->arch.tlb_fillptr = 0;
+}

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 1/2] arm: mediatek: enable the caches in SPL
  2026-11-20 16:29 ` [PATCH v3 1/2] arm: mediatek: enable the caches in SPL Steffen Dirkwinkel
@ 2026-11-21 16:29   ` Carlo Caione
  0 siblings, 0 replies; 5+ messages in thread
From: Carlo Caione @ 2026-11-21 16:29 UTC (permalink / raw)
  To: Steffen Dirkwinkel
  Cc: GSS_MTK_Uboot_upstream, u-boot, Tom Rini, Ilias Apalodimas,
	Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, David Lechner,
	Julien Stephan, Steffen Dirkwinkel, Chris Chen, Julien Masson,
	Johan Jonker

On Fri, Nov 20, 2026 at 17:29:18 +0100, Steffen Dirkwinkel wrote:
> From: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
> 
> Running through spl without the dcache is very slow, especially when
> hashing or checking signatures.

[...]

> --- a/arch/arm/include/asm/arch-mediatek/misc.h
> +++ b/arch/arm/include/asm/arch-mediatek/misc.h
> @@ -14,4 +14,6 @@
>  #define APHW_VER		0x08
>  #define APSW_VER		0x0c
>  
> +void mtk_early_enable_caches(void);

nit: this should really be mtk_early_enable_dcache()

> +
>  #endif /* __MEDIATEK_MISC_H_ */
> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
> index cdbcb6b3bc18..9e36b2a2c82d 100644
> --- a/arch/arm/mach-mediatek/Kconfig
> +++ b/arch/arm/mach-mediatek/Kconfig
> @@ -221,6 +221,23 @@ config MTK_BROM_HEADER_INFO
>  	default "media=emmc" if TARGET_MT8516 || TARGET_MT8365 || TARGET_MT8366 || TARGET_MT8183 || TARGET_MT8189 || TARGET_MT8195
>  	default "lk=1" if TARGET_MT7623
>  
> +config SPL_MTK_EARLY_CACHES
> +	bool "Enable caches in SPL"
> +	depends on SPL && ARM64 && !SPL_SYS_DCACHE_OFF
> +	default y if TARGET_MT8188
> +	help
> +	  Enable the MMU and caches in SPL and disable them before
> +	  jumping to the next stage.

nit: same here SPL_MTK_EARLY_DCACHE

> +
> +config MTK_EARLY_TLB_ADDR
> +	hex "Address of the early page tables"
> +	depends on SPL_MTK_EARLY_CACHES
> +	default 0x401f8000 if TARGET_MT8188
> +	help
> +	  Address of the 32 KiB of page tables used while the early
> +	  caches are on. Nothing else may use this memory during that
> +	  time.
> +
>  config SPL_MTK_FIRMWARE_AB
>  	bool "MediaTek firmware A/B boot in SPL"
>  	depends on TARGET_MT8188 && SPL_MMC && SPL_LOAD_FIT && SPL_BLK
> diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile
> index 4b1524e5e2f1..55bf8790cc92 100644
> --- a/arch/arm/mach-mediatek/Makefile
> +++ b/arch/arm/mach-mediatek/Makefile
> @@ -6,6 +6,7 @@ obj-$(CONFIG_MTK_TZ_MOVABLE)	+= tzcfg.o
>  obj-$(CONFIG_XPL_BUILD)	+= spl.o
>  obj-$(CONFIG_$(PHASE_)MTK_FIRMWARE_AB) += spl_ab.o mtk_ab.o
>  obj-$(CONFIG_$(PHASE_)MTK_BROM_DOWNLOAD_AGENT_FASTBOOT) += download_agent.o
> +obj-$(CONFIG_$(PHASE_)MTK_EARLY_CACHES) += early_caches.o
>  
>  obj-$(CONFIG_TARGET_MT7622) += mt7622/
>  obj-$(CONFIG_TARGET_MT7623) += mt7623/
> diff --git a/arch/arm/mach-mediatek/early_caches.c b/arch/arm/mach-mediatek/early_caches.c
> new file mode 100644
> index 000000000000..003393d2f681
> --- /dev/null
> +++ b/arch/arm/mach-mediatek/early_caches.c
> @@ -0,0 +1,21 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * MMU and caches before U-Boot sets up its final page tables
> + */
> +
> +#include <cpu_func.h>
> +#include <asm/global_data.h>
> +#include <asm/arch/misc.h>
> +#include <linux/sizes.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +/* get_page_table_size() for the largest MediaTek mem_map */
> +#define EARLY_TLB_SIZE	SZ_32K

nit: MTK_EARLY_TLB_SIZE for naming consistency

besides the nits:

Reviewed-by: Carlo Caione <ccaione@baylibre.com>

--
Carlo Caione

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 2/2] arm: mediatek: run board_init_f() with the caches on
  2026-11-20 16:29 ` [PATCH v3 2/2] arm: mediatek: run board_init_f() with the caches on Steffen Dirkwinkel
@ 2026-11-21 16:30   ` Carlo Caione
  0 siblings, 0 replies; 5+ messages in thread
From: Carlo Caione @ 2026-11-21 16:30 UTC (permalink / raw)
  To: Steffen Dirkwinkel
  Cc: GSS_MTK_Uboot_upstream, u-boot, Tom Rini, Ilias Apalodimas,
	Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, David Lechner,
	Julien Stephan, Steffen Dirkwinkel, Chris Chen, Julien Masson,
	Johan Jonker

On Fri, Nov 20, 2026 at 17:29:19 +0100, Steffen Dirkwinkel wrote:
> From: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
> 
> Device tree walks and other setup is very slow without caches, so turn
> them on before relocation.
> 
> On an MT8370 module, from bootstage marks before each initcall, two
> boots each:
> 
>   step                            caches off        caches on
>   initf_dm                        349.8 / 349.7     4.6 / 4.6 ms
>   serial_init                     204.7 / 204.7     3.0 / 3.0 ms
>   dram_init                       162.2 / 162.1     2.3 / 2.3 ms
>   relocate_code                   22.0 / 22.0       0.4 / 0.4 ms
>   board_init_f() to main_loop()   819 / 819         87 / 87 ms
> 
> and from the serial console, after power-on (includes 5s debug usb wait):
> 
>   U-Boot banner                   7336 / 7335 ms    6772 / 6775 ms
> 
> Signed-off-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
> ---
>  arch/arm/include/asm/arch-mediatek/misc.h |  1 +
>  arch/arm/mach-mediatek/Kconfig            | 10 +++++++++-
>  arch/arm/mach-mediatek/cpu.c              |  6 ++++++
>  arch/arm/mach-mediatek/early_caches.c     | 10 ++++++++++
>  4 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/include/asm/arch-mediatek/misc.h b/arch/arm/include/asm/arch-mediatek/misc.h
> index dd248d222b97..517fbe7842ff 100644
> --- a/arch/arm/include/asm/arch-mediatek/misc.h
> +++ b/arch/arm/include/asm/arch-mediatek/misc.h
> @@ -15,5 +15,6 @@
>  #define APSW_VER		0x0c
>  
>  void mtk_early_enable_caches(void);
> +void mtk_early_disable_caches(void);

nit: same as before these functions are really only dealing with
dcache, not caches in general so I think a more proper name would be
mtk_early_disable_dcache

Otherwise:

Reviewed-by: Carlo Caione <ccaione@baylibre.com>


--
Carlo Caione

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-21 16:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 16:29 [PATCH v3 0/2] arm: mediatek: run SPL and pre-relocation U-Boot with caches Steffen Dirkwinkel
2026-11-20 16:29 ` [PATCH v3 1/2] arm: mediatek: enable the caches in SPL Steffen Dirkwinkel
2026-11-21 16:29   ` Carlo Caione
2026-11-20 16:29 ` [PATCH v3 2/2] arm: mediatek: run board_init_f() with the caches on Steffen Dirkwinkel
2026-11-21 16:30   ` Carlo Caione

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.