Skip to contentSkip to conversation

Fix cpuidle on qcom's THUMB2 kernels

PATCH In review Stephen Boyd 5 participants 15 messages Jun 2, 2015 – Jun 15, 2015

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

v2 cover Fix cpuidle on qcom's THUMB2 kernels

I split this patch into two now that we have the cpu_resume_arm() wrapper. The first patch could go through rmk's tree and then be provided at some stable branch so that the second patch could go through arm-soc. Or the two patches could go through arm-soc and be squashed into one patch or stay split out. Either way, we have a cross maintainer dependency here that needs to be resolved.

Changes from v1:
* Add cpu_resume_arm() wrapper
* New patch to fix up spm code to use new wrapper

Stephen Boyd (2):
ARM: Add cpu_resume_arm() for firmwares that resume in ARM state
soc: qcom: spm: Fix idle on THUMB2 kernels

 arch/arm/include/asm/suspend.h | 1 +
 arch/arm/kernel/sleep.S        | 7 +++++++
 drivers/soc/qcom/spm.c         | 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)
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 v2 1/2 ARM: Add cpu_resume_arm() for firmwares that resume in ARM state

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

This fixes a problem reported by Kevin Hilman on next-20150601 where the ifc6410 fails to boot a THUMB2 kernel because the platform's firmware always enters the kernel in ARM mode from deep idle states.

---
 arch/arm/include/asm/suspend.h | 1 +
 arch/arm/kernel/sleep.S        | 7 +++++++
 2 files changed, 8 insertions(+)
arch/arm/include/asm/suspend.h +1 -0
index cd20029bcd94..6c7182f32cef 100644
@@ -7,6 +7,7 @@ struct sleep_save_sp {
 };
 
 extern void cpu_resume(void);
+extern void cpu_resume_arm(void);
 extern int cpu_suspend(unsigned long, int (*)(unsigned long));
 
 #endif
arch/arm/kernel/sleep.S +7 -0
index 76bb3128e135..f37593567ef5 100644
@@ -118,6 +118,12 @@ ENDPROC(cpu_resume_after_mmu)
 
 	.text
 	.align
