mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 03/27] ARM: cache: drive the XSC3 cache with the ARMv4 functions
Date: Sun, 16 Aug 2026 19:56:23 +0200	[thread overview]
Message-ID: <20260816-pxa3xx-v1-3-f3c3d7a6c43f@pengutronix.de> (raw)
In-Reply-To: <20260816-pxa3xx-v1-0-f3c3d7a6c43f@pengutronix.de>

XSC3 reports ARMv5TE and is dispatched to the ARMv5 cache functions
accordingly, where v5_mmu_cache_flush() cleans the D-cache with

	1:	mrc	p15, 0, r15, c7, c14, 3	@ test,clean,invalidate
		bne	1b

XSC3 does not implement that operation - Linux' xsc3_flush_kern_cache_all()
uses a set/way loop instead - so the condition flags never come back with
the cache reported clean and the loop does not end. The board hangs in
sync_caches_for_execution(), between the PBL and barebox proper, before
anything has been printed.

The ARMv4 functions flush by reading through the cache and use nothing
XScale is missing, so send XSC3 there.

This only shows up in a build that has another ARMv5 core in it, which is
why the PXA board defconfigs are unaffected and multi_v5_v6_defconfig
hangs. On its own CONFIG_CPU_XSC3 selects CPU_32v4T and no other CPU_32v*,
so ARM_MULTIARCH is never defined, cpu_architecture() is the compile time
constant CPU_ARCH_ARMv4T, and the same functions are reached by accident.
Add an ARM926 or an ARM1176 to the config and the runtime detection takes
over, correctly returns ARMv5TE, and picks code the core cannot run.

Assisted-by: Claude Opus 5
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/cpu/cache_32.c            | 31 +++++++++++++++++++++++++++++++
 arch/arm/include/asm/system_info.h |  9 +++++++++
 2 files changed, 40 insertions(+)

diff --git a/arch/arm/cpu/cache_32.c b/arch/arm/cpu/cache_32.c
index 0ac50c4d9a..e82cd212d2 100644
--- a/arch/arm/cpu/cache_32.c
+++ b/arch/arm/cpu/cache_32.c
@@ -39,10 +39,35 @@ DEFINE_CPU_FNS(v5)
 DEFINE_CPU_FNS(v6)
 DEFINE_CPU_FNS(v7)
 
