Skip to contentSkip to conversation

arm: start.S: Fix startup of dragonboard410c

PATCH New Mateusz Kulikowski 3 participants 3 messages Jul 12, 2016 – Jul 14, 2016 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: start.S: Fix startup of dragonboard410c

Commit d73718f3 breaks devices where:
- There is EL2/EL3 firmware and
- U-Boot starts in NS EL1 and
- EL2/EL3 firmware didn't unlocked write-access to CPUECTLR_EL1.

This patch makes that change opt-out configuration option, and disables it for dragonboard410c.

---
I make it opt-out so nobody will complain that I broke someones board.

If you prefer opt-in - just let me know, I'll flip the switch in Kconfig.

BTW. I wonder if this register should be written at all on devices that implement ARMv8 but are *not* ARM Cortex.

Mateusz

 arch/arm/cpu/armv8/Kconfig        | 13 +++++++++++++
 arch/arm/cpu/armv8/start.S        |  7 +++++--
 configs/dragonboard410c_defconfig |  1 +
 3 files changed, 19 insertions(+), 2 deletions(-)
arch/arm/cpu/armv8/Kconfig +13 -0
index 3d19bbf..33af0a2 100644
@@ -3,4 +3,17 @@ if ARM64
 config ARMV8_MULTIENTRY
         boolean "Enable multiple CPUs to enter into U-Boot"
 
+config ARMV8_SET_SMPEN
+        boolean "Enable data coherency with other cores in cluster"
+        default y if ARM64
+        help
+          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.
+
 endif
arch/arm/cpu/armv8/start.S +5 -2
index dfce469..777cad3 100644
@@ -81,13 +81,16 @@ reset:
 	msr	cpacr_el1, x0			/* Enable FP/SIMD */
 0:
 
-	/* Enalbe SMPEN bit for coherency.
+	/* Enable SMPEN bit for coherency.
 	 * This register is not architectural but at the moment
 	 * this bit should be set for A53/A57/A72.
+	 *
 	 */
-	mrs     x0, S3_1_c15_c2_1               /* cpuactlr_el1 */
+#ifdef CONFIG_ARMV8_SET_SMPEN
+	mrs     x0, S3_1_c15_c2_1               /* cpuectlr_el1 */
 	orr     x0, x0, #0x40
 	msr     S3_1_c15_c2_1, x0
+#endif
 
 	/* Apply ARM core specific erratas */
 	bl	apply_core_errata
configs/dragonboard410c_defconfig +1 -0
index ad2e8b8..d3cfa69 100644
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_ARCH_SNAPDRAGON=y
+CONFIG_ARMV8_SET_SMPEN=n
 CONFIG_DEFAULT_DEVICE_TREE="dragonboard410c"
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="dragonboard410c => "
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 arm: start.S: Fix startup of dragonboard410c

On 12/07/16 21:15, Mateusz Kulikowski wrote:

Hi Mateusz,

Quoted 7 lines

Commit d73718f3 breaks devices where:
- There is EL2/EL3 firmware and
- U-Boot starts in NS EL1 and
- EL2/EL3 firmware didn't unlocked write-access to CPUECTLR_EL1.

This patch makes that change opt-out configuration option, and disables it for dragonboard410c.

thanks for bringing this up!
You are totally right, as this register isn't architecturally defined, we should never set it without checking for a particular core. Actually even that is not enough, as it's also access restricted - even defaulting to RO - as you mentioned.

So I am very much for a board specific _opt-in_ solution, also as ARM Trusted Firmware takes care of the bit already, for instance.

Mingkai Hu, can you say for which board/SoC/family the original patch was needed for? Layerscape?

...

Quoted 27 lines

---
I make it opt-out so nobody will complain that I broke someones board.

If you prefer opt-in - just let me know, I'll flip the switch in Kconfig.

BTW. I wonder if this register should be written at all on devices that implement ARMv8 but are *not* ARM Cortex.

