Skip to contentSkip to conversation

Fix secondary CPU boot for thumb2 kernels

PATCH In review Stephen Boyd 2 participants 6 messages Jan 21, 2015 – Jan 29, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Fix secondary CPU boot for thumb2 kernels

Currently I can't boot up secondary CPUs on qcom platforms when I compile the kernel for THUMB2 mode. This is because we always enter the kernel in ARM mode regardless of what mode the kernel is compiled for. This patchset adds a small wrapper to secondary_startup() called secondary_startup_arm() that allows us to switch into THUMB2 mode if we need to. If the kernel is compiled for ARM mode it shouldn't have any effect.

Stephen Boyd (2):
ARM: Add a secondary_startup that assumes ARM mode
ARM: qcom: Use secondary_startup_arm()

 arch/arm/kernel/head.S       | 7 +++++++
 arch/arm/mach-qcom/platsmp.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#1 lore raw

PATCH 1/2 ARM: Add a secondary_startup that assumes ARM mode

Some platforms always enter the kernel in ARM mode even if the kernel is compiled for THUMB2. Add a small wrapper on top of secondary_startup() that switches into THUMB2 mode.

---
 arch/arm/kernel/head.S | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/kernel/head.S +7 -0
index 664eee8c4a26..22bb6d54e90d 100644
@@ -346,6 +346,12 @@ __turn_mmu_on_loc:
 
 #if defined(CONFIG_SMP)
 	.text
+ENTRY(secondary_startup_arm)
+	.arm
+ THUMB(	adr	r9, BSYM(1f)	)	@ Kernel is entered in ARM.
+ THUMB(	bx	r9		)	@ If this is a Thumb-2 kernel,
+ THUMB(	.thumb			)	@ switch to Thumb now.
+ THUMB(1:			)
 ENTRY(secondary_startup)
 	/*
 	 * Common entry point for secondary CPUs.
@@ -385,6 +391,7 @@ ENTRY(secondary_startup)
  THUMB(	add	r12, r10, #PROCINFO_INITFUNC	)
  THUMB(	ret	r12				)
 ENDPROC(secondary_startup)
+ENDPROC(secondary_startup_arm)
 
 	/*
 	 * r6  = &secondary_data
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#2 lore raw

PATCH 2/2 ARM: qcom: Use secondary_startup_arm()

In reply to Stephen Boyd

On qcom platforms we always enter the kernel in ARM mode, regardless of the kernel being compiled for THUMB mode. Use secondary_startup_arm() to properly switch the mode to what the kernel expects if required.

---
 arch/arm/mach-qcom/platsmp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-qcom/platsmp.c +2 -2
index a692bcb7e7f5..0f8b5147a78f 100644
@@ -44,7 +44,7 @@
 #define APCS_SAW2_VCTL		0x14
 #define APCS_SAW2_2_VCTL	0x1c
 
-extern void secondary_startup(void);
+extern void secondary_startup_arm(void);
 
 static DEFINE_SPINLOCK(boot_lock);
 
@@ -337,7 +337,7 @@ static void __init qcom_smp_prepare_cpus(unsigned int max_cpus)
 		flags |= cold_boot_flags[map];
 	}
 
-	if (scm_set_boot_addr(virt_to_phys(secondary_startup), flags)) {
+	if (scm_set_boot_addr(virt_to_phys(secondary_startup_arm), flags)) {
 		for_each_present_cpu(cpu) {
 			if (cpu == smp_processor_id())
 				continue;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#3 lore raw
In reply to Stephen Boyd
Quoted 8 lines · Stephen Boyd

Currently I can't boot up secondary CPUs on qcom platforms when I compile the kernel for THUMB2 mode. This is because we always enter the kernel in ARM mode regardless of what mode the kernel is compiled for. This patchset adds a small wrapper to secondary_startup() called secondary_startup_arm() that allows us to switch into THUMB2 mode if we need to. If the kernel is compiled for ARM mode it shouldn't have any effect.

Quoted 8 lines

Stephen Boyd (2):
ARM: Add a secondary_startup that assumes ARM mode
ARM: qcom: Use secondary_startup_arm()

 arch/arm/kernel/head.S       | 7 +++++++
 arch/arm/mach-qcom/platsmp.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

Any comments here? Perhaps I can send this through the patch tracker?

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#4 lore raw
Quoted 13 lines · Stephen Boyd
Quoted 12 lines · Stephen Boyd

Currently I can't boot up secondary CPUs on qcom platforms when I compile the kernel for THUMB2 mode. This is because we always enter the kernel in ARM mode regardless of what mode the kernel is compiled for. This patchset adds a small wrapper to secondary_startup() called secondary_startup_arm() that allows us to switch into THUMB2 mode if we need to. If the kernel is compiled for ARM mode it shouldn't have any effect.

Stephen Boyd (2):
ARM: Add a secondary_startup that assumes ARM mode
ARM: qcom: Use secondary_startup_arm()

Quoted 5 lines
Quoted 3 lines
 arch/arm/kernel/head.S       | 7 +++++++
 arch/arm/mach-qcom/platsmp.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

Any comments here? Perhaps I can send this through the patch tracker?

FWIW, they look fine to me.

I guess the reason it works fine on other platforms is because the secondary start address we pass to firmware has bit 0 set and this causes the jump to the kernel in Thumb-2 mode.

Catalin

#5 lore raw
Quoted 17 lines · Catalin Marinas
Quoted 16 lines · Stephen Boyd
Quoted 15 lines · Stephen Boyd

Currently I can't boot up secondary CPUs on qcom platforms when I compile the kernel for THUMB2 mode. This is because we always enter the kernel in ARM mode regardless of what mode the kernel is compiled for. This patchset adds a small wrapper to secondary_startup() called secondary_startup_arm() that allows us to switch into THUMB2 mode if we need to. If the kernel is compiled for ARM mode it shouldn't have any effect.

Stephen Boyd (2):
ARM: Add a secondary_startup that assumes ARM mode
ARM: qcom: Use secondary_startup_arm()

 arch/arm/kernel/head.S       | 7 +++++++
 arch/arm/mach-qcom/platsmp.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)
Quoted 9 lines
Quoted 1 line

Any comments here? Perhaps I can send this through the patch tracker?

FWIW, they look fine to me.

I guess the reason it works fine on other platforms is because the secondary start address we pass to firmware has bit 0 set and this causes the jump to the kernel in Thumb-2 mode.

Thanks. I tried forcing that and it still didn't work so I guess the firmware isn't using interworking branches.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project