+/*
+ * XSC3 reports ARMv5TE, and it is - but its cache is not the one the ARMv5
+ * code drives. v5_mmu_cache_flush() cleans the D-cache with the ARM926
+ * test-and-clean operation (c7, c14, 3), which XSC3 does not implement, so
+ * the loop waiting for it to report the cache clean never ends. The ARMv4
+ * code flushes by reading through the cache instead and uses nothing XScale
+ * is missing, so send these cores there.
+ *
+ * This only ever comes up in a build that has another ARMv5 core in it. On
+ * its own CPU_XSC3 selects CPU_32v4T and no other CPU_32v*, which leaves
+ * cpu_architecture() a compile time ARMv4T and lands on the same functions
+ * by accident.
+ */
+static struct cache_fns *cache_fns_by_core(void)
+{
+	if (IS_ENABLED(CONFIG_CPU_32v4T) && cpu_is_xsc3())
+		return &cache_fns_armv4;
+
+	return NULL;
+}
+
 static struct cache_fns *cache_functions(void)
 {
 	static struct cache_fns *cache_fns;
 
+	if (cache_fns)
+		return cache_fns;
+
+	cache_fns = cache_fns_by_core();
 	if (cache_fns)
 		return cache_fns;
 
@@ -119,6 +144,12 @@ void __mmu_cache_flush(void)
  */
 void arm_early_mmu_cache_flush(void)
 {
+	/* see cache_fns_by_core() */
+	if (IS_ENABLED(CONFIG_CPU_32v4T) && cpu_is_xsc3()) {
+		v4_mmu_cache_flush();
+		return;
+	}
+
 	switch (arm_early_get_cpu_architecture()) {
 #ifdef CONFIG_CPU_32v4T
 	case CPU_ARCH_ARMv4T:
diff --git a/arch/arm/include/asm/system_info.h b/arch/arm/include/asm/system_info.h
index 5a84fde75b..1fde203063 100644
--- a/arch/arm/include/asm/system_info.h
+++ b/arch/arm/include/asm/system_info.h
@@ -59,6 +59,9 @@
 #define CPU_IS_PXA270		0x69054110
 #define CPU_IS_PXA270_MASK	0xfffff7f0
 
+#define CPU_IS_XSC3		0x69056000
+#define CPU_IS_XSC3_MASK	0xffffe000
+
 #define cpu_is_arm(core) ((read_cpuid_id() & CPU_IS_##core##_MASK) == CPU_IS_##core)
 
 #ifdef CONFIG_CPU_32v4T
@@ -80,6 +83,12 @@
 #define cpu_is_pxa270() (0)
 #endif
 
+#ifdef CONFIG_CPU_XSC3
+#define cpu_is_xsc3()	cpu_is_arm(XSC3)
+#else
+#define cpu_is_xsc3()	(0)
+#endif
+
 #ifdef CONFIG_CPU_32v5
 #ifdef ARM_ARCH
 #define ARM_MULTIARCH

-- 
2.47.3




  parent reply	other threads:[~2026-08-16 18:01 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-16 17:56 [PATCH 00/27] ARM: Add pxa3xx and Raumfeld Speaker support Sascha Hauer
2026-08-16 17:56 ` [PATCH 01/27] ARM: pxa: remove PXA25x and PXA27x support Sascha Hauer
2026-08-16 17:56 ` [PATCH 02/27] video: remove the PXA framebuffer driver Sascha Hauer
2026-08-16 17:56 ` Sascha Hauer [this message]
2026-08-16 17:56 ` [PATCH 04/27] mci: pxamci: get the clock from the clk API Sascha Hauer
2026-08-16 17:56 ` [PATCH 05/27] pwm: pxa: " Sascha Hauer
2026-08-16 17:56 ` [PATCH 06/27] serial: " Sascha Hauer
2026-08-16 17:56 ` [PATCH 07/27] clk: pxa: add a device tree clock driver for PXA3xx Sascha Hauer
2026-08-16 17:56 ` [PATCH 08/27] mtd: nand: nand_mrvl_nfc: honour marvell,nand-keep-config Sascha Hauer
2026-08-16 17:56 ` [PATCH 09/27] mtd: nand: nand_mrvl_nfc: support the nand-controller bindings Sascha Hauer
2026-08-16 17:56 ` [PATCH 10/27] mtd: nand: mrvl_nfc: keep the ready latch across a STATUS command Sascha Hauer
2026-08-16 17:56 ` [PATCH 11/27] mtd: nand: mrvl_nfc: do not report a command timeout as an error Sascha Hauer
2026-08-16 17:56 ` [PATCH 12/27] mci: pxamci: probe from the device tree Sascha Hauer
2026-08-16 17:56 ` [PATCH 13/27] serial: pxa: add device tree support Sascha Hauer
2026-08-16 17:56 ` [PATCH 14/27] serial: pxa: provide the Linux console name Sascha Hauer
2026-08-16 17:56 ` [PATCH 15/27] gpio: pxa: add a driver and switch the architecture to GPIOLIB Sascha Hauer
2026-08-16 17:56 ` [PATCH 16/27] ARM: pxa: add DEBUG_LL support Sascha Hauer
2026-08-16 17:56 ` [PATCH 17/27] ARM: pxa: let the board select the SoC Sascha Hauer
2026-08-16 17:56 ` [PATCH 18/27] ARM: pxa: enable device tree support Sascha Hauer
2026-08-16 17:56 ` [PATCH 19/27] scripts: add pxa-image Sascha Hauer
2026-08-16 17:56 ` [PATCH 20/27] ARM: pxa: add a NAND first stage loader Sascha Hauer
2026-08-16 17:56 ` [PATCH 21/27] filetype: detect PXA3xx NTIM images Sascha Hauer
2026-08-16 17:56 ` [PATCH 22/27] ARM: pxa: add a barebox update handler for NAND Sascha Hauer
2026-08-16 17:56 ` [PATCH 23/27] clocksource: add a driver for the PXA OS timer and its watchdog Sascha Hauer
2026-08-16 17:56 ` [PATCH 24/27] ARM: pxa: move over to MULTIARCH Sascha Hauer
2026-08-16 17:56 ` [PATCH 25/27] ARM: pxa: reset straight away and without complaining Sascha Hauer
2026-08-16 17:56 ` [PATCH 26/27] ARM: pxa: add Raumfeld Speaker board support Sascha Hauer
2026-08-16 17:56 ` [PATCH 27/27] ARM: multi_v5_v6_defconfig: enable PXA support Sascha Hauer
2026-08-17  7:35 ` [PATCH 00/27] ARM: Add pxa3xx and Raumfeld Speaker support Ahmad Fatoum
2026-08-19  9:26 ` Sascha Hauer

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=20260816-pxa3xx-v1-3-f3c3d7a6c43f@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox