Skip to contentSkip to conversation

Add support for booting multiple cores

PATCH Superseded Akshay Saraswat 3 participants 16 messages Feb 3, 2015 – Feb 17, 2015

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add support for booting multiple cores

This patch series introduces changes for booting secondary CPUs on Exynos5420 and Exynos5800.

Changes since v1:
- Added Reviewed-by & Tested-by in the acked patches.
- Removed unnecessary CONFIGS and macros.
- Changed names of few macros for better understanding in patch 2.
- Added MPIDR bit assignment info comment in power_down_core in patch 2.
- Changed to SPDX header in sec_boot.S in patch 5.
- Fixed compilation error for snow build in patch 11.

Akshay Saraswat (10):
Exynos542x: Config: Add various configs
Exynos542x: CPU: Power down all secondary cores
Exynos542x: Add workaround for ARM errata 798870
Exynos542x: Add workaround for ARM errata 799270
Exynos542x: Add workaround for exynos iROM errata
Exynos542x: Change ambiguous function name set_l2cache
Exynos542x: cache: Disable clean/evict push to external
Exynos542x: add L2 control register configuration
Exynos542x: Fix secondary core booting for thumb
Exynos542x: Make A7s boot with thumb-mode U-Boot on warm reset

Doug Anderson (1):
Exynos: Fix L2 cache timings on Exynos5420 and Exynos5800

 arch/arm/cpu/armv7/exynos/Makefile        |   2 +
 arch/arm/cpu/armv7/exynos/common_setup.h  |  55 ++++++++++
 arch/arm/cpu/armv7/exynos/exynos5_setup.h |   3 +
 arch/arm/cpu/armv7/exynos/lowlevel_init.c | 166 ++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7/exynos/sec_boot.S      | 128 +++++++++++++++++++++++
 arch/arm/cpu/armv7/exynos/soc.c           |  35 -------
 arch/arm/include/asm/arch-exynos/cpu.h    |   5 +
 arch/arm/include/asm/arch-exynos/system.h |  88 ++++++++++++++++
 include/configs/exynos5420-common.h       |  16 +++
 9 files changed, 463 insertions(+), 35 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/exynos/sec_boot.S
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/11 Exynos542x: Config: Add various configs

This patch adds "iRAM, CPU state and low power" configs which are the addresses acting as flag registers.

iROM code checks CONFIG_LOWPOWER_FLAG address. If it is equal to CONFIG_LOWPOWER_EN then it jumps to the address (0x02020000+CPUID*4). This is a part of iROM logic. Rest other flags are being used at various places during kernel switching and reset.
They are nowhere documented because they are part programming. These configs are serving as flags for us because they are representing the addresses in iRAM which we are using for storing and extracting CPU Status and GIC status.

---
Changes since v1:
- Added Reviewed-by & Tested-by.
- Removed unnecessary CONFIGS.

 include/configs/exynos5420-common.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
include/configs/exynos5420-common.h +16 -0
index fe72bd0..b42dab7 100644
@@ -38,4 +38,20 @@
 
 #define CONFIG_BOARD_REV_GPIO_COUNT	2
 
+#define CONFIG_PHY_IRAM_BASE		0x02020000
+
+/* Address for relocating helper code (Last 4 KB of IRAM) */
+#define CONFIG_EXYNOS_RELOCATE_CODE_BASE	(CONFIG_IRAM_TOP - 0x1000)
+
+/*
+ * Low Power settings
+ */
+#define CONFIG_LOWPOWER_FLAG		0x02020028
+#define CONFIG_LOWPOWER_ADDR		0x0202002C
+
+/*
+ * Number of CPUs available
+ */
+#define CONFIG_CORE_COUNT		0x8
+
 #endif	/* __CONFIG_EXYNOS5420_H */
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 2/11 Exynos542x: CPU: Power down all secondary cores

In reply to Akshay Saraswat

This patch adds code to shutdown secondary cores. When U-boot comes up, all secondary cores appear powered on, which is undesirable and causes side effects while initializing these cores in kernel.

Secondary core power down happens in following steps:

Step-1: After Exynos power-on, primary core starts executing first.
Step-2: In iROM code every core has to check 2 flags i.e.

	addresses 0x02020028 & 0x02020004.

Step-3: Initially 0x02020028 is 0 for all cores and 0x02020004 has a
jump address for primary core and 0 for all secondary cores.
Step-4: Therefore, primary core follows normal iROM execution and jumps
to BL1 eventually, whereas all secondary cores enter WFE.
Step-5: When primary core comes into function secondary_cores_configure,
it puts pointer to function power_down_core into 0x02020004 and provides DSB and SEV for all cores so that they may come out of WFE and jump to power_down_core function.
Step-6: And ultimately because of power_down_core all
secondary cores shut-down.

---
Changes since v1:
- Removed unnecessary macros.
- Changed names of few macros for better understanding.
- Added MPIDR bit assignment info comment in power_down_core.

 arch/arm/cpu/armv7/exynos/exynos5_setup.h |  3 ++
 arch/arm/cpu/armv7/exynos/lowlevel_init.c | 69 ++++++++++++++++++++++++
 arch/arm/include/asm/arch-exynos/cpu.h    |  5 ++
 arch/arm/include/asm/arch-exynos/system.h | 87 +++++++++++++++++++++++++++++++
 4 files changed, 164 insertions(+)
arch/arm/cpu/armv7/exynos/exynos5_setup.h +3 -0
index 2eea48a..9073f50 100644
@@ -700,6 +700,9 @@
 #define CLK_DIV_CPERI1_VAL	NOT_AVAILABLE
 
 #else
