Skip to contentSkip to conversation

ARM: shmobile: SMP Cortex-A9 SCU rework

PATCH New Magnus Damm 4 participants 13 messages Feb 13, 2013 – Feb 18, 2013

Subsystems (4)
lore
Share & tools
lore

Magnus Damm

author maintainer
#0 lore raw

cover ARM: shmobile: SMP Cortex-A9 SCU rework

ARM: shmobile: SMP Cortex-A9 SCU rework

[PATCH 01/06] ARM: shmobile: Kill off sh73a0 scu_base_addr() function [PATCH 02/06] ARM: shmobile: Kill off r8a7779 scu_base_addr() function [PATCH 03/06] ARM: shmobile: Rework EMEV2 scu_base variable [PATCH 04/06] ARM: shmobile: Move headsmp-sh73a0.S to headsmp-scu.S [PATCH 05/06] ARM: shmobile: Common shmobile_scu_base in headsmp-scu.S [PATCH 06/06] ARM: shmobile: Update EMEV2 to use scu_power_mode()

Rework the EMEV2 SMP code to make use of common scu_power_mode() code together with a shared shmobile_scu_base and early SCU setup code in headsmp-scu.S.

The patches are known to build for sh73a0, r8a7779 and EMEV2.

Note that the code has only been tested on the KZM9D/EMEV2 board, and because of that changes to other boards have been kept at a minimum. Next target after this is to update the r8a7779 SMP/SCU code to make use of scu_base_addr(), but that requires hardware access for testing.

---

No known dependencies apart from previous SMP cleanup series "[PATCH 00/06] ARM: shmobile: Trivial SMP cleanups" Written against -next in renesas.git.

 arch/arm/mach-shmobile/Makefile              |    6 +-
 arch/arm/mach-shmobile/headsmp-scu.S         |   58 +++++++++++++++++++++++++
 arch/arm/mach-shmobile/headsmp-sh73a0.S      |   50 ----------------------
 arch/arm/mach-shmobile/include/mach/common.h |    3 -
 arch/arm/mach-shmobile/smp-emev2.c           |   59 +++++++-------------------
 arch/arm/mach-shmobile/smp-r8a7779.c         |   19 +++-----
 arch/arm/mach-shmobile/smp-sh73a0.c          |   26 +++++------
 7 files changed, 98 insertions(+), 123 deletions(-)
author maintainer
#1 lore raw

PATCH 1/6 ARM: shmobile: Kill off sh73a0 scu_base_addr() function

From: Magnus Damm <[email protected]>

Replace scu_base_addr() with a static shmobile_scu_base variable and introduce SH73A0_SCU_BASE.

Later in the series the shmobile_scu_base variable will be made into a global variable so this is preparation only.

---

 arch/arm/mach-shmobile/smp-sh73a0.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
arch/arm/mach-shmobile/smp-sh73a0.c +10 -10
@@ -39,13 +39,12 @@
 
 #define PSTR_SHUTDOWN_MODE	3
 
-static void __iomem *scu_base_addr(void)
-{
-	return (void __iomem *)0xf0000000;
-}
+#define SH73A0_SCU_BASE IOMEM(0xf0000000)
+
+static void __iomem *shmobile_scu_base;
 
 #ifdef CONFIG_HAVE_ARM_TWD