+	.arm
+ENTRY(cpu_resume_arm)
+ THUMB(	badr	r9, 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(cpu_resume)
 ARM_BE8(setend be)			@ ensure we are in BE mode
 #ifdef CONFIG_ARM_VIRT_EXT
@@ -149,6 +155,7 @@ THUMB(	ldmia	r0!, {r1, r2, r3}	)
 THUMB(	mov	sp, r2			)
 THUMB(	bx	r3			)
 ENDPROC(cpu_resume)
+ENDPROC(cpu_resume_arm)
 
 	.align 2
 _sleep_save_sp:
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#2 lore raw

Re: [PATCH v2 1/2] ARM: Add cpu_resume_arm() for firmwares that resume in ARM state

Quoted 8 lines · Stephen Boyd

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

This fixes a problem reported by Kevin Hilman on next-20150601 where the ifc6410 fails to boot a THUMB2 kernel because the platform's firmware always enters the kernel in ARM mode from deep idle states.

I think this bit of the commit message isn't quite correct: this will only resolve the boot problem with a T2 kernel when the failing platform is converted to use the cpu_resume_arm() entry point.

Apart from that, the patch looks good to me, thanks.

Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
#3 lore raw

Re: [PATCH v2 1/2] ARM: Add cpu_resume_arm() for firmwares that resume in ARM state

Quoted 10 lines · Russell King - ARM Linux
Quoted 8 lines · Stephen Boyd

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

This fixes a problem reported by Kevin Hilman on next-20150601 where the ifc6410 fails to boot a THUMB2 kernel because the platform's firmware always enters the kernel in ARM mode from deep idle states.

Quoted 5 lines

I think this bit of the commit message isn't quite correct: this will only resolve the boot problem with a T2 kernel when the failing platform is converted to use the cpu_resume_arm() entry point.

Apart from that, the patch looks good to me, thanks.

Sure, it could say "This provides the functionality to fix a problem reported by..."

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

Re: [PATCH v2 1/2] ARM: Add cpu_resume_arm() for firmwares that resume in ARM state

Quoted 11 lines · Stephen Boyd
Quoted 10 lines · Russell King - ARM Linux
Quoted 8 lines · Stephen Boyd

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

This fixes a problem reported by Kevin Hilman on next-20150601 where the ifc6410 fails to boot a THUMB2 kernel because the platform's firmware always enters the kernel in ARM mode from deep idle states.

Quoted 8 lines
Quoted 5 lines

I think this bit of the commit message isn't quite correct: this will only resolve the boot problem with a T2 kernel when the failing platform is converted to use the cpu_resume_arm() entry point.

Apart from that, the patch looks good to me, thanks.

Sure, it could say "This provides the functionality to fix a problem reported by..."

Stephen, are you planning to submit this through Russell's patch tracker? or...

Russell, should we take this through arm-soc along with PATCH 2/2 which depends on this one?

Kevin

#5 lore raw

Re: [PATCH v2 1/2] ARM: Add cpu_resume_arm() for firmwares that resume in ARM state

Quoted 16 lines · Kevin Hilman
Quoted 14 lines · Stephen Boyd
Quoted 13 lines · Russell King - ARM Linux
Quoted 8 lines · Stephen Boyd

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

This fixes a problem reported by Kevin Hilman on next-20150601 where the ifc6410 fails to boot a THUMB2 kernel because the platform's firmware always enters the kernel in ARM mode from deep idle states.

I think this bit of the commit message isn't quite correct: this will only resolve the boot problem with a T2 kernel when the failing platform is converted to use the cpu_resume_arm() entry point.

Quoted 9 lines
Quoted 3 lines
Quoted 1 line

Apart from that, the patch looks good to me, thanks.

Sure, it could say "This provides the functionality to fix a problem reported by..."

Stephen, are you planning to submit this through Russell's patch tracker? or...

Russell, should we take this through arm-soc along with PATCH 2/2 which depends on this one?

I'm happy to see it be applied by arm-soc maintainers directly given that Russell said "the patch looks good to me". The commit text needs a slight reword here though, so I can resubmit the patches to arm-soc if you like.

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

Re: [PATCH v2 1/2] ARM: Add cpu_resume_arm() for firmwares that resume in ARM state

Quoted 23 lines · Stephen Boyd
Quoted 22 lines · Kevin Hilman
Quoted 10 lines · Stephen Boyd
Quoted 9 lines · Russell King - ARM Linux
Quoted 8 lines · Stephen Boyd

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

This fixes a problem reported by Kevin Hilman on next-20150601 where the ifc6410 fails to boot a THUMB2 kernel because the platform's firmware always enters the kernel in ARM mode from deep idle states.

Quoted 7 lines
Quoted 5 lines

I think this bit of the commit message isn't quite correct: this will only resolve the boot problem with a T2 kernel when the failing platform is converted to use the cpu_resume_arm() entry point.

Apart from that, the patch looks good to me, thanks.

Sure, it could say "This provides the functionality to fix a problem reported by..."

Stephen, are you planning to submit this through Russell's patch tracker? or...

Quoted 8 lines
Quoted 3 lines

Russell, should we take this through arm-soc along with PATCH 2/2 which depends on this one?

I'm happy to see it be applied by arm-soc maintainers directly given that Russell said "the patch looks good to me". The commit text needs a slight reword here though, so I can resubmit the patches to arm-soc if you like.

Go ahead and respin/resubmit, and I can get them ready, but I'll wait for an official word or acked-by from Russell before taking them both through arm-soc.

Kevin

#7 lore raw

Re: [PATCH v2 1/2] ARM: Add cpu_resume_arm() for firmwares that resume in ARM state

Quoted 9 lines · Kevin Hilman
Quoted 4 lines · Stephen Boyd

I'm happy to see it be applied by arm-soc maintainers directly given that Russell said "the patch looks good to me". The commit text needs a slight reword here though, so I can resubmit the patches to arm-soc if you like.

Go ahead and respin/resubmit, and I can get them ready, but I'll wait for an official word or acked-by from Russell before taking them both through arm-soc.

I've suggested to Kevin that, as I have another patch outstanding for arm-soc, that I take this one into that same branch and send Kevin a pull for both patches. (Esp. as I don't like sending single-patch pull requests. Having two patches solves my dilema!)

Stephen, if you can arrange for the patch to end up in the patch system please...

Thanks.

Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
#8 lore raw

Re: [PATCH v2 1/2] ARM: Add cpu_resume_arm() for firmwares that resume in ARM state

Quoted 4 lines · Russell King - ARM Linux

Stephen, if you can arrange for the patch to end up in the patch system please...

Sure no problem. The patch is 8389/1 in the tracker. I also fixed the commit text.

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

Re: [PATCH v2 1/2] ARM: Add cpu_resume_arm() for firmwares that resume in ARM state

In reply to Stephen Boyd

Hello,

Quoted 21 lines · Stephen Boyd

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

This fixes a problem reported by Kevin Hilman on next-20150601 where the ifc6410 fails to boot a THUMB2 kernel because the platform's firmware always enters the kernel in ARM mode from deep idle states.

arch/arm/kernel/sleep.S +0 -0
index 76bb3128e135..f37593567ef5 100644
@@ -118,6 +118,12 @@ ENDPROC(cpu_resume_after_mmu)
 
 	.text

arch/arm/kernel/sleep.S ENDPROC(cpu_resume_after_mmu) · line 129

