Skip to contentSkip to conversation

armv8: Enable CPUECTLR.SMPEN for coherency

PATCH New Zhiqiang Hou 3 participants 5 messages Jan 6, 2017 – Jan 19, 2017 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 armv8: Enable CPUECTLR.SMPEN for coherency

From: Mingkai Hu <[email protected]>

For A53, data coherency is enabled only when the CPUECTLR.SMPEN bit is set. The SMPEN bit should be set before enabling the data cache. If not enabled, the cache is not coherent with other cores and data corruption could occur.

For A57/A72, SMPEN bit enables the processor to receive instruction cache and TLB maintenance operations broadcast from other processors in the cluster. This bit should be set before enabling the caches and MMU, or performing any cache and TLB maintenance operations.

---
V2:
- Revised the help information.

 arch/arm/cpu/armv8/Kconfig | 18 ++++++++++++++++++
 arch/arm/cpu/armv8/start.S | 11 +++++++++++
 2 files changed, 29 insertions(+)
arch/arm/cpu/armv8/Kconfig +18 -0
index 22dce88..472b2ba 100644
@@ -3,6 +3,24 @@ if ARM64
 config ARMV8_MULTIENTRY
         bool "Enable multiple CPUs to enter into U-Boot"
 
+config ARMV8_SET_SMPEN
+        bool "Enable data coherency with other cores in cluster"
+        help
+	  Say Y here if there is not any trust firmware to set
+	  CPUECTLR_EL1.SMPEN bit before U-Boot.
+
+	  For A53, it enables data coherency with other cores in the
+	  cluster, and for A57/A72, it enables receiving of instruction
+	  cache and TLB maintenance operations.
+	  Cortex A53/57/72 cores require CPUECTLR_EL1.SMPEN set even
+	  for single core systems. Unfortunately write access to this
+	  register may be controlled by EL3/EL2 firmware. To be more
+	  precise, by default (if there is EL2/EL3 firmware running)
+	  this register is RO for NS EL1.
+	  This switch can be used to avoid writing to CPUECTLR_EL1,
+	  it can be safely enabled when EL2/EL3 initialized SMPEN bit
+	  or when CPU implementation doesn't include that register.
+
 config ARMV8_SPIN_TABLE
 	bool "Support spin-table enable method"
 	depends on ARMV8_MULTIENTRY && OF_LIBFDT
arch/arm/cpu/armv8/start.S +11 -0
index 4f5f6d8..5308702 100644
@@ -86,6 +86,17 @@ save_boot_params_ret:
 	msr	cpacr_el1, x0			/* Enable FP/SIMD */
 0:
 
+	/*
+	 * Enalbe SMPEN bit for coherency.
+	 * This register is not architectural but at the moment
+	 * this bit should be set for A53/A57/A72.
+	 */
+#ifdef CONFIG_ARMV8_SET_SMPEN
+	mrs     x0, S3_1_c15_c2_1               /* cpuactlr_el1 */
+	orr     x0, x0, #0x40
+	msr     S3_1_c15_c2_1, x0
+#endif
+
 	/* Apply ARM core specific erratas */
 	bl	apply_core_errata
 
Signature · 1 line
2.1.0.27.g96db324
#1 lore raw

PATCH v2 2/2 ARMv8/fsl-layerscape: Enable data coherency between cores in cluster

From: Hou Zhiqiang <[email protected]>

---
V2:
- No change

 arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/cpu/armv8/fsl-layerscape/Kconfig +4 -0
index cc0dc88..f71a243 100644
@@ -1,5 +1,6 @@
 config ARCH_LS1012A
 	bool
+	select ARMV8_SET_SMPEN
 	select FSL_LSCH2
 	select SYS_FSL_DDR_BE
 	select SYS_FSL_MMDC
@@ -7,6 +8,7 @@ config ARCH_LS1012A
 
 config ARCH_LS1043A
 	bool
+	select ARMV8_SET_SMPEN
 	select FSL_LSCH2
 	select SYS_FSL_DDR_BE
 	select SYS_FSL_DDR_VER_50
@@ -15,6 +17,7 @@ config ARCH_LS1043A
 
 config ARCH_LS1046A
 	bool
+	select ARMV8_SET_SMPEN
 	select FSL_LSCH2
 	select SYS_FSL_DDR_BE
 	select SYS_FSL_DDR4
@@ -24,6 +27,7 @@ config ARCH_LS1046A
 
 config ARCH_LS2080A
 	bool
+	select ARMV8_SET_SMPEN
 	select FSL_LSCH3
 	select SYS_FSL_DDR4
 	select SYS_FSL_DDR_LE
Signature · 1 line
2.1.0.27.g96db324
#2 lore raw

PATCH v2 1/2 armv8: Enable CPUECTLR.SMPEN for coherency

In reply to Zhiqiang Hou

Hi.

2017-01-06 18:41 GMT+09:00 Zhiqiang Hou <[email protected]>:

Quoted 29 lines

From: Mingkai Hu <[email protected]>

For A53, data coherency is enabled only when the CPUECTLR.SMPEN bit is set. The SMPEN bit should be set before enabling the data cache. If not enabled, the cache is not coherent with other cores and data corruption could occur.

For A57/A72, SMPEN bit enables the processor to receive instruction cache and TLB maintenance operations broadcast from other processors in the cluster. This bit should be set before enabling the caches and MMU, or performing any cache and TLB maintenance operations.

---
V2:
- Revised the help information.

 arch/arm/cpu/armv8/Kconfig | 18 ++++++++++++++++++
 arch/arm/cpu/armv8/start.S | 11 +++++++++++
 2 files changed, 29 insertions(+)
arch/arm/cpu/armv8/Kconfig +0 -0
index 22dce88..472b2ba 100644

arch/arm/cpu/armv8/Kconfig if ARM64 · line 10

Quoted 8 lines
arch/arm/cpu/armv8/Kconfig +5 -0
@@ -3,6 +3,24 @@ if ARM64
 config ARMV8_MULTIENTRY
         bool "Enable multiple CPUs to enter into U-Boot"
 
+config ARMV8_SET_SMPEN
+        bool "Enable data coherency with other cores in cluster"
+        help
+         Say Y here if there is not any trust firmware to set
+         CPUECTLR_EL1.SMPEN bit before U-Boot.

I am a bit curious about this.
Are you planning to implement Trusted Firmware in the future? It this option a temporary work-around until then?

Signature · 2 lines
Best Regards
Masahiro Yamada
#3 lore raw

PATCH v2 1/2 armv8: Enable CPUECTLR.SMPEN for coherency

Quoted 36 lines · Masahiro Yamada

Hi.

2017-01-06 18:41 GMT+09:00 Zhiqiang Hou <[email protected]>:

Quoted 32 lines

From: Mingkai Hu <[email protected]>

For A53, data coherency is enabled only when the CPUECTLR.SMPEN bit is set. The SMPEN bit should be set before enabling the data cache. If not enabled, the cache is not coherent with other cores and data corruption could occur.

For A57/A72, SMPEN bit enables the processor to receive instruction cache and TLB maintenance operations broadcast from other processors in the cluster. This bit should be set before enabling the caches and MMU, or performing any cache and TLB maintenance operations.

---
V2:
- Revised the help information.

 arch/arm/cpu/armv8/Kconfig | 18 ++++++++++++++++++
 arch/arm/cpu/armv8/start.S | 11 +++++++++++
 2 files changed, 29 insertions(+)
arch/arm/cpu/armv8/Kconfig +0 -0
index 22dce88..472b2ba 100644
@@ -3,6 +3,24 @@ if ARM64
 config ARMV8_MULTIENTRY
         bool "Enable multiple CPUs to enter into U-Boot"
 
Quoted 9 lines

arch/arm/cpu/armv8/Kconfig if ARM64 · line 10

Quoted 5 lines
arch/arm/cpu/armv8/Kconfig +5 -0
+config ARMV8_SET_SMPEN
+        bool "Enable data coherency with other cores in cluster"
+        help
+         Say Y here if there is not any trust firmware to set
+         CPUECTLR_EL1.SMPEN bit before U-Boot.

I am a bit curious about this.
Are you planning to implement Trusted Firmware in the future?

Yes, trusted firmware has been planned and is on the way.

Quoted 1 line

It this option a temporary work-around until then?

Yes. Actually there are other things need to be disabled once U-Boot starts at EL2.

York

#4 lore raw

PATCH v2 1/2 armv8: Enable CPUECTLR.SMPEN for coherency

In reply to Zhiqiang Hou
Quoted 12 lines · Zhiqiang Hou

From: Mingkai Hu <[email protected]>

For A53, data coherency is enabled only when the CPUECTLR.SMPEN bit is set. The SMPEN bit should be set before enabling the data cache. If not enabled, the cache is not coherent with other cores and data corruption could occur.

For A57/A72, SMPEN bit enables the processor to receive instruction cache and TLB maintenance operations broadcast from other processors in the cluster. This bit should be set before enabling the caches and MMU, or performing any cache and TLB maintenance operations.

Quoted 8 lines

---
V2:
- Revised the help information.

This set is applied to fsl-qoriq master, awaiting upstream. Thanks.

York