All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carlo Caione <ccaione@baylibre.com>
To: Steffen Dirkwinkel <lists@steffen.cc>
Cc: GSS_MTK_Uboot_upstream <GSS_MTK_Uboot_upstream@mediatek.com>,
	 u-boot@lists.u-boot-project.org, Tom Rini <trini@konsulko.com>,
	 Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Ryder Lee <ryder.lee@mediatek.com>,
	 Weijie Gao <weijie.gao@mediatek.com>,
	Chunfeng Yun <chunfeng.yun@mediatek.com>,
	Igor Belwon <igor.belwon@mentallysanemainliners.org>,
	David Lechner <dlechner@baylibre.com>,
	 Julien Stephan <jstephan@baylibre.com>,
	Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>,
	 Chris Chen <chris-qj.chen@mediatek.com>,
	Julien Masson <jmasson@baylibre.com>,
	 Johan Jonker <jbx6244@gmail.com>
Subject: Re: [PATCH v3 1/2] arm: mediatek: enable the caches in SPL
Date: Sat, 21 Nov 2026 17:29:21 +0100	[thread overview]
Message-ID: <awHEzAIcwMkHvMIt@macbook> (raw)
In-Reply-To: <20261120-std-upstream-mt8188-spl-caches-v3-1-b5ab70d56006@beckhoff.com>

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

  reply	other threads:[~2026-11-21 16:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-11-20 16:29 ` [PATCH v3 2/2] arm: mediatek: run board_init_f() with the caches on Steffen Dirkwinkel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awHEzAIcwMkHvMIt@macbook \
    --to=ccaione@baylibre.com \
    --cc=GSS_MTK_Uboot_upstream@mediatek.com \
    --cc=chris-qj.chen@mediatek.com \
    --cc=chunfeng.yun@mediatek.com \
    --cc=dlechner@baylibre.com \
    --cc=igor.belwon@mentallysanemainliners.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jbx6244@gmail.com \
    --cc=jmasson@baylibre.com \
    --cc=jstephan@baylibre.com \
    --cc=lists@steffen.cc \
    --cc=ryder.lee@mediatek.com \
    --cc=s.dirkwinkel@beckhoff.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    --cc=weijie.gao@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.