+
+#define CPU_CONFIG_STATUS_OFFSET	0x80
+#define CPU_RST_FLAG_VAL		0xFCBA0D10
 #define PAD_RETENTION_DRAM_COREBLK_VAL	0x10000000
 
 /* APLL_CON1 */
arch/arm/cpu/armv7/exynos/lowlevel_init.c +69 -0

88 lines not on this page · raw message

arch/arm/include/asm/arch-exynos/cpu.h +5 -0
index 29674ad..e739520 100644
@@ -153,6 +153,10 @@
 #define EXYNOS5420_CLOCK_BASE		0x10010000
 #define EXYNOS5420_POWER_BASE		0x10040000
 #define EXYNOS5420_SWRESET		0x10040400
+#define EXYNOS5420_INFORM_BASE		0x10040800
+#define EXYNOS5420_SPARE_BASE		0x10040900
+#define EXYNOS5420_CPU_CONFIG_BASE	0x10042000
+#define EXYNOS5420_CPU_STATUS_BASE	0x10042004
 #define EXYNOS5420_SYSREG_BASE		0x10050000
 #define EXYNOS5420_TZPC_BASE		0x100E0000
 #define EXYNOS5420_WATCHDOG_BASE	0x101D0000
@@ -186,6 +190,7 @@
 #define EXYNOS5420_USB3PHY_BASE		DEVICE_NOT_AVAILABLE
 #define EXYNOS5420_USB_HOST_XHCI_BASE	DEVICE_NOT_AVAILABLE
 
+
 #ifndef __ASSEMBLY__
 #include <asm/io.h>
 /* CPU detection macros */
arch/arm/include/asm/arch-exynos/system.h +87 -0

93 lines not on this page · raw message

Signature · 1 line
1.9.1
#3 lore raw

PATCH v2 2/11 Exynos542x: CPU: Power down all secondary cores

Quoted 29 lines · Akshay Saraswat

This patch adds code to shutdown secondary cores. When U-boot comes up, all secondary cores appear powered on, which is undesirable and causes side effects while initializing these cores in kernel.

Secondary core power down happens in following steps:

Step-1: After Exynos power-on, primary core starts executing first.
Step-2: In iROM code every core has to check 2 flags i.e.

        addresses 0x02020028 & 0x02020004.

Step-3: Initially 0x02020028 is 0 for all cores and 0x02020004 has a
jump address for primary core and 0 for all secondary cores.
Step-4: Therefore, primary core follows normal iROM execution and jumps
to BL1 eventually, whereas all secondary cores enter WFE.
Step-5: When primary core comes into function secondary_cores_configure,
it puts pointer to function power_down_core into 0x02020004 and provides DSB and SEV for all cores so that they may come out of WFE and jump to power_down_core function.
Step-6: And ultimately because of power_down_core all
secondary cores shut-down.

---
Changes since v1:
- Removed unnecessary macros.
- Changed names of few macros for better understanding.
- Added MPIDR bit assignment info comment in power_down_core.

Quoted 5 lines
 arch/arm/cpu/armv7/exynos/exynos5_setup.h |  3 ++
 arch/arm/cpu/armv7/exynos/lowlevel_init.c | 69 ++++++++++++++++++++++++
 arch/arm/include/asm/arch-exynos/cpu.h    |  5 ++
 arch/arm/include/asm/arch-exynos/system.h | 87 +++++++++++++++++++++++++++++++
 4 files changed, 164 insertions(+)
#4 lore raw

PATCH v2 3/11 Exynos542x: Add workaround for ARM errata 798870

In reply to Akshay Saraswat

This patch adds workaround for ARM errata 798870 which says "If back-to-back speculative cache line fills (fill A and fill B) are issued from the L1 data cache of a CPU to the L2 cache, the second request (fill B) is then cancelled, and the second request would have detected a hazard against a recent write or eviction (write B) to the same cache line as fill B then the L2 logic might deadlock."

---
Changes since v1:
- Added Reviewed-by & Tested-by.
- Added space before */ on line # 40.

 arch/arm/cpu/armv7/exynos/lowlevel_init.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