-static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, 0xf0000600, 29);
+static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, SH73A0_SCU_BASE + 0x600, 29);
 void __init sh73a0_register_twd(void)
 {
 	twd_local_timer_register(&twd_local_timer);
@@ -71,21 +70,22 @@ static int __cpuinit sh73a0_boot_seconda
 
 static void __init sh73a0_smp_prepare_cpus(unsigned int max_cpus)
 {
-	scu_enable(scu_base_addr());
+	scu_enable(shmobile_scu_base);
 
 	/* Map the reset vector (in headsmp-sh73a0.S) */
 	__raw_writel(0, APARMBAREA);      /* 4k */
 	__raw_writel(__pa(sh73a0_secondary_vector), SBAR);
 
 	/* enable cache coherency on booting CPU */
-	scu_power_mode(scu_base_addr(), SCU_PM_NORMAL);
+	scu_power_mode(shmobile_scu_base, SCU_PM_NORMAL);
 }
 
 static void __init sh73a0_smp_init_cpus(void)
 {
-	unsigned int ncores = scu_get_core_count(scu_base_addr());
+	/* setup sh73a0 specific SCU base */
+	shmobile_scu_base = SH73A0_SCU_BASE;
 
-	shmobile_smp_init_cpus(ncores);
+	shmobile_smp_init_cpus(scu_get_core_count(shmobile_scu_base));
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
@@ -121,7 +121,7 @@ static void sh73a0_cpu_die(unsigned int
 	flush_cache_all();
 
 	/* Set power off mode. This takes the CPU out of the MP cluster */
-	scu_power_mode(scu_base_addr(), SCU_PM_POWEROFF);
+	scu_power_mode(shmobile_scu_base, SCU_PM_POWEROFF);
 
 	/* Enter shutdown mode */
 	cpu_do_idle();
#2 lore raw

PATCH 1/6 ARM: shmobile: Kill off sh73a0 scu_base_addr() function

arch/arm/mach-shmobile/smp-sh73a0.c line 47

Quoted 8 lines · Magnus Damm
arch/arm/mach-shmobile/smp-sh73a0.c +4 -2
-}
+#define SH73A0_SCU_BASE IOMEM(0xf0000000)
+
+static void __iomem *shmobile_scu_base;
 
 #ifdef CONFIG_HAVE_ARM_TWD
-static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, 0xf0000600, 29);
+static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, SH73A0_SCU_BASE + 0x600, 29);

This is causing a build warning in linux-next:

arch/arm/mach-shmobile/smp-sh73a0.c:45:15: warning: initialization makes integer from pointer without a cast [enabled by default] arch/arm/mach-shmobile/smp-sh73a0.c:45:15: warning: (near initialization for 'twd_local_timer.res[0].start') [enabled by default] arch/arm/mach-shmobile/smp-sh73a0.c:45:15: warning: initialization makes integer from pointer without a cast [enabled by default] /arch/arm/mach-shmobile/smp-sh73a0.c:45:15: warning: (near initialization for 'twd_local_timer.res[0].end') [enabled by default]

The problem is that DEFINE_TWD_LOCAL_TIMER expects a physical address to pass into ioremap(), while you are passing an __iomem token.

Arnd

author maintainer
#3 lore raw

PATCH 1/6 ARM: shmobile: Kill off sh73a0 scu_base_addr() function

Hi Arnd,

Quoted 13 lines · Arnd Bergmann

arch/arm/mach-shmobile/smp-sh73a0.c line 47

Quoted 8 lines · Magnus Damm
arch/arm/mach-shmobile/smp-sh73a0.c +4 -2
-}
+#define SH73A0_SCU_BASE IOMEM(0xf0000000)
+
+static void __iomem *shmobile_scu_base;
 
 #ifdef CONFIG_HAVE_ARM_TWD
-static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, 0xf0000600, 29);
+static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, SH73A0_SCU_BASE + 0x600, 29);

This is causing a build warning in linux-next:

Quoted 8 lines

arch/arm/mach-shmobile/smp-sh73a0.c:45:15: warning: initialization makes integer from pointer without a cast [enabled by default] arch/arm/mach-shmobile/smp-sh73a0.c:45:15: warning: (near initialization for 'twd_local_timer.res[0].start') [enabled by default] arch/arm/mach-shmobile/smp-sh73a0.c:45:15: warning: initialization makes integer from pointer without a cast [enabled by default] /arch/arm/mach-shmobile/smp-sh73a0.c:45:15: warning: (near initialization for 'twd_local_timer.res[0].end') [enabled by default]

The problem is that DEFINE_TWD_LOCAL_TIMER expects a physical address to pass into ioremap(), while you are passing an __iomem token.

Thanks, will fix up.

/ magnus

author maintainer
#4 lore raw

PATCH 2/6 ARM: shmobile: Kill off r8a7779 scu_base_addr() function

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Replace scu_base_addr() with a static shmobile_scu_base variable and introduce R8A7779_SCU_BASE.

Later in the series the shmobile_scu_base variable will be made into a global variable so this is preparation only.

---

 arch/arm/mach-shmobile/smp-r8a7779.c |   17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
arch/arm/mach-shmobile/smp-r8a7779.c +8 -9
@@ -31,6 +31,9 @@
 #include <asm/smp_twd.h>
 
 #define AVECR IOMEM(0xfe700040)
+#define R8A7779_SCU_BASE IOMEM(0xf0000000)
+
+static void __iomem *shmobile_scu_base;
 
 static struct r8a7779_pm_ch r8a7779_ch_cpu1 = {
 	.chan_offs = 0x40, /* PWRSR0 .. PWRER0 */
@@ -56,11 +59,6 @@ static struct r8a7779_pm_ch *r8a7779_ch_
 	[3] = &r8a7779_ch_cpu3,
 };
 
