Skip to contentSkip to conversation

ARM: shmobile: SMP virt_to_phys() conversion

PATCH New Magnus Damm 2 participants 13 messages Jun 10, 2013 – Jun 12, 2013

Subsystems (4)
lore
Share & tools
lore

Magnus Damm

author maintainer
#0 lore raw

cover ARM: shmobile: SMP virt_to_phys() conversion

ARM: shmobile: SMP virt_to_phys() conversion

[PATCH 01/06] ARM: shmobile: Add SMP boot function and argument [PATCH 02/06] ARM: shmobile: Add SCU boot function using argument [PATCH 03/06] ARM: shmobile: r8a7779 SMP with SCU boot fn and args [PATCH 04/06] ARM: shmobile: sh73a0 SMP with SCU boot fn and args [PATCH 05/06] ARM: shmobile: EMEV2 SMP with SCU boot fn and args [PATCH 06/06] ARM: shmobile: Remove old SCU boot code

This series replaces the inline virtual to physical address conversion code in the mach-shmobile assembly files with C code making use of virt_to_phys().

This is one of several series of code that rework code not to rely on CONFIG_MEMORY_START/SIZE which in turn is needed for ARCH_MULTIPLATFORM.

---

Written against renesas.git renesas-next-20130607

 arch/arm/mach-shmobile/headsmp-scu.S         |   35 ++++++++++----------------
 arch/arm/mach-shmobile/headsmp.S             |   13 +++++++--
 arch/arm/mach-shmobile/include/mach/common.h |    6 ++--
 arch/arm/mach-shmobile/smp-emev2.c           |    6 ++--
 arch/arm/mach-shmobile/smp-r8a7779.c         |    6 ++--
 arch/arm/mach-shmobile/smp-sh73a0.c          |    6 ++--
 6 files changed, 40 insertions(+), 32 deletions(-)
author maintainer
#1 lore raw

PATCH 1/6 ARM: shmobile: Add SMP boot function and argument

From: Magnus Damm <[email protected]>

Add code for mach-shmobile to allow specifying boot function and argument. Will initially be used for SMP together with SCU but may in the future also be used for deep sleep resume. This patch removes one inline virtual to physical address conversion.

---

 arch/arm/mach-shmobile/headsmp.S             |   13 ++++++++++---
 arch/arm/mach-shmobile/include/mach/common.h |    4 +++-
 2 files changed, 13 insertions(+), 4 deletions(-)
arch/arm/mach-shmobile/headsmp.S +10 -3
@@ -27,7 +27,14 @@ ENDPROC(shmobile_invalidate_start)
  * We need _long_ jump to the physical address.
  */
 	.align  12
-ENTRY(shmobile_secondary_vector)
+ENTRY(shmobile_boot_vector)
+	ldr     r0, 2f
 	ldr     pc, 1f
-1:	.long   shmobile_invalidate_start - PAGE_OFFSET + PLAT_PHYS_OFFSET
-ENDPROC(shmobile_secondary_vector)
+ENDPROC(shmobile_boot_vector)
+
+	.globl	shmobile_boot_fn
+shmobile_boot_fn:
+1:	.space	4
+	.globl	shmobile_boot_arg
+shmobile_boot_arg:
+2:	.space	4
arch/arm/mach-shmobile/include/mach/common.h +3 -1
@@ -7,7 +7,9 @@ extern void shmobile_setup_delay(unsigne
 			 unsigned int mult, unsigned int div);
 struct twd_local_timer;
 extern void shmobile_setup_console(void);
-extern void shmobile_secondary_vector(void);
+extern void shmobile_boot_vector(void);
+extern unsigned long shmobile_boot_fn;
+extern unsigned long shmobile_boot_arg;
 extern void shmobile_secondary_vector_scu(void);
 struct clk;
 extern int shmobile_clk_init(void);
author maintainer
#3 lore raw

PATCH 2/6 ARM: shmobile: Add SCU boot function using argument

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Add a shmoible_boot_scu function that assumes that the base address of the SCU is passed in r0. This code is free from inline virtual to physical address conversion.

---

 arch/arm/mach-shmobile/headsmp-scu.S         |   13 +++++++++++++
 arch/arm/mach-shmobile/include/mach/common.h |    1 +
 2 files changed, 14 insertions(+)
arch/arm/mach-shmobile/headsmp-scu.S +13 -0
@@ -51,6 +51,19 @@ ENTRY(shmobile_secondary_vector_scu)
 2:	.long shmobile_scu_base - PAGE_OFFSET + PLAT_PHYS_OFFSET
 ENDPROC(shmobile_secondary_vector_scu)
 
+ENTRY(shmobile_boot_scu)
+					@ r0 = SCU base address
+	mrc     p15, 0, r1, c0, c0, 5	@ read MIPDR
+	and	r1, r1, #3		@ mask out cpu ID
+	lsl	r1, r1, #3		@ we will shift by cpu_id * 8 bits
+	ldr	r2, [r0, #8]		@ SCU Power Status Register
+	mov	r3, #3
+	bic	r2, r2, r3, lsl r1	@ Clear bits of our CPU (Run Mode)
+	str	r2, [r0, #8]		@ write back
+
+	b	shmobile_invalidate_start
+ENDPROC(shmobile_boot_scu)
+
 	.text
 	.globl	shmobile_scu_base
 shmobile_scu_base:
arch/arm/mach-shmobile/include/mach/common.h +1 -0
@@ -11,6 +11,7 @@ extern void shmobile_boot_vector(void);
 extern unsigned long shmobile_boot_fn;
 extern unsigned long shmobile_boot_arg;
 extern void shmobile_secondary_vector_scu(void);
+extern void shmobile_boot_scu(void);
 struct clk;
 extern int shmobile_clk_init(void);
 extern void shmobile_handle_irq_intc(struct pt_regs *);
author maintainer
#5 lore raw

PATCH 3/6 ARM: shmobile: r8a7779 SMP with SCU boot fn and args

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Let r8a7779 make use of shmobile_boot_fn and shmobile_boot_arg together with shmobile_boot_scu and the SCU base address.

---

 arch/arm/mach-shmobile/smp-r8a7779.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/arm/mach-shmobile/smp-r8a7779.c +4 -2
@@ -101,8 +101,10 @@ static void __init r8a7779_smp_prepare_c
 {
 	scu_enable(shmobile_scu_base);
 
-	/* Map the reset vector (in headsmp-scu.S) */
-	__raw_writel(__pa(shmobile_secondary_vector_scu), AVECR);
+	/* Map the reset vector (in headsmp-scu.S, headsmp.S) */
+	__raw_writel(__pa(shmobile_boot_vector), AVECR);
+	shmobile_boot_fn = virt_to_phys(shmobile_boot_scu);
+	shmobile_boot_arg = (unsigned long)shmobile_scu_base;
 
 	/* enable cache coherency on booting CPU */
 	scu_power_mode(shmobile_scu_base, SCU_PM_NORMAL);
author maintainer
#7 lore raw

PATCH 4/6 ARM: shmobile: sh73a0 SMP with SCU boot fn and args

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Let sh73a0 make use of shmobile_boot_fn and shmobile_boot_arg together with shmobile_boot_scu and the SCU base address.

---

 arch/arm/mach-shmobile/smp-sh73a0.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/arm/mach-shmobile/smp-sh73a0.c +4 -2
@@ -64,9 +64,11 @@ static void __init sh73a0_smp_prepare_cp
 {
 	scu_enable(shmobile_scu_base);
 
-	/* Map the reset vector (in headsmp-scu.S) */
+	/* Map the reset vector (in headsmp-scu.S, headsmp.S) */
 	__raw_writel(0, APARMBAREA);      /* 4k */
-	__raw_writel(__pa(shmobile_secondary_vector_scu), SBAR);
+	__raw_writel(__pa(shmobile_boot_vector), SBAR);
+	shmobile_boot_fn = virt_to_phys(shmobile_boot_scu);
+	shmobile_boot_arg = (unsigned long)shmobile_scu_base;
 
 	/* enable cache coherency on booting CPU */
 	scu_power_mode(shmobile_scu_base, SCU_PM_NORMAL);
author maintainer
#9 lore raw

PATCH 5/6 ARM: shmobile: EMEV2 SMP with SCU boot fn and args

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Let EMEV2 make use of shmobile_boot_fn and shmobile_boot_arg together with shmobile_boot_scu and the SCU base address.

---

 arch/arm/mach-shmobile/smp-emev2.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/arm/mach-shmobile/smp-emev2.c +4 -2
@@ -40,8 +40,10 @@ static void __init emev2_smp_prepare_cpu
 {
 	scu_enable(shmobile_scu_base);
 
-	/* Tell ROM loader about our vector (in headsmp-scu.S) */
-	emev2_set_boot_vector(__pa(shmobile_secondary_vector_scu));
+	/* Tell ROM loader about our vector (in headsmp-scu.S, headsmp.S) */
+	emev2_set_boot_vector(__pa(shmobile_boot_vector));
+	shmobile_boot_fn = virt_to_phys(shmobile_boot_scu);
+	shmobile_boot_arg = (unsigned long)shmobile_scu_base;
 
 	/* enable cache coherency on booting CPU */
 	scu_power_mode(shmobile_scu_base, SCU_PM_NORMAL);
author maintainer
#11 lore raw

PATCH 6/6 ARM: shmobile: Remove old SCU boot code

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Remove shmobile_secondary_vector_scu now when all SCU enabled SMP platforms instead make use of shmobile_boot_scu. This removes two inline virtual to physical address conversions.

---

 arch/arm/mach-shmobile/headsmp-scu.S         |   22 +---------------------
 arch/arm/mach-shmobile/include/mach/common.h |    1 -
 2 files changed, 1 insertion(+), 22 deletions(-)
arch/arm/mach-shmobile/headsmp-scu.S +1 -21
@@ -25,32 +25,12 @@
 
 	__CPUINIT
 /*
- * Reset vector for secondary CPUs.
+ * Boot code for secondary CPUs.
  *
  * First we turn on L1 cache coherency for our CPU. Then we jump to
  * shmobile_invalidate_start that invalidates the cache and hands over control
  * to the common ARM startup code.
- * This function will be mapped to address 0 by the SBAR register.
- * A normal branch is out of range here so we need a long jump. We jump to
- * the physical address as the MMU is still turned off.
  */
-	.align	12
-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
-	ldr	r1, 2f
-	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)
-	str	r2, [r1, #8]		@ write back
-
-	ldr	pc, 1f
-1:	.long shmobile_invalidate_start - PAGE_OFFSET + PLAT_PHYS_OFFSET
-2:	.long shmobile_scu_base - PAGE_OFFSET + PLAT_PHYS_OFFSET
-ENDPROC(shmobile_secondary_vector_scu)
-
 ENTRY(shmobile_boot_scu)
 					@ r0 = SCU base address
 	mrc     p15, 0, r1, c0, c0, 5	@ read MIPDR
arch/arm/mach-shmobile/include/mach/common.h +0 -1
@@ -10,7 +10,6 @@ extern void shmobile_setup_console(void)
 extern void shmobile_boot_vector(void);
 extern unsigned long shmobile_boot_fn;
 extern unsigned long shmobile_boot_arg;
-extern void shmobile_secondary_vector_scu(void);
 extern void shmobile_boot_scu(void);
 struct clk;
 extern int shmobile_clk_init(void);
#2 lore raw

PATCH 1/6 ARM: shmobile: Add SMP boot function and argument

In reply to Magnus Damm
Quoted 7 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Add code for mach-shmobile to allow specifying boot function and argument. Will initially be used for SMP together with SCU but may in the future also be used for deep sleep resume. This patch removes one inline virtual to physical address conversion.

Quoted 6 lines

---

 arch/arm/mach-shmobile/headsmp.S             |   13 ++++++++++---
 arch/arm/mach-shmobile/include/mach/common.h |    4 +++-
 2 files changed, 13 insertions(+), 4 deletions(-)

Thanks, I have queued this up for v3.11 in the (new) cleanup-boot branch.

#4 lore raw

PATCH 2/6 ARM: shmobile: Add SCU boot function using argument

In reply to Magnus Damm
Quoted 6 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Add a shmoible_boot_scu function that assumes that the base address of the SCU is passed in r0. This code is free from inline virtual to physical address conversion.

Quoted 6 lines

---

 arch/arm/mach-shmobile/headsmp-scu.S         |   13 +++++++++++++
 arch/arm/mach-shmobile/include/mach/common.h |    1 +
 2 files changed, 14 insertions(+)

Thanks, I have queued this up for v3.11 in the (new) cleanup-boot branch.

#6 lore raw

PATCH 3/6 ARM: shmobile: r8a7779 SMP with SCU boot fn and args

In reply to Magnus Damm
Quoted 4 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Let r8a7779 make use of shmobile_boot_fn and shmobile_boot_arg together with shmobile_boot_scu and the SCU base address.

Thanks, I have queued this up for v3.11 in the (new) cleanup-boot branch.

#8 lore raw

PATCH 4/6 ARM: shmobile: sh73a0 SMP with SCU boot fn and args

In reply to Magnus Damm
Quoted 10 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Let sh73a0 make use of shmobile_boot_fn and shmobile_boot_arg together with shmobile_boot_scu and the SCU base address.

---

 arch/arm/mach-shmobile/smp-sh73a0.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Thanks, I have queued this up for v3.11 in the (new) cleanup-boot branch.

#10 lore raw

PATCH 5/6 ARM: shmobile: EMEV2 SMP with SCU boot fn and args

In reply to Magnus Damm
Quoted 10 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Let EMEV2 make use of shmobile_boot_fn and shmobile_boot_arg together with shmobile_boot_scu and the SCU base address.

---

 arch/arm/mach-shmobile/smp-emev2.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Thanks, I have queued this up for v3.11 in the (new) cleanup-boot branch.

#12 lore raw

PATCH 6/6 ARM: shmobile: Remove old SCU boot code

In reply to Magnus Damm
Quoted 6 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Remove shmobile_secondary_vector_scu now when all SCU enabled SMP platforms instead make use of shmobile_boot_scu. This removes two inline virtual to physical address conversions.

Quoted 6 lines

---

 arch/arm/mach-shmobile/headsmp-scu.S         |   22 +---------------------
 arch/arm/mach-shmobile/include/mach/common.h |    1 -
 2 files changed, 1 insertion(+), 22 deletions(-)

Thanks, I have queued this up for v3.11 in the (new) cleanup-boot branch.