arch/arm/cpu/armv7/exynos/lowlevel_init.c +22 -0
index d599bd3..3ad5b78 100644
@@ -46,6 +46,28 @@ enum {
 
 #ifdef CONFIG_EXYNOS5420
 /*
+ * Set L2ACTLR[7] to reissue any memory transaction in the L2 that has been
+ * stalled for 1024 cycles to verify that its hazard condition still exists.
+ */
+void set_l2cache(void)
+{
+	uint32_t val;
+
+	/* Read MIDR for Primary Part Number */
+	mrc_midr(val);
+	val = (val >> 4);
+	val &= 0xf;
+
+	/* L2ACTLR[7]: Enable hazard detect timeout for A15 */
+	if (val == 0xf) {
+		mrc_l2_aux_ctlr(val);
+		val |= (1 << 7);
+		mcr_l2_aux_ctlr(val);
+		mrc_l2_ctlr(val);
+	}
+}
+
+/*
  * Pointer to this function is stored in iRam which is used
  * for jump and power down of a specific core.
  */
Signature · 1 line
1.9.1
#5 lore raw

PATCH v2 4/11 Exynos542x: Add workaround for ARM errata 799270

In reply to Akshay Saraswat

This patch adds workaround for the ARM errata 799270 which says "If the L2 cache logic clock is stopped because of L2 inactivity, setting or clearing the ACTLR.SMP bit might not be effective. The bit is modified in the ACTLR, meaning a read of the register returns the updated value. However the logic that uses that bit retains the previous value."

---
Changes since v1:
- Added Reviewed-by & Tested-by.

 arch/arm/cpu/armv7/exynos/lowlevel_init.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
arch/arm/cpu/armv7/exynos/lowlevel_init.c +22 -0
index 3ad5b78..3ebbf84 100644
@@ -46,6 +46,28 @@ enum {
 
 #ifdef CONFIG_EXYNOS5420
 /*
+ * Ensure that the L2 logic has been used within the previous 256 cycles
+ * before modifying the ACTLR.SMP bit. This is required during boot before
+ * MMU has been enabled, or during a specified reset or power down sequence.
+ */
+void enable_smp(void)
+{
+	uint32_t temp, val;
+
+	/* Enable SMP mode */
+	mrc_auxr(temp);
+	temp |= (1 << 6);
+
+	/* Dummy read to assure L2 access */
+	val = readl(EXYNOS5420_INFORM_BASE);
+	val &= 0;
+	temp |= val;
+	mcr_auxr(temp);
+	dsb();
+	isb();
+}
+
+/*
  * Set L2ACTLR[7] to reissue any memory transaction in the L2 that has been
  * stalled for 1024 cycles to verify that its hazard condition still exists.
  */
Signature · 1 line
1.9.1
#6 lore raw

PATCH v2 5/11 Exynos542x: Add workaround for exynos iROM errata

In reply to Akshay Saraswat

iROM logic provides undesired jump address for CPU2. This patch adds a programmable susbstitute for a part of iROM logic which wakes up cores and provides jump addresses. This patch creates a logic to make all secondary cores jump to a particular address which evades the possibility of CPU2 jumping to wrong address and create undesired results.

Logic of the workaround:

Step-1: iROM code checks value at address 0x2020028.
Step-2: If value is 0xc9cfcfcf, it jumps to the address (0x202000+CPUid*4),
else, it continues executing normally.
Step-3: Primary core puts secondary cores in WFE and store 0xc9cfcfcf in

	0x2020028 and jump address (pointer to function low_power_start)
	in (0x202000+CPUid*4).

Step-4: When secondary cores recieve event signal they jump to this address
and continue execution.

---
Changes since v1:
- Added Reviewed-by & Tested-by.
- Changed to SPDX header in sec_boot.S.

 arch/arm/cpu/armv7/exynos/Makefile        |   2 +
 arch/arm/cpu/armv7/exynos/lowlevel_init.c |  90 ++++++++++++++++-----
 arch/arm/cpu/armv7/exynos/sec_boot.S      | 128 ++++++++++++++++++++++++++++++
 3 files changed, 202 insertions(+), 18 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/exynos/sec_boot.S
arch/arm/cpu/armv7/exynos/Makefile +2 -0
index e207bd6..8542f89 100644
@@ -7,6 +7,8 @@
 
 obj-y	+= clock.o power.o soc.o system.o pinmux.o tzpc.o
 
+obj-$(CONFIG_EXYNOS5420)	+= sec_boot.o
+
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_EXYNOS5)	+= clock_init_exynos5.o
 obj-$(CONFIG_EXYNOS5)	+= dmc_common.o dmc_init_ddr3.o
arch/arm/cpu/armv7/exynos/lowlevel_init.c +72 -18

127 lines not on this page · raw message

arch/arm/cpu/armv7/exynos/sec_boot.S new file +128 -0

128 lines not on this page · raw message

Signature · 1 line
1.9.1
#7 lore raw

PATCH v2 6/11 Exynos542x: Change ambiguous function name set_l2cache

In reply to Akshay Saraswat

1. Renaming set_l2cache to configure_l2actlr in order to avoid misleading comprehensions. Apparently this name suggests that L2 cache is being set or initialized which is incorrect as per the code in this function.
2. Cleaning missed mrc for L2 control register.

---
Changes since v1:
- Added Reviewed-by & Tested-by.

 arch/arm/cpu/armv7/exynos/lowlevel_init.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/arm/cpu/armv7/exynos/lowlevel_init.c +3 -4
index 527d20b..1c70e54 100644
@@ -71,7 +71,7 @@ static void enable_smp(void)
  * Set L2ACTLR[7] to reissue any memory transaction in the L2 that has been
  * stalled for 1024 cycles to verify that its hazard condition still exists.
  */
-static void set_l2cache(void)
+static void configure_l2actlr(void)
 {
 	uint32_t val;
 
@@ -85,7 +85,6 @@ static void set_l2cache(void)
 		mrc_l2_aux_ctlr(val);
 		val |= (1 << 7);
 		mcr_l2_aux_ctlr(val);
-		mrc_l2_ctlr(val);
 	}
 }
 
@@ -123,7 +122,7 @@ static void low_power_start(void)
 
 	/* Set the CPU to SVC32 mode */
 	svc32_mode_en();
-	set_l2cache();
+	configure_l2actlr();
 
 	/* Invalidate L1 & TLB */
 	val = 0x0;