-static void __iomem *scu_base_addr(void)
-{
-	return (void __iomem *)0xf0000000;
-}
-
 static DEFINE_SPINLOCK(scu_lock);
 static unsigned long tmp;
 
@@ -75,7 +73,7 @@ void __init r8a7779_register_twd(void)
 
 static void modify_scu_cpu_psr(unsigned long set, unsigned long clr)
 {
-	void __iomem *scu_base = scu_base_addr();
+	void __iomem *scu_base = shmobile_scu_base;
 
 	spin_lock(&scu_lock);
 	tmp = __raw_readl(scu_base + 8);
@@ -153,7 +151,7 @@ static void __init r8a7779_smp_prepare_c
 {
 	int cpu = cpu_logical_map(0);
 
-	scu_enable(scu_base_addr());
+	scu_enable(shmobile_scu_base);
 
 	/* Map the reset vector (in headsmp.S) */
 	__raw_writel(__pa(shmobile_secondary_vector), AVECR);
@@ -171,9 +169,10 @@ static void __init r8a7779_smp_prepare_c
 
 static void __init r8a7779_smp_init_cpus(void)
 {
-	unsigned int ncores = scu_get_core_count(scu_base_addr());
+	/* setup r8a7779 specific SCU base */
+	shmobile_scu_base = R8A7779_SCU_BASE;
 
-	shmobile_smp_init_cpus(ncores);
+	shmobile_smp_init_cpus(scu_get_core_count(shmobile_scu_base));
 }
 
 struct smp_operations r8a7779_smp_ops  __initdata = {
author maintainer
#5 lore raw

PATCH 3/6 ARM: shmobile: Rework EMEV2 scu_base variable

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Rename the static scu_base variable into shmobile_scu_base.

Later in the series the shmobile_scu_base variable will be made into a global variable so this is preparation only.

---

 arch/arm/mach-shmobile/smp-emev2.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
arch/arm/mach-shmobile/smp-emev2.c +8 -7
@@ -32,8 +32,9 @@
 
 #define EMEV2_SCU_BASE 0x1e000000
 
+static void __iomem *shmobile_scu_base;
+
 static DEFINE_SPINLOCK(scu_lock);
-static void __iomem *scu_base;
 
 static void modify_scu_cpu_psr(unsigned long set, unsigned long clr)
 {
@@ -42,10 +43,10 @@ static void modify_scu_cpu_psr(unsigned
 	/* we assume this code is running on a different cpu
 	 * than the one that is changing coherency setting */
 	spin_lock(&scu_lock);
-	tmp = readl(scu_base + 8);
+	tmp = readl(shmobile_scu_base + 8);
 	tmp &= ~clr;
 	tmp |= set;
-	writel(tmp, scu_base + 8);
+	writel(tmp, shmobile_scu_base + 8);
 	spin_unlock(&scu_lock);
 
 }
@@ -70,7 +71,7 @@ static void __init emev2_smp_prepare_cpu
 {
 	int cpu = cpu_logical_map(0);
 
-	scu_enable(scu_base);
+	scu_enable(shmobile_scu_base);
 
 	/* Tell ROM loader about our vector (in headsmp.S) */
 	emev2_set_boot_vector(__pa(shmobile_secondary_vector));
@@ -83,12 +84,12 @@ static void __init emev2_smp_init_cpus(v
 {
 	unsigned int ncores;
 
-	if (!scu_base) {
-		scu_base = ioremap(EMEV2_SCU_BASE, PAGE_SIZE);
+	if (!shmobile_scu_base) {
+		shmobile_scu_base = ioremap(EMEV2_SCU_BASE, PAGE_SIZE);
 		emev2_clock_init(); /* need ioremapped SMU */
 	}
 
-	ncores = scu_base ? scu_get_core_count(scu_base) : 1;
+	ncores = shmobile_scu_base ? scu_get_core_count(shmobile_scu_base) : 1;
 
 	shmobile_smp_init_cpus(ncores);
 }
author maintainer
#6 lore raw

PATCH 4/6 ARM: shmobile: Move headsmp-sh73a0.S to headsmp-scu.S

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Rename headsmp-sh73a0.S into headsmp-scu.S and introduce shmobile_secondary_vector_scu().

The goal is to be able to share the function above between all mach-shmobile SoCs that use SCU for SMP. So far only sh73a0 use this.

At this time the SCU base address is still hard coded in headsmp-scu.S to 0xf0000000, but this will be changed in the future.

---

Hum, perhaps git can generate a better patch with "rename" information?

 arch/arm/mach-shmobile/Makefile              |    2 -
 arch/arm/mach-shmobile/headsmp-scu.S         |   50 ++++++++++++++++++++++++++
 arch/arm/mach-shmobile/headsmp-sh73a0.S      |   50 --------------------------
 arch/arm/mach-shmobile/include/mach/common.h |    2 -
 arch/arm/mach-shmobile/smp-sh73a0.c          |    4 +-
 5 files changed, 54 insertions(+), 54 deletions(-)
arch/arm/mach-shmobile/Makefile +1 -1
@@ -15,7 +15,7 @@ obj-$(CONFIG_ARCH_EMEV2)	+= setup-emev2.
 # SMP objects
 smp-y				:= platsmp.o headsmp.o
 smp-$(CONFIG_HOTPLUG_CPU)	+= hotplug.o
-smp-$(CONFIG_ARCH_SH73A0)	+= smp-sh73a0.o headsmp-sh73a0.o
+smp-$(CONFIG_ARCH_SH73A0)	+= smp-sh73a0.o headsmp-scu.o
 smp-$(CONFIG_ARCH_R8A7779)	+= smp-r8a7779.o
 smp-$(CONFIG_ARCH_EMEV2)	+= smp-emev2.o
 
arch/arm/mach-shmobile/headsmp-scu.S new file +50 -0

50 lines not on this page · raw message

arch/arm/mach-shmobile/headsmp-sh73a0.S deleted +0 -50

50 lines not on this page · raw message

arch/arm/mach-shmobile/include/mach/common.h +1 -1
@@ -8,6 +8,7 @@ extern void shmobile_setup_delay(unsigne
 struct twd_local_timer;
 extern void shmobile_setup_console(void);
 extern void shmobile_secondary_vector(void);
+extern void shmobile_secondary_vector_scu(void);
 struct clk;
 extern int shmobile_clk_init(void);
 extern void shmobile_handle_irq_intc(struct pt_regs *);
@@ -45,7 +46,6 @@ extern void sh73a0_add_standard_devices_
 extern void sh73a0_clock_init(void);
 extern void sh73a0_pinmux_init(void);
 extern void sh73a0_pm_init(void);
-extern void sh73a0_secondary_vector(void);
 extern struct clk sh73a0_extal1_clk;
 extern struct clk sh73a0_extal2_clk;
 extern struct clk sh73a0_extcki_clk;
arch/arm/mach-shmobile/smp-sh73a0.c +2 -2
@@ -80,9 +80,9 @@ static void __init sh73a0_smp_prepare_cp
 {
 	scu_enable(scu_base_addr());
 
-	/* Map the reset vector (in headsmp-sh73a0.S) */
+	/* Map the reset vector (in headsmp-scu.S) */
 	__raw_writel(0, APARMBAREA);      /* 4k */
-	__raw_writel(__pa(sh73a0_secondary_vector), SBAR);
+	__raw_writel(__pa(shmobile_secondary_vector_scu), SBAR);
 
 	/* enable cache coherency on booting CPU */
 	scu_power_mode(scu_base_addr(), SCU_PM_NORMAL);
author maintainer
#7 lore raw

PATCH 5/6 ARM: shmobile: Common shmobile_scu_base in headsmp-scu.S

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Update the code in headsmp-scu.S to use a global shmobile_scu_base variable both for convenient SCU base address storage and for the early SCU setup code in shmobile_secondary_vector_scu.

With this patch applied r8a7779, sh73a0 and EMEV2 all make use of the global shmobile_scu_base variable. However only sh73a0 makes use of the SCU bring up code in shmobile_secondary_vector_scu.

---

 arch/arm/mach-shmobile/Makefile              |    4 ++--
 arch/arm/mach-shmobile/headsmp-scu.S         |    8 +++++++-
 arch/arm/mach-shmobile/include/mach/common.h |    1 +
 arch/arm/mach-shmobile/smp-emev2.c           |    2 --
 arch/arm/mach-shmobile/smp-r8a7779.c         |    2 --
 arch/arm/mach-shmobile/smp-sh73a0.c          |    2 --
 6 files changed, 10 insertions(+), 9 deletions(-)
arch/arm/mach-shmobile/Makefile +2 -2
@@ -16,8 +16,8 @@ obj-$(CONFIG_ARCH_EMEV2)	+= setup-emev2.
 smp-y				:= platsmp.o headsmp.o
 smp-$(CONFIG_HOTPLUG_CPU)	+= hotplug.o
 smp-$(CONFIG_ARCH_SH73A0)	+= smp-sh73a0.o headsmp-scu.o
-smp-$(CONFIG_ARCH_R8A7779)	+= smp-r8a7779.o
-smp-$(CONFIG_ARCH_EMEV2)	+= smp-emev2.o
+smp-$(CONFIG_ARCH_R8A7779)	+= smp-r8a7779.o headsmp-scu.o
+smp-$(CONFIG_ARCH_EMEV2)	+= smp-emev2.o headsmp-scu.o
 
 # IRQ objects
 obj-$(CONFIG_ARCH_SH7372)	+= entry-intc.o
arch/arm/mach-shmobile/headsmp-scu.S +7 -1
@@ -39,7 +39,8 @@ ENTRY(shmobile_secondary_vector_scu)
 	mrc     p15, 0, r0, c0, c0, 5	@ read MIPDR
 	and	r0, r0, #3		@ mask out cpu ID
 	lsl	r0, r0, #3		@ we will shift by cpu_id * 8 bits
-	mov	r1, #0xf0000000		@ SCU base address
+	ldr	r1, =shmobile_scu_base
+	ldr	r1, [r1]		@ SCU base address
 	ldr	r2, [r1, #8]		@ SCU Power Status Register
 	mov	r3, #3
 	bic	r2, r2, r3, lsl r0	@ Clear bits of our CPU (Run Mode)
@@ -48,3 +49,8 @@ ENTRY(shmobile_secondary_vector_scu)
 	ldr	pc, 1f
 1:	.long shmobile_invalidate_start - PAGE_OFFSET + PLAT_PHYS_OFFSET
 ENDPROC(shmobile_secondary_vector_scu)
+
+	.text
+	.globl	shmobile_scu_base
+shmobile_scu_base:
+	.space	4
arch/arm/mach-shmobile/include/mach/common.h +1 -0
@@ -96,6 +96,7 @@ extern int shmobile_cpu_is_dead(unsigned
 static inline int shmobile_cpu_is_dead(unsigned int cpu) { return 1; }
 #endif
 
+extern void __iomem *shmobile_scu_base;
 extern void shmobile_smp_init_cpus(unsigned int ncores);
 
 static inline void __init shmobile_init_late(void)
arch/arm/mach-shmobile/smp-emev2.c +0 -2
@@ -32,8 +32,6 @@
 
 #define EMEV2_SCU_BASE 0x1e000000
 
-static void __iomem *shmobile_scu_base;
-
 static DEFINE_SPINLOCK(scu_lock);
 
 static void modify_scu_cpu_psr(unsigned long set, unsigned long clr)
arch/arm/mach-shmobile/smp-r8a7779.c +0 -2
@@ -33,8 +33,6 @@
 #define AVECR IOMEM(0xfe700040)
 #define R8A7779_SCU_BASE IOMEM(0xf0000000)
 
-static void __iomem *shmobile_scu_base;
-
 static struct r8a7779_pm_ch r8a7779_ch_cpu1 = {
 	.chan_offs = 0x40, /* PWRSR0 .. PWRER0 */
 	.chan_bit = 1, /* ARM1 */
arch/arm/mach-shmobile/smp-sh73a0.c +0 -2
@@ -41,8 +41,6 @@
 
 #define SH73A0_SCU_BASE IOMEM(0xf0000000)
 
-static void __iomem *shmobile_scu_base;
-
 #ifdef CONFIG_HAVE_ARM_TWD
 static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, SH73A0_SCU_BASE + 0x600, 29);
 void __init sh73a0_register_twd(void)
#8 lore raw

PATCH 5/6 ARM: shmobile: Common shmobile_scu_base in headsmp-scu.S

Hi,

this breaks the secondary CPU startup when I test it. I think you can't access shmobile_scu_address this way with the MMU still turned off.

But instead of

arch/arm/mach-shmobile/headsmp-scu.S ENTRY(shmobile_secondary_vector_scu) · line 43

Quoted 2 lines
arch/arm/mach-shmobile/headsmp-scu.S +2 -0
+       ldr     r1, =shmobile_scu_base
+       ldr     r1, [r1]                @ SCU base address

try

+ mrc p15, 4, r1, c15, c0, 0 @ get SCU base address

to get it from the coprocessor.

Cheers,

Bastian

2013/2/13 Magnus Damm <[email protected]>:

Quoted 104 lines

From: Magnus Damm <[email protected]>

Update the code in headsmp-scu.S to use a global shmobile_scu_base variable both for convenient SCU base address storage and for the early SCU setup code in shmobile_secondary_vector_scu.

With this patch applied r8a7779, sh73a0 and EMEV2 all make use of the global shmobile_scu_base variable. However only sh73a0 makes use of the SCU bring up code in shmobile_secondary_vector_scu.

---

 arch/arm/mach-shmobile/Makefile              |    4 ++--
 arch/arm/mach-shmobile/headsmp-scu.S         |    8 +++++++-
 arch/arm/mach-shmobile/include/mach/common.h |    1 +
 arch/arm/mach-shmobile/smp-emev2.c           |    2 --
 arch/arm/mach-shmobile/smp-r8a7779.c         |    2 --
 arch/arm/mach-shmobile/smp-sh73a0.c          |    2 --
 6 files changed, 10 insertions(+), 9 deletions(-)
arch/arm/mach-shmobile/Makefile 2013-02-13 21:54:34.000000000 +0900 renamed from arch/arm/mach-shmobile/Makefile +2 -2
@@ -16,8 +16,8 @@ obj-$(CONFIG_ARCH_EMEV2)      += setup-emev2.
 smp-y                          := platsmp.o headsmp.o
 smp-$(CONFIG_HOTPLUG_CPU)      += hotplug.o
 smp-$(CONFIG_ARCH_SH73A0)      += smp-sh73a0.o headsmp-scu.o
-smp-$(CONFIG_ARCH_R8A7779)     += smp-r8a7779.o
-smp-$(CONFIG_ARCH_EMEV2)       += smp-emev2.o
+smp-$(CONFIG_ARCH_R8A7779)     += smp-r8a7779.o headsmp-scu.o
+smp-$(CONFIG_ARCH_EMEV2)       += smp-emev2.o headsmp-scu.o
 
 # IRQ objects
 obj-$(CONFIG_ARCH_SH7372)      += entry-intc.o
arch/arm/mach-shmobile/headsmp-scu.S 2013-02-13 21:54:27.000000000 +0900 renamed from arch/arm/mach-shmobile/headsmp-scu.S +7 -1
@@ -39,7 +39,8 @@ ENTRY(shmobile_secondary_vector_scu)
        mrc     p15, 0, r0, c0, c0, 5   @ read MIPDR
        and     r0, r0, #3              @ mask out cpu ID
        lsl     r0, r0, #3              @ we will shift by cpu_id * 8 bits
-       mov     r1, #0xf0000000         @ SCU base address
+       ldr     r1, =shmobile_scu_base
+       ldr     r1, [r1]                @ SCU base address
        ldr     r2, [r1, #8]            @ SCU Power Status Register
        mov     r3, #3
        bic     r2, r2, r3, lsl r0      @ Clear bits of our CPU (Run Mode)
@@ -48,3 +49,8 @@ ENTRY(shmobile_secondary_vector_scu)
        ldr     pc, 1f
 1:     .long shmobile_invalidate_start - PAGE_OFFSET + PLAT_PHYS_OFFSET
 ENDPROC(shmobile_secondary_vector_scu)
+
+       .text
+       .globl  shmobile_scu_base
+shmobile_scu_base:
+       .space  4
arch/arm/mach-shmobile/include/mach/common.h 2013-02-13 21:54:27.000000000 +0900 renamed from arch/arm/mach-shmobile/include/mach/common.h +1 -0
@@ -96,6 +96,7 @@ extern int shmobile_cpu_is_dead(unsigned
 static inline int shmobile_cpu_is_dead(unsigned int cpu) { return 1; }
 #endif
 
+extern void __iomem *shmobile_scu_base;
 extern void shmobile_smp_init_cpus(unsigned int ncores);
 
 static inline void __init shmobile_init_late(void)
arch/arm/mach-shmobile/smp-emev2.c 2013-02-13 21:54:27.000000000 +0900 renamed from arch/arm/mach-shmobile/smp-emev2.c +0 -2
@@ -32,8 +32,6 @@
 
 #define EMEV2_SCU_BASE 0x1e000000
 
-static void __iomem *shmobile_scu_base;
-
 static DEFINE_SPINLOCK(scu_lock);
 
 static void modify_scu_cpu_psr(unsigned long set, unsigned long clr)
arch/arm/mach-shmobile/smp-r8a7779.c 2013-02-13 21:54:27.000000000 +0900 renamed from arch/arm/mach-shmobile/smp-r8a7779.c +0 -2
@@ -33,8 +33,6 @@
 #define AVECR IOMEM(0xfe700040)
 #define R8A7779_SCU_BASE IOMEM(0xf0000000)
 
-static void __iomem *shmobile_scu_base;
-
 static struct r8a7779_pm_ch r8a7779_ch_cpu1 = {
        .chan_offs = 0x40, /* PWRSR0 .. PWRER0 */
        .chan_bit = 1, /* ARM1 */
arch/arm/mach-shmobile/smp-sh73a0.c 2013-02-13 21:54:27.000000000 +0900 renamed from arch/arm/mach-shmobile/smp-sh73a0.c +0 -3
@@ -41,8 +41,6 @@
 
 #define SH73A0_SCU_BASE IOMEM(0xf0000000)
 
-static void __iomem *shmobile_scu_base;
-
 #ifdef CONFIG_HAVE_ARM_TWD
 static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, SH73A0_SCU_BASE + 0x600, 29);
 void __init sh73a0_register_twd(void)
--

To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#9 lore raw

PATCH 5/6 ARM: shmobile: Common shmobile_scu_base in headsmp-scu.S

Hello Bastian,

Quoted 7 lines · Bastian Hecht

Hi,

this breaks the secondary CPU startup when I test it. I think you can't access shmobile_scu_address this way with the MMU still turned off.

But instead of

Quoted 8 lines

arch/arm/mach-shmobile/headsmp-scu.S ENTRY(shmobile_secondary_vector_scu) · line 43

Quoted 2 lines
arch/arm/mach-shmobile/headsmp-scu.S +2 -0
+       ldr     r1, =shmobile_scu_base
+       ldr     r1, [r1]                @ SCU base address

try

+ mrc p15, 4, r1, c15, c0, 0 @ get SCU base address

to get it from the coprocessor.

Thanks. Can you please let us know which platform you see this?

I've executed this on sh73a0 and KZM9G myself without any issues.

Could it be that you are powering down the power domain in your own code?

Thanks,

/ magnus

#10 lore raw

PATCH 5/6 ARM: shmobile: Common shmobile_scu_base in headsmp-scu.S

Hi,

2013/2/17 Magnus Damm <[email protected]>:

Quoted 17 lines

Hello Bastian,

Quoted 14 lines · Bastian Hecht

Hi,

this breaks the secondary CPU startup when I test it. I think you can't access shmobile_scu_address this way with the MMU still turned off.

But instead of

arch/arm/mach-shmobile/headsmp-scu.S ENTRY(shmobile_secondary_vector_scu) · line 43

Quoted 2 lines
arch/arm/mach-shmobile/headsmp-scu.S +2 -0
+       ldr     r1, =shmobile_scu_base
+       ldr     r1, [r1]                @ SCU base address

try

+ mrc p15, 4, r1, c15, c0, 0 @ get SCU base address

Quoted 7 lines
Quoted 1 line

to get it from the coprocessor.

Thanks. Can you please let us know which platform you see this?

I've executed this on sh73a0 and KZM9G myself without any issues.

Could it be that you are powering down the power domain in your own code?

I saw it on the current HEAD of the next branch using my KZM9G. I bisected it down to your commit. The problem appears right at boot time when the 2nd CPU should be brought up.

Thanks,

Bastian

Quoted 3 lines

Thanks,

/ magnus

author maintainer
#11 lore raw

PATCH 6/6 ARM: shmobile: Update EMEV2 to use scu_power_mode()

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Update the SMP code for EMEV2 to make use of the shared SCU function scu_power_mode() together with the early setup code in shmobile_secondary_vector_scu.

With this patch in place the secondary CPUs modify the SCU setting during early boot instead of letting other CPUs deal with the coherency setting before boot. In other words, we used to setup coherency before boot in emev2_boot_secondary() but that bit is now instead handled by the code in shmobile_secondary_vector_scu.

---

Tested on the EMEV2/KZM9D board.

 arch/arm/mach-shmobile/smp-emev2.c |   42 ++++++------------------------------
 1 file changed, 8 insertions(+), 34 deletions(-)
arch/arm/mach-shmobile/smp-emev2.c +8 -34
@@ -28,27 +28,9 @@
 #include <mach/emev2.h>
 #include <asm/smp_plat.h>
 #include <asm/smp_scu.h>
-#include <asm/cacheflush.h>
 
 #define EMEV2_SCU_BASE 0x1e000000
 
-static DEFINE_SPINLOCK(scu_lock);
-
-static void modify_scu_cpu_psr(unsigned long set, unsigned long clr)
-{
-	unsigned long tmp;
-
-	/* we assume this code is running on a different cpu
-	 * than the one that is changing coherency setting */
-	spin_lock(&scu_lock);
-	tmp = readl(shmobile_scu_base + 8);
-	tmp &= ~clr;
-	tmp |= set;
-	writel(tmp, shmobile_scu_base + 8);
-	spin_unlock(&scu_lock);
-
-}
-
 static void __cpuinit emev2_secondary_init(unsigned int cpu)
 {
 	gic_secondary_init(0);
@@ -56,36 +38,28 @@ static void __cpuinit emev2_secondary_in
 
 static int __cpuinit emev2_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
-	cpu = cpu_logical_map(cpu);
-
-	/* enable cache coherency */
-	modify_scu_cpu_psr(0, 3 << (cpu * 8));
-
-	arch_send_wakeup_ipi_mask(cpumask_of(cpu));
+	arch_send_wakeup_ipi_mask(cpumask_of(cpu_logical_map(cpu)));
 	return 0;
 }
 
 static void __init emev2_smp_prepare_cpus(unsigned int max_cpus)
 {
-	int cpu = cpu_logical_map(0);
-
 	scu_enable(shmobile_scu_base);
 
-	/* Tell ROM loader about our vector (in headsmp.S) */
-	emev2_set_boot_vector(__pa(shmobile_secondary_vector));
+	/* Tell ROM loader about our vector (in headsmp-scu.S) */
+	emev2_set_boot_vector(__pa(shmobile_secondary_vector_scu));
 
-	/* enable cache coherency on CPU0 */
-	modify_scu_cpu_psr(0, 3 << (cpu * 8));
+	/* enable cache coherency on booting CPU */
+	scu_power_mode(shmobile_scu_base, SCU_PM_NORMAL);
 }
 
 static void __init emev2_smp_init_cpus(void)
 {
 	unsigned int ncores;
 
-	if (!shmobile_scu_base) {
-		shmobile_scu_base = ioremap(EMEV2_SCU_BASE, PAGE_SIZE);
-		emev2_clock_init(); /* need ioremapped SMU */
-	}
+	/* setup EMEV2 specific SCU base */
+	shmobile_scu_base = ioremap(EMEV2_SCU_BASE, PAGE_SIZE);
+	emev2_clock_init(); /* need ioremapped SMU */
 
 	ncores = shmobile_scu_base ? scu_get_core_count(shmobile_scu_base) : 1;
 
#12 lore raw

cover ARM: shmobile: SMP Cortex-A9 SCU rework

In reply to Magnus Damm
Quoted 13 lines · Magnus Damm

ARM: shmobile: SMP Cortex-A9 SCU rework

[PATCH 01/06] ARM: shmobile: Kill off sh73a0 scu_base_addr() function [PATCH 02/06] ARM: shmobile: Kill off r8a7779 scu_base_addr() function [PATCH 03/06] ARM: shmobile: Rework EMEV2 scu_base variable [PATCH 04/06] ARM: shmobile: Move headsmp-sh73a0.S to headsmp-scu.S [PATCH 05/06] ARM: shmobile: Common shmobile_scu_base in headsmp-scu.S [PATCH 06/06] ARM: shmobile: Update EMEV2 to use scu_power_mode()

Rework the EMEV2 SMP code to make use of common scu_power_mode() code together with a shared shmobile_scu_base and early SCU setup code in headsmp-scu.S.

Quoted 7 lines

The patches are known to build for sh73a0, r8a7779 and EMEV2.

Note that the code has only been tested on the KZM9D/EMEV2 board, and because of that changes to other boards have been kept at a minimum. Next target after this is to update the r8a7779 SMP/SCU code to make use of scu_base_addr(), but that requires hardware access for testing.

I have tested this on the kzm9g/sh73a0, marzen/r8a7779 and kzm9d/emev2.

I have applied the entire series to the soc5 branch thus queued up for v3.10. It is also in the next branch and thus should appear in linux-next in the not to distant future.