Mateusz

 arch/arm/cpu/armv8/Kconfig        | 13 +++++++++++++
 arch/arm/cpu/armv8/start.S        |  7 +++++--
 configs/dragonboard410c_defconfig |  1 +
 3 files changed, 19 insertions(+), 2 deletions(-)
arch/arm/cpu/armv8/Kconfig +2 -0
index 3d19bbf..33af0a2 100644
@@ -3,4 +3,17 @@ if ARM64
 config ARMV8_MULTIENTRY
         boolean "Enable multiple CPUs to enter into U-Boot"
 
+config ARMV8_SET_SMPEN
+        boolean "Enable data coherency with other cores in cluster"

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

Quoted 10 lines
arch/arm/cpu/armv8/Kconfig +10 -0
+        default y if ARM64
+        help
+          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.

I don't think we need this option to be user visible. Just a simple "boolean" should suffice, boards in need for the bit should select it in their defconfig or in a board specific Kconfig file.
Either it's needed on board or not, a _user_ shouldn't be bothered with that choice.
You can copy the help text into the commit message.

Quoted 7 lines
arch/arm/cpu/armv8/Kconfig +1 -0
+
 endif
arch/arm/cpu/armv8/start.S +0 -0
index dfce469..777cad3 100644

arch/arm/cpu/armv8/start.S reset: · line 87

Quoted 8 lines
arch/arm/cpu/armv8/start.S +2 -1
@@ -81,13 +81,16 @@ reset:
 	msr	cpacr_el1, x0			/* Enable FP/SIMD */
 0:
 
-	/* Enalbe SMPEN bit for coherency.
+	/* Enable SMPEN bit for coherency.
 	 * This register is not architectural but at the moment
 	 * this bit should be set for A53/A57/A72.
+	 *

Shouldn't this extra line be at the beginning of the comment instead?

arch/arm/cpu/armv8/start.S reset: · line 90

Quoted 4 lines
arch/arm/cpu/armv8/start.S +2 -1
 	 */
-	mrs     x0, S3_1_c15_c2_1               /* cpuactlr_el1 */
+#ifdef CONFIG_ARMV8_SET_SMPEN
+	mrs     x0, S3_1_c15_c2_1               /* cpuectlr_el1 */

Ah, thanks for fixing that typo, I was confused for a moment or two.

Thanks,
Andre

Quoted 18 lines
arch/arm/cpu/armv8/start.S +1 -0
 	orr     x0, x0, #0x40
 	msr     S3_1_c15_c2_1, x0
+#endif
 
 	/* Apply ARM core specific erratas */
 	bl	apply_core_errata
configs/dragonboard410c_defconfig +1 -0
index ad2e8b8..d3cfa69 100644
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_ARCH_SNAPDRAGON=y
+CONFIG_ARMV8_SET_SMPEN=n
 CONFIG_DEFAULT_DEVICE_TREE="dragonboard410c"
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="dragonboard410c => "
#2 lore raw

PATCH 1/1 arm: start.S: Fix startup of dragonboard410c

Quoted 18 lines · Andr? Przywara

On 12/07/16 21:15, Mateusz Kulikowski wrote:

Hi Mateusz,

Quoted 7 lines

Commit d73718f3 breaks devices where:
- There is EL2/EL3 firmware and
- U-Boot starts in NS EL1 and
- EL2/EL3 firmware didn't unlocked write-access to CPUECTLR_EL1.

This patch makes that change opt-out configuration option, and disables it for dragonboard410c.

thanks for bringing this up!
You are totally right, as this register isn't architecturally defined, we should never set it without checking for a particular core. Actually even that is not enough, as it's also access restricted - even defaulting to RO - as you mentioned.

Quoted 5 lines

So I am very much for a board specific _opt-in_ solution, also as ARM Trusted Firmware takes care of the bit already, for instance.

Mingkai Hu, can you say for which board/SoC/family the original patch was needed for? Layerscape?

OK, I'm going to revert the original patch here (and would recommend that distros that are picking up v2016.07 do the same). Thanks all!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160714/03931d88/attachment.sig>