@@ -176,7 +175,7 @@ static void power_down_core(void)
 static void secondary_cores_configure(void)
 {
 	/* Setup L2 cache */
-	set_l2cache();
+	configure_l2actlr();
 
 	/* Clear secondary boot iRAM base */
 	writel(0x0, (CONFIG_EXYNOS_RELOCATE_CODE_BASE + 0x1C));
Signature · 1 line
1.9.1
#8 lore raw

PATCH v2 7/11 Exynos542x: cache: Disable clean/evict push to external

In reply to Akshay Saraswat

L2 Auxiliary Control Register provides configuration and control options for the L2 memory system. Bit 3 of L2ACTLR stands for clean/evict push to external. Setting bit 3 disables clean/evict which is what this patch intends to do.

---
Changes since v1:
- Added Reviewed-by & Tested-by.

 arch/arm/cpu/armv7/exynos/soc.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/cpu/armv7/exynos/soc.c +9 -0
index 8c7d7d8..7268b9b 100644
@@ -45,6 +45,15 @@ static void exynos5_set_l2cache_params(void)
 		CACHE_DATA_RAM_LATENCY;
 
 	asm volatile("mcr p15, 1, %0, c9, c0, 2\n" : : "r"(val));
+
+#ifdef CONFIG_EXYNOS5420
+	/* Read CP15 L2ACTLR value */
+	asm volatile("mrc	p15, 1, %0, c15, c0, 0" : "=r" (val));
+	/* Disable clean/evict push to external */
+	val |= (0x1 << 3);
+	/* Write new vlaue to L2ACTLR */
+	asm volatile("mcr	p15, 1, %0, c15, c0, 0" : : "r" (val));
+#endif
 }
 
 /*
Signature · 1 line
1.9.1
#9 lore raw

PATCH v2 7/11 Exynos542x: cache: Disable clean/evict push to external

Hi,

Quoted 21 lines · Akshay Saraswat

L2 Auxiliary Control Register provides configuration and control options for the L2 memory system. Bit 3 of L2ACTLR stands for clean/evict push to external. Setting bit 3 disables clean/evict which is what this patch intends to do.

---
Changes since v1:
- Added Reviewed-by & Tested-by.

 arch/arm/cpu/armv7/exynos/soc.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/cpu/armv7/exynos/soc.c +0 -0
index 8c7d7d8..7268b9b 100644

arch/arm/cpu/armv7/exynos/soc.c static void exynos5_set_l2cache_params(void) · line 49

Quoted 5 lines
arch/arm/cpu/armv7/exynos/soc.c +2 -0
@@ -45,6 +45,15 @@ static void exynos5_set_l2cache_params(void)
 		CACHE_DATA_RAM_LATENCY;
 
 	asm volatile("mcr p15, 1, %0, c9, c0, 2\n" : : "r"(val));
+
+#ifdef CONFIG_EXYNOS5420

I think you can use proid_is.. instead of ifdef

arch/arm/cpu/armv7/exynos/soc.c static void exynos5_set_l2cache_params(void) · line 59

Quoted 11 lines
arch/arm/cpu/armv7/exynos/soc.c +7 -0
+	/* Read CP15 L2ACTLR value */
+	asm volatile("mrc	p15, 1, %0, c15, c0, 0" : "=r" (val));
+	/* Disable clean/evict push to external */
+	val |= (0x1 << 3);
+	/* Write new vlaue to L2ACTLR */
+	asm volatile("mcr	p15, 1, %0, c15, c0, 0" : : "r" (val));
+#endif
 }
 
 /*

Thanks,
Minkyu Kang.

#10 lore raw

PATCH v2 8/11 Exynos542x: add L2 control register configuration

In reply to Akshay Saraswat

This patch does 3 things:
1. Enables ECC by setting 21st bit of L2CTLR.
2. Restore data and tag RAM latencies to 3 cycles because iROM sets 0x3000400 L2CTLR value during switching.
3. Disable clean/evict push to external by setting 3rd bit of L2ACTLR. We need to restore this here due to switching.

---
Changes since v1:
- Added Reviewed-by & Tested-by.

 arch/arm/cpu/armv7/exynos/lowlevel_init.c | 53 +++++++++++++++++++++++--------
 arch/arm/cpu/armv7/exynos/soc.c           |  7 ++++
 2 files changed, 46 insertions(+), 14 deletions(-)
arch/arm/cpu/armv7/exynos/lowlevel_init.c +39 -14
index 1c70e54..9892e6b 100644
@@ -68,24 +68,40 @@ static void enable_smp(void)
 }
 
 /*
+ * Enable ECC by setting L2CTLR[21].
+ * Set L2CTLR[7] to make tag ram latency 3 cycles and
+ * set L2CTLR[1] to make data ram latency 3 cycles.
+ * We need to make RAM latency of 3 cycles here because cores
+ * power ON and OFF while switching. And everytime a core powers
+ * ON, iROM provides it a default L2CTLR value 0x400 which stands
+ * for TAG RAM setup of 1 cycle. Hence, we face a need of
+ * restoring data and tag latency values.
+ */
+static void configure_l2_ctlr(void)
+{
+	uint32_t val;
+
+	mrc_l2_ctlr(val);
+	val |= (1 << 21);
+	val |= (1 << 7);
+	val |= (1 << 1);
+	mcr_l2_ctlr(val);
+}
+
+/*
  * Set L2ACTLR[7] to reissue any memory transaction in the L2 that has been
  * stalled for 1024 cycles to verify that its hazard condition still exists.
+ * Disable clean/evict push to external by setting L2ACTLR[3].
  */