Quoted 10 lines
arch/arm/kernel/sleep.S +6 -0
 	.align
+	.arm
+ENTRY(cpu_resume_arm)
+ THUMB(	badr	r9, 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(cpu_resume)
 ARM_BE8(setend be)			@ ensure we are in BE mode
 #ifdef CONFIG_ARM_VIRT_EXT

this patch is in next as 51ac91b7f6b11b0da55ac93885ee7b864865bcb1 and breaks efm32_defconfig. The exact error message is:

AS arch/arm/kernel/sleep.o
arch/arm/kernel/sleep.S: Assembler messages:
arch/arm/kernel/sleep.S:121: Error: selected processor does not support ARM opcodes arch/arm/kernel/sleep.S:123: Error: bad instruction badr r9,1f' arch/arm/kernel/sleep.S:124: Error: attempt to use an ARM instruction on a Thumb-only processor -- bx r9' scripts/Makefile.build:294: recipe for target 'arch/arm/kernel/sleep.o' failed
make[3]: *** [arch/arm/kernel/sleep.o] Error 1

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#10 lore raw

Re: [PATCH v2 1/2] ARM: Add cpu_resume_arm() for firmwares that resume in ARM state

Quoted 13 lines · Uwe Kleine-K?nig

Hello,

arch/arm/kernel/sleep.S ENDPROC(cpu_resume_after_mmu) · line 129

Quoted 9 lines
arch/arm/kernel/sleep.S +6 -0
+	.arm
+ENTRY(cpu_resume_arm)
+ THUMB(	badr	r9, 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(cpu_resume)
 ARM_BE8(setend be)			@ ensure we are in BE mode
 #ifdef CONFIG_ARM_VIRT_EXT

this patch is in next as 51ac91b7f6b11b0da55ac93885ee7b864865bcb1 and breaks efm32_defconfig. The exact error message is:

Quoted 7 lines

AS arch/arm/kernel/sleep.o
arch/arm/kernel/sleep.S: Assembler messages:
arch/arm/kernel/sleep.S:121: Error: selected processor does not support ARM opcodes arch/arm/kernel/sleep.S:123: Error: bad instruction badr r9,1f' arch/arm/kernel/sleep.S:124: Error: attempt to use an ARM instruction on a Thumb-only processor -- bx r9' scripts/Makefile.build:294: recipe for target 'arch/arm/kernel/sleep.o' failed
make[3]: *** [arch/arm/kernel/sleep.o] Error 1

Don't get me wrong, the build testing which goes on is really great, but there's now a problem with all this.

There needs to be coordination between the people doing the build tests to ensure that we don't "tire out" those who read the emails with different groups of people reporting the same problem days after it was first discovered, and even worse, days after it's been fixed.

The worst thing to do is to report build regressions on Monday for a tree which was created on Thursday - by the time Monday comes around, projects such as the 0-day builder have had plenty of time to find them.

Remember, the linux-next tree which is published on Friday (Austrailian time) is a result of git trees snapshotted around midnight on Thursday.

So, if you're going to build an old linux-next tree, before you report any problems, please check whether other build systems have already reported them. If you've gone to the trouble of tracking down the commit which caused it, and therefore the likely git tree, check whether a fix has already been merged. Or maybe wait until the post-weekend linux-next is published...

(The problem you're referring to was fixed and pushed out on Friday - which seems to be a regular thing that happens with problems you've reported on Mondays...)

Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
#11 lore raw

Re: [PATCH v2 1/2] ARM: Add cpu_resume_arm() for firmwares that resume in ARM state

Hello Russell,

Quoted 44 lines · Russell King - ARM Linux
Quoted 13 lines · Uwe Kleine-K?nig

Hello,

arch/arm/kernel/sleep.S ENDPROC(cpu_resume_after_mmu) · line 129

Quoted 9 lines
arch/arm/kernel/sleep.S +6 -0
+	.arm
+ENTRY(cpu_resume_arm)
+ THUMB(	badr	r9, 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(cpu_resume)
 ARM_BE8(setend be)			@ ensure we are in BE mode
 #ifdef CONFIG_ARM_VIRT_EXT

this patch is in next as 51ac91b7f6b11b0da55ac93885ee7b864865bcb1 and breaks efm32_defconfig. The exact error message is:

Quoted 7 lines

AS arch/arm/kernel/sleep.o
arch/arm/kernel/sleep.S: Assembler messages:
arch/arm/kernel/sleep.S:121: Error: selected processor does not support ARM opcodes arch/arm/kernel/sleep.S:123: Error: bad instruction badr r9,1f' arch/arm/kernel/sleep.S:124: Error: attempt to use an ARM instruction on a Thumb-only processor -- bx r9' scripts/Makefile.build:294: recipe for target 'arch/arm/kernel/sleep.o' failed
make[3]: *** [arch/arm/kernel/sleep.o] Error 1

Don't get me wrong, the build testing which goes on is really great, but there's now a problem with all this.

There needs to be coordination between the people doing the build tests to ensure that we don't "tire out" those who read the emails with different groups of people reporting the same problem days after it was first discovered, and even worse, days after it's been fixed.

The worst thing to do is to report build regressions on Monday for a tree which was created on Thursday - by the time Monday comes around, projects such as the 0-day builder have had plenty of time to find them.

Remember, the linux-next tree which is published on Friday (Austrailian time) is a result of git trees snapshotted around midnight on Thursday.

So, if you're going to build an old linux-next tree, before you report any problems, please check whether other build systems have already reported them. If you've gone to the trouble of tracking down the commit which caused it, and therefore the likely git tree, check whether a fix has already been merged. Or maybe wait until the post-weekend linux-next is published...

Quoted 3 lines

(The problem you're referring to was fixed and pushed out on Friday - which seems to be a regular thing that happens with problems you've reported on Mondays...)

I consulted Google (asking for the commit id) and checked the linux-arm-kernel list for reports which usually works well enough.

But I understand your complaint, last time I introduced a build regression I got two automatic reports and three times the same fix into my mailbox. So I will try to be more careful in the future.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#12 lore raw

PATCH v2 2/2 soc: qcom: spm: Fix idle on THUMB2 kernels

In reply to Stephen Boyd

The ifc6410 firmware always enters the kernel in ARM state from deep idle. Use the cpu_resume_arm() wrapper instead of cpu_resume() to property switch into the THUMB2 state when we wake up from idle.

This fixes a problem reported by Kevin Hilman on next-20150601 where the ifc6410 fails to boot a THUMB2 kernel because the platform's firmware always enters the kernel in ARM mode from deep idle states.

---
 drivers/soc/qcom/spm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/spm.c +1 -1
index b562af816c0a..b04b05a0904e 100644
@@ -260,7 +260,7 @@ static int __init qcom_cpuidle_init(struct device_node *cpu_node, int cpu)
 		/* We have atleast one power down mode */
 		cpumask_clear(&mask);
 		cpumask_set_cpu(cpu, &mask);
-		qcom_scm_set_warm_boot_addr(cpu_resume, &mask);
+		qcom_scm_set_warm_boot_addr(cpu_resume_arm, &mask);
 	}
 
 	per_cpu(qcom_idle_ops, cpu) = fns;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#13 lore raw

Re: [PATCH v2 2/2] soc: qcom: spm: Fix idle on THUMB2 kernels

Quoted 10 lines · Stephen Boyd

The ifc6410 firmware always enters the kernel in ARM state from deep idle. Use the cpu_resume_arm() wrapper instead of cpu_resume() to property switch into the THUMB2 state when we wake up from idle.

This fixes a problem reported by Kevin Hilman on next-20150601 where the ifc6410 fails to boot a THUMB2 kernel because the platform's firmware always enters the kernel in ARM mode from deep idle states.

Quoted 4 lines
Quoted 21 lines

---
drivers/soc/qcom/spm.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/spm.c +1 -1
index b562af816c0a..b04b05a0904e 100644
@@ -260,7 +260,7 @@ static int __init qcom_cpuidle_init(struct device_node *cpu_node, int cpu)
 		/* We have atleast one power down mode */
 		cpumask_clear(&mask);
 		cpumask_set_cpu(cpu, &mask);
-		qcom_scm_set_warm_boot_addr(cpu_resume, &mask);
+		qcom_scm_set_warm_boot_addr(cpu_resume_arm, &mask);
 	}
 
 	per_cpu(qcom_idle_ops, cpu) = fns;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
Tested-by on the v2 series
#14 lore raw
In reply to Stephen Boyd
Quoted 6 lines · Stephen Boyd

I split this patch into two now that we have the cpu_resume_arm() wrapper. The first patch could go through rmk's tree and then be provided at some stable branch so that the second patch could go through arm-soc. Or the two patches could go through arm-soc and be squashed into one patch or stay split out. Either way, we have a cross maintainer dependency here that needs to be resolved.

Boot tested on top of next-20150602 using multi_v7_defconfig + CONFIG_THUMB2_KERNEL=y on a handful of qcom 8x[678]4 platforms[1]

These platforms were all failing to boot this config with plain next-20150602[2] and are all booting fine with this series.

Kevin

[1]
qcom-apq8064-ifc6410
qcom-apq8064-cm-qs600
qcom-apq8074-dragonboard
qcom-msm8974-sony-xperia-honami
qcom-apq8084-ifc6540

[2] http://kernelci.org/boot/all/job/next/kernel/next-20150602/