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

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.