-static void configure_l2actlr(void)
+static void configure_l2_actlr(void)
 {
 	uint32_t val;
 
-	/* Read MIDR for Primary Part Number */
-	mrc_midr(val);
-	val = (val >> 4);
-	val &= 0xf;
-
-	/* L2ACTLR[7]: Enable hazard detect timeout for A15 */
-	if (val == 0xf) {
-		mrc_l2_aux_ctlr(val);
-		val |= (1 << 7);
-		mcr_l2_aux_ctlr(val);
-	}
+	mrc_l2_aux_ctlr(val);
+	val |= (1 << 27);
+	val |= (1 << 7);
+	val |= (1 << 3);
+	mcr_l2_aux_ctlr(val);
 }
 
 /*
@@ -122,7 +138,16 @@ static void low_power_start(void)
 
 	/* Set the CPU to SVC32 mode */
 	svc32_mode_en();
-	configure_l2actlr();
+
+	/* Read MIDR for Primary Part Number */
+	mrc_midr(val);
+	val = (val >> 4);
+	val &= 0xf;
+
+	if (val == 0xf) {
+		configure_l2_ctlr();
+		configure_l2_actlr();
+	}
 
 	/* Invalidate L1 & TLB */
 	val = 0x0;
@@ -175,7 +200,7 @@ static void power_down_core(void)
 static void secondary_cores_configure(void)
 {
 	/* Setup L2 cache */
-	configure_l2actlr();
+	configure_l2_ctlr();
 
 	/* Clear secondary boot iRAM base */
 	writel(0x0, (CONFIG_EXYNOS_RELOCATE_CODE_BASE + 0x1C));
arch/arm/cpu/armv7/exynos/soc.c +7 -0
index 7268b9b..ea201e7 100644
@@ -10,8 +10,10 @@
 #include <asm/system.h>
 
 enum l2_cache_params {
+#ifndef CONFIG_EXYNOS5420
 	CACHE_TAG_RAM_SETUP = (1 << 9),
 	CACHE_DATA_RAM_SETUP = (1 << 5),
+#endif
 	CACHE_TAG_RAM_LATENCY = (2 << 6),
 	CACHE_DATA_RAM_LATENCY = (2 << 0)
 };
@@ -39,10 +41,15 @@ static void exynos5_set_l2cache_params(void)
 
 	asm volatile("mrc p15, 1, %0, c9, c0, 2\n" : "=r"(val));
 
+#ifndef CONFIG_EXYNOS5420
 	val |= CACHE_TAG_RAM_SETUP |
 		CACHE_DATA_RAM_SETUP |
 		CACHE_TAG_RAM_LATENCY |
 		CACHE_DATA_RAM_LATENCY;
+#else
+	val |= CACHE_TAG_RAM_LATENCY |
+		CACHE_DATA_RAM_LATENCY;
+#endif
 
 	asm volatile("mcr p15, 1, %0, c9, c0, 2\n" : : "r"(val));
 
Signature · 1 line
1.9.1
#11 lore raw

PATCH v2 8/11 Exynos542x: add L2 control register configuration

Hi,

Quoted 108 lines · Akshay Saraswat

This patch does 3 things:
1. Enables ECC by setting 21st bit of L2CTLR.
2. Restore data and tag RAM latencies to 3 cycles because iROM sets 0x3000400 L2CTLR value during switching.
3. Disable clean/evict push to external by setting 3rd bit of L2ACTLR. We need to restore this here due to switching.

---
Changes since v1:
- Added Reviewed-by & Tested-by.

 arch/arm/cpu/armv7/exynos/lowlevel_init.c | 53 +++++++++++++++++++++++--------
 arch/arm/cpu/armv7/exynos/soc.c           |  7 ++++
 2 files changed, 46 insertions(+), 14 deletions(-)
arch/arm/cpu/armv7/exynos/lowlevel_init.c +39 -14
index 1c70e54..9892e6b 100644
@@ -68,24 +68,40 @@ static void enable_smp(void)
 }
 
 /*
+ * Enable ECC by setting L2CTLR[21].
+ * Set L2CTLR[7] to make tag ram latency 3 cycles and
+ * set L2CTLR[1] to make data ram latency 3 cycles.
+ * We need to make RAM latency of 3 cycles here because cores
+ * power ON and OFF while switching. And everytime a core powers
+ * ON, iROM provides it a default L2CTLR value 0x400 which stands
+ * for TAG RAM setup of 1 cycle. Hence, we face a need of
+ * restoring data and tag latency values.
+ */
+static void configure_l2_ctlr(void)
+{
+	uint32_t val;
+
+	mrc_l2_ctlr(val);
+	val |= (1 << 21);
+	val |= (1 << 7);
+	val |= (1 << 1);
+	mcr_l2_ctlr(val);
+}
+
+/*
  * Set L2ACTLR[7] to reissue any memory transaction in the L2 that has been
  * stalled for 1024 cycles to verify that its hazard condition still exists.
+ * Disable clean/evict push to external by setting L2ACTLR[3].
  */
-static void configure_l2actlr(void)
+static void configure_l2_actlr(void)
 {
 	uint32_t val;
 
-	/* Read MIDR for Primary Part Number */
-	mrc_midr(val);
-	val = (val >> 4);
-	val &= 0xf;
-
-	/* L2ACTLR[7]: Enable hazard detect timeout for A15 */
-	if (val == 0xf) {
-		mrc_l2_aux_ctlr(val);
-		val |= (1 << 7);
-		mcr_l2_aux_ctlr(val);
-	}
+	mrc_l2_aux_ctlr(val);
+	val |= (1 << 27);
+	val |= (1 << 7);
+	val |= (1 << 3);
+	mcr_l2_aux_ctlr(val);
 }
 
 /*
@@ -122,7 +138,16 @@ static void low_power_start(void)
 
 	/* Set the CPU to SVC32 mode */
 	svc32_mode_en();
-	configure_l2actlr();
+
+	/* Read MIDR for Primary Part Number */
+	mrc_midr(val);
+	val = (val >> 4);
+	val &= 0xf;
+
+	if (val == 0xf) {
+		configure_l2_ctlr();
+		configure_l2_actlr();
+	}
 
 	/* Invalidate L1 & TLB */
 	val = 0x0;
@@ -175,7 +200,7 @@ static void power_down_core(void)
 static void secondary_cores_configure(void)
 {
 	/* Setup L2 cache */
-	configure_l2actlr();
+	configure_l2_ctlr();
 
 	/* Clear secondary boot iRAM base */
 	writel(0x0, (CONFIG_EXYNOS_RELOCATE_CODE_BASE + 0x1C));
arch/arm/cpu/armv7/exynos/soc.c +0 -0
index 7268b9b..ea201e7 100644

arch/arm/cpu/armv7/exynos/soc.c line 13

Quoted 4 lines
arch/arm/cpu/armv7/exynos/soc.c +1 -0
@@ -10,8 +10,10 @@
 #include <asm/system.h>
 
 enum l2_cache_params {
+#ifndef CONFIG_EXYNOS5420

Please don't use ifdef.

Quoted 13 lines
arch/arm/cpu/armv7/exynos/soc.c +2 -0
 	CACHE_TAG_RAM_SETUP = (1 << 9),
 	CACHE_DATA_RAM_SETUP = (1 << 5),
+#endif
 	CACHE_TAG_RAM_LATENCY = (2 << 6),
 	CACHE_DATA_RAM_LATENCY = (2 << 0)
 };
@@ -39,10 +41,15 @@ static void exynos5_set_l2cache_params(void)
 
 	asm volatile("mrc p15, 1, %0, c9, c0, 2\n" : "=r"(val));
 
+#ifndef CONFIG_EXYNOS5420
 	val |= CACHE_TAG_RAM_SETUP |

arch/arm/cpu/armv7/exynos/soc.c static void exynos5_set_l2cache_params(void) · line 55

Quoted 10 lines
arch/arm/cpu/armv7/exynos/soc.c +4 -0
 		CACHE_DATA_RAM_SETUP |
 		CACHE_TAG_RAM_LATENCY |
 		CACHE_DATA_RAM_LATENCY;
+#else
+	val |= CACHE_TAG_RAM_LATENCY |
+		CACHE_DATA_RAM_LATENCY;
+#endif
 
 	asm volatile("mcr p15, 1, %0, c9, c0, 2\n" : : "r"(val));
 

Thanks,
Minkyu Kang.

#12 lore raw

PATCH v2 9/11 Exynos542x: Fix secondary core booting for thumb

In reply to Akshay Saraswat

When compiled SPL for Thumb secondary cores failed to boot at the kernel boot up. Only one core came up out of 4. This was happening because the code relocated to the address 0x02073000 by the primary core was an ARM asm code which was executed by the secondary cores as if it was a thumb code.
This patch fixes the issue of secondary cores considering relocated code as Thumb instructions and not ARM instructions by jumping to the relocated with the help of "bx" ARM instruction. "bx" instruction changes the 5th bit of CPSR which allows execution unit to consider the following instructions as ARM instructions.

---
Changes since v1:
- Added Reviewed-by & Tested-by.

 arch/arm/cpu/armv7/exynos/lowlevel_init.c | 2 +-
 arch/arm/include/asm/arch-exynos/system.h | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/exynos/lowlevel_init.c +1 -1
index 9892e6b..3fbaaf3 100644
@@ -111,7 +111,7 @@ static void secondary_cpu_start(void)
 {
 	enable_smp();
 	svc32_mode_en();
-	set_pc(CONFIG_EXYNOS_RELOCATE_CODE_BASE);
+	branch_bx(CONFIG_EXYNOS_RELOCATE_CODE_BASE);
 }
 
 /*
arch/arm/include/asm/arch-exynos/system.h +3 -0
index 86903c3..a9fd5e6 100644
@@ -75,6 +75,9 @@ struct exynos5_sysreg {
 /* Set program counter with the given value */
 #define set_pc(x) __asm__ __volatile__ ("mov     pc, %0\n\t" : : "r"(x))
 
+/* Branch to the given location */
+#define branch_bx(x) __asm__ __volatile__ ("bx	%0\n\t" : : "r"(x))
+
 /* Read Main Id register */
 #define mrc_midr(x) __asm__ __volatile__	\
 			("mrc     p15, 0, %0, c0, c0, 0\n\t" : "=r"(x) : )
Signature · 1 line
1.9.1
#13 lore raw

PATCH v2 10/11 Exynos542x: Make A7s boot with thumb-mode U-Boot on warm reset

In reply to Akshay Saraswat

On warm reset, all cores jump to the low_power_start function because iRAM data is retained and because while executing iROM code all cores find the jump flag 0x02020028 set. In low_power_start, cores check the reset status and if true they clear the jump flag and jump back to 0x0.

The A7 cores do jump to 0x0 but consider following instructions as a Thumb instructions which in turn makes them loop inside the iROM code instead of jumping to power_down_core.

This issue is fixed by replacing the "mov pc" instruction with a "bx" instruction which switches state along with the jump to make the execution unit consider the branch target as an ARM instruction.

---
Changes since v1:
- Added Reviewed-by & Tested-by.

 arch/arm/cpu/armv7/exynos/lowlevel_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/cpu/armv7/exynos/lowlevel_init.c +1 -1
index 3fbaaf3..e9e3cb7 100644
@@ -125,7 +125,7 @@ static void low_power_start(void)
 	reg_val = readl(EXYNOS5420_SPARE_BASE);
 	if (reg_val != CPU_RST_FLAG_VAL) {
 		writel(0x0, CONFIG_LOWPOWER_FLAG);
-		set_pc(0x0);
+		branch_bx(0x0);
 	}
 
 	reg_val = readl(CONFIG_PHY_IRAM_BASE + 0x4);
Signature · 1 line
1.9.1
#14 lore raw

PATCH v2 11/11 Exynos: Fix L2 cache timings on Exynos5420 and Exynos5800

In reply to Akshay Saraswat

From: Doug Anderson <[email protected]>

It was found that the L2 cache timings that we had before could cause freezes and hangs. We should make things more robust with better timings. Currently the production ChromeOS kernel applies these timings, but it's nice to fixup firmware too (and upstream probably won't take our kernel hacks).

This also provides a big cleanup of the L2 cache init code avoiding some duplication. The way things used to work:
* low_power_start() was installed by the SPL (both at boot and resume time) and left resident in iRAM for the kernel to use when bringing up additional CPUs. It used configure_l2_ctlr() and configure_l2_actlr() when it detected it was on an A15. This was needed (despite the L2 cache registers being shared among all A15s) because we might have been the first man in after the whole A15 cluster was shutdown.
* secondary_cores_configure() was called on at boot time and at resume time. Strangely this called configure_l2_ctlr() but not configure_l2_actlr() which was almost certainly wrong. Given that we'll call both (see next bullet) later in the boot process it didn't matter for normal boot, but I guess this is how L2 cache settings got set on 5420/5800 (but not 5250?) at resume time.
* exynos5_set_l2cache_params() was called as part of cache enablement. This should happen at boot time (normally in the SPL except for USB boot where it happens in main U-Boot).

Note that the old code wasn't setting ECC/parity in the cache enablement code but we happened to get it anyway because we'd call secondary_cores_configure() at boot time. For resume time we'd get it anyway when the 2nd A15 core came up.

Let's make this a whole lot simpler. Now we always set these parameters in the same place for all boots and use the same code for setting up secondary CPUs.

Intended net effects of this change (other than cleanup):
* Timings go from before:

    data: 0 cycle setup, 3 cycles (0x2) latency
    tag:  0 cycle setup, 3 cycles (0x2) latency
  after:
    data: 1 cycle setup, 4 cycles (0x3) latency
    tag:  1 cycle setup, 4 cycles (0x3) latency

* L2ACTLR is properly initted on 5420/5800 in all cases.

One note is that we're still relying on luck to keep low_power_start() working. The compiler is being nice and not storing anything on the stack.

Another note is that on its own this patch won't help to fix cache settings in an RW U-Boot update where we still have the RO SPL. The plan for that is:
* Have RW U-Boot re-init the cache right before calling the kernel (after it has turned the L2 cache off). This is why the functions are in a header file instead of lowlevel_init.c.

* Have the kernel save the L2 cache settings of the boot CPU and apply them to all other CPUs. We get a little lucky here because the old code was using "|=" to modify the registers and all of the bits that it's setting are also present in the new settings (!). That means that when the 2nd CPU in the A15 cluster comes up it doesn't actually mess up the settings of the 1st CPU in the A15 cluster. An alternative option is to have the kernel write its own low_power_start() code.

---
Changes since v1:
- Fixed compilation error for snow build.

 arch/arm/cpu/armv7/exynos/common_setup.h  | 55 +++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7/exynos/lowlevel_init.c | 55 +++++++++----------------------
 arch/arm/cpu/armv7/exynos/soc.c           | 51 ----------------------------
 arch/arm/include/asm/arch-exynos/system.h |  2 --
 4 files changed, 70 insertions(+), 93 deletions(-)
arch/arm/cpu/armv7/exynos/common_setup.h +55 -0
index e6318c0..4c00186 100644
@@ -23,6 +23,8 @@
  * MA 02111-1307 USA
  */
 
+#include <asm/arch/system.h>
+
 #define DMC_OFFSET	0x10000
 
 /*
@@ -43,3 +45,56 @@ void system_clock_init(void);
 int do_lowlevel_init(void);
 
 void sdelay(unsigned long);
+
+enum l2_cache_params {
+	CACHE_ECC_AND_PARITY = (1 << 21),
+	CACHE_TAG_RAM_SETUP = (1 << 9),
+	CACHE_DATA_RAM_SETUP = (1 << 5),
+#ifndef CONFIG_EXYNOS5420
+	CACHE_TAG_RAM_LATENCY = (2 << 6),  /* 5250 */
+	CACHE_DATA_RAM_LATENCY = (2 << 0),
+#else
+	CACHE_TAG_RAM_LATENCY = (3 << 6),  /* 5420 and 5800 */
+	CACHE_DATA_RAM_LATENCY = (3 << 0),
+#endif
+};
+
+#ifndef CONFIG_SYS_L2CACHE_OFF
+/*
+ * Configure L2CTLR to get timings that keep us from hanging/crashing.
+ *
+ * Must be inline here since low_power_start() is called without a
+ * stack (!).
+ */
+static inline void configure_l2_ctlr(void)
+{
+	uint32_t val;
+
+	mrc_l2_ctlr(val);
+	val |= CACHE_TAG_RAM_SETUP |
+		CACHE_DATA_RAM_SETUP |
+		CACHE_TAG_RAM_LATENCY |
+		CACHE_DATA_RAM_LATENCY |
+		CACHE_ECC_AND_PARITY;
+	mcr_l2_ctlr(val);
+}
+
+/*
+ * Configure L2ACTLR.
+ *
+ * Must be inline here since low_power_start() is called without a
+ * stack (!).
+ */
+static inline void configure_l2_actlr(void)
+{
+#ifdef CONFIG_EXYNOS5420
+	uint32_t val;
+
+	mrc_l2_aux_ctlr(val);
+	val |= (1 << 27) |	/* Prevents stopping the L2 logic clock */
+		(1 << 7) |	/* Enable hazard detect timeout for A15 */
+		(1 << 3);	/* Disable clean/evict push to external */
+	mcr_l2_aux_ctlr(val);
+#endif
+}
+#endif
arch/arm/cpu/armv7/exynos/lowlevel_init.c +15 -40

73 lines not on this page · raw message

arch/arm/cpu/armv7/exynos/soc.c +0 -51

60 lines not on this page · raw message

arch/arm/include/asm/arch-exynos/system.h +0 -2
index a9fd5e6..3ffb296 100644
@@ -37,7 +37,6 @@ struct exynos5_sysreg {
 
 #define USB20_PHY_CFG_HOST_LINK_EN	(1 << 0)
 
-#ifdef CONFIG_EXYNOS5420
 /*
  * Data Synchronization Barrier acts as a special kind of memory barrier.
  * No instruction in program order after this instruction executes until
@@ -125,7 +124,6 @@ struct exynos5_sysreg {
 /* Write L2 Auxilliary Control register */
 #define mcr_l2_aux_ctlr(x) __asm__ __volatile__	\
 			("mcr     p15, 1, %0, c15, c0, 0\n\t" : : "r"(x))
-#endif
 
 void set_usbhost_mode(unsigned int mode);
 void set_system_display_ctrl(void);
Signature · 1 line
1.9.1
#15 lore raw

PATCH v2 11/11 Exynos: Fix L2 cache timings on Exynos5420 and Exynos5800

Quoted 71 lines · Akshay Saraswat

From: Doug Anderson <[email protected]>

It was found that the L2 cache timings that we had before could cause freezes and hangs. We should make things more robust with better timings. Currently the production ChromeOS kernel applies these timings, but it's nice to fixup firmware too (and upstream probably won't take our kernel hacks).

This also provides a big cleanup of the L2 cache init code avoiding some duplication. The way things used to work:
* low_power_start() was installed by the SPL (both at boot and resume time) and left resident in iRAM for the kernel to use when bringing up additional CPUs. It used configure_l2_ctlr() and configure_l2_actlr() when it detected it was on an A15. This was needed (despite the L2 cache registers being shared among all A15s) because we might have been the first man in after the whole A15 cluster was shutdown.
* secondary_cores_configure() was called on at boot time and at resume time. Strangely this called configure_l2_ctlr() but not configure_l2_actlr() which was almost certainly wrong. Given that we'll call both (see next bullet) later in the boot process it didn't matter for normal boot, but I guess this is how L2 cache settings got set on 5420/5800 (but not 5250?) at resume time.
* exynos5_set_l2cache_params() was called as part of cache enablement. This should happen at boot time (normally in the SPL except for USB boot where it happens in main U-Boot).

Note that the old code wasn't setting ECC/parity in the cache enablement code but we happened to get it anyway because we'd call secondary_cores_configure() at boot time. For resume time we'd get it anyway when the 2nd A15 core came up.

Let's make this a whole lot simpler. Now we always set these parameters in the same place for all boots and use the same code for setting up secondary CPUs.

Intended net effects of this change (other than cleanup):
* Timings go from before:

    data: 0 cycle setup, 3 cycles (0x2) latency
    tag:  0 cycle setup, 3 cycles (0x2) latency
  after:
    data: 1 cycle setup, 4 cycles (0x3) latency
    tag:  1 cycle setup, 4 cycles (0x3) latency

* L2ACTLR is properly initted on 5420/5800 in all cases.

One note is that we're still relying on luck to keep low_power_start() working. The compiler is being nice and not storing anything on the stack.

Another note is that on its own this patch won't help to fix cache settings in an RW U-Boot update where we still have the RO SPL. The plan for that is:
* Have RW U-Boot re-init the cache right before calling the kernel (after it has turned the L2 cache off). This is why the functions are in a header file instead of lowlevel_init.c.

* Have the kernel save the L2 cache settings of the boot CPU and apply them to all other CPUs. We get a little lucky here because the old code was using "|=" to modify the registers and all of the bits that it's setting are also present in the new settings (!). That means that when the 2nd CPU in the A15 cluster comes up it doesn't actually mess up the settings of the 1st CPU in the A15 cluster. An alternative option is to have the kernel write its own low_power_start() code.

---
Changes since v1:
- Fixed compilation error for snow build.

Quoted 5 lines
 arch/arm/cpu/armv7/exynos/common_setup.h  | 55 +++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7/exynos/lowlevel_init.c | 55 +++++++++----------------------
 arch/arm/cpu/armv7/exynos/soc.c           | 51 ----------------------------
 arch/arm/include/asm/arch-exynos/system.h |  2 --
 4 files changed, 70 insertions(+), 93 deletions(-)