Skip to contentSkip to conversation

Convert ARM subarchitectures to generic wfi macro.

PATCH New Nick Bowler 3 participants 10 messages Sep 9, 2011

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

cover Convert ARM subarchitectures to generic wfi macro.

This series cleans up all remaining ARM subarchitectures that I could find to use the generic wfi macro. As I don't have any of the boards in question, I've only compile-tested these patches to the extent that I was able.

See the previous discussion in https://lkml.org/lkml/2011/8/19/433 for more background.

Nick Bowler (5):
ARM: realview: Use wfi macro in platform_do_lowpower.
ARM: exynos4: Use wfi macro in platform_do_lowpower.
ARM: shmobile: Use wfi macro in platform_cpu_die.
ARM: tegra: Use wfi macro in platform_do_lowpower.
ARM: omap4: Kill private do_wfi macro.

 arch/arm/mach-exynos4/hotplug.c                 |    9 ++-------
 arch/arm/mach-omap2/include/mach/omap4-common.h |   11 -----------
 arch/arm/mach-omap2/omap-hotplug.c              |    7 +++----
 arch/arm/mach-omap2/pm44xx.c                    |    4 +++-
 arch/arm/mach-realview/hotplug.c                |    9 ++-------
 arch/arm/mach-shmobile/hotplug.c                |   10 +++-------
 arch/arm/mach-tegra/hotplug.c                   |    9 ++-------
 7 files changed, 15 insertions(+), 44 deletions(-)
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 1/5 ARM: realview: Use wfi macro in platform_do_lowpower.

Current Realview CPU hotplug code includes a hardcoded WFI instruction, in ARM encoding. The hardcoded instruction is both hard to understand and doomed to failure when building the kernel in Thumb-2 mode.

---
Compile tested in both ARM and Thumb-2 mode.

---
 arch/arm/mach-realview/hotplug.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)
arch/arm/mach-realview/hotplug.c +2 -7
index a87523d..6d19377 100644
@@ -13,6 +13,7 @@
 #include <linux/smp.h>
 
 #include <asm/cacheflush.h>
+#include <asm/system.h>
 
 extern volatile int pen_release;
 
@@ -61,13 +62,7 @@ static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
 	 * code will have already disabled interrupts
 	 */
 	for (;;) {
-		/*
-		 * here's the WFI
-		 */
-		asm(".word	0xe320f003\n"
-		    :
-		    :
-		    : "memory", "cc");
+		wfi();
 
 		if (pen_release == cpu) {
 			/*
Signature · 1 line
1.7.3.4
#2 lore raw

PATCH 2/5 ARM: exynos4: Use wfi macro in platform_do_lowpower.

In reply to Nick Bowler

Current Exynos4 CPU hotplug code includes a hardcoded WFI instruction, in ARM encoding. The hardcoded instruction is both hard to understand and doomed to failure when building the kernel in Thumb-2 mode.

---
Compile tested in both ARM and Thumb-2 mode.

---
 arch/arm/mach-exynos4/hotplug.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)
arch/arm/mach-exynos4/hotplug.c +2 -7
index 7490789..8724227 100644
@@ -16,6 +16,7 @@
 #include <linux/io.h>
 
 #include <asm/cacheflush.h>
+#include <asm/system.h>
 
 #include <mach/regs-pmu.h>
 
@@ -67,13 +68,7 @@ static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
 		if (cpu == 1)
 			__raw_writel(0, S5P_ARM_CORE1_CONFIGURATION);
 
-		/*
-		 * here's the WFI
-		 */
-		asm(".word	0xe320f003\n"
-		    :
-		    :
-		    : "memory", "cc");
+		wfi();
 
 		if (pen_release == cpu) {
 			/*
Signature · 1 line
1.7.3.4
#3 lore raw

PATCH 3/5 ARM: shmobile: Use wfi macro in platform_cpu_die.

In reply to Nick Bowler

Current Shmobile CPU hotplug code includes a hardcoded WFI instruction, in ARM encoding. The hardcoded instruction is both hard to understand and doomed to failure when building the kernel in Thumb-2 mode.

---
Compile tested in both ARM and Thumb-2 mode, and the resulting hotplug.o contains the correct instruction sequence, but the final kernel failed to link for apparently unrelated reasons:

In ARM mode:

LD .tmp_vmlinux1
arch/arm/kernel/built-in.o: In function `twd_timer_setup':
io.c:(.cpuinit.text+0x600): undefined reference to gic_enable_ppi' arch/arm/mach-shmobile/built-in.o: In function smp_init_cpus':
pfc-sh7372.c:(.init.text+0xbb0): undefined reference to `gic_raise_softirq'

In Thumb-2 mode:

LD .tmp_vmlinux1
arch/arm/kernel/built-in.o: In function `get_wchan':
io.c:(.text+0x1542): undefined reference to unwind_frame' arch/arm/kernel/built-in.o: In function walk_stackframe':
io.c:(.text+0x27f0): undefined reference to unwind_frame' arch/arm/kernel/built-in.o: In function profile_pc':
io.c:(.text+0x2828): undefined reference to unwind_frame' arch/arm/kernel/built-in.o: In function twd_timer_setup':
io.c:(.cpuinit.text+0x42e): undefined reference to gic_enable_ppi' arch/arm/mach-shmobile/built-in.o: In function smp_init_cpus':
pfc-sh7372.c:(.init.text+0x8e8): undefined reference to `gic_raise_softirq'

---
 arch/arm/mach-shmobile/hotplug.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)
arch/arm/mach-shmobile/hotplug.c +3 -7
index 238a0d9..1e83087 100644
@@ -13,6 +13,8 @@
 #include <linux/errno.h>
 #include <linux/smp.h>
 
+#include <asm/system.h>
+
 int platform_cpu_kill(unsigned int cpu)
 {
 	return 1;
@@ -21,13 +23,7 @@ int platform_cpu_kill(unsigned int cpu)
 void platform_cpu_die(unsigned int cpu)
 {
 	while (1) {
-		/*
-		 * here's the WFI
-		 */
-		asm(".word	0xe320f003\n"
-		    :
-		    :
-		    : "memory", "cc");
+		wfi();
 	}
 }
 
Signature · 1 line
1.7.3.4
#4 lore raw

PATCH 4/5 ARM: tegra: Use wfi macro in platform_do_lowpower.

In reply to Nick Bowler

Current Tegra CPU hotplug code includes a hardcoded WFI instruction, in ARM encoding. The hardcoded instruction is both hard to understand and doomed to failure when building the kernel in Thumb-2 mode.

---
Compile tested in ARM mode only as I could not build for this platform in Thumb-2 mode:

/scratch_space/linux-2.6/arch/arm/mach-tegra/headsmp.S: Assembler messages:
/scratch_space/linux-2.6/arch/arm/mach-tegra/headsmp.S:51: Error: Thumb encoding does not support an immediate here -- `msr cpsr_fsxc,#0xd3'

---
 arch/arm/mach-tegra/hotplug.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)
arch/arm/mach-tegra/hotplug.c +2 -7
index f329404..4fc72d6 100644
@@ -13,6 +13,7 @@
 #include <linux/smp.h>
 
 #include <asm/cacheflush.h>
+#include <asm/system.h>
 
 static inline void cpu_enter_lowpower(void)
 {
@@ -60,13 +61,7 @@ static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
 	 * code will have already disabled interrupts
 	 */
 	for (;;) {
-		/*
-		 * here's the WFI
-		 */
-		asm(".word	0xe320f003\n"
-		    :
-		    :
-		    : "memory", "cc");
+		wfi();
 
 		/*if (pen_release == cpu) {*/
 			/*
Signature · 1 line
1.7.3.4
#5 lore raw

PATCH 5/5 ARM: omap4: Kill private do_wfi macro.

In reply to Nick Bowler

The do_wfi macro duplicates the functionality of the wfi macro in common ARM code. Use the common version instead.

---
Compile tested in both ARM and Thumb-2 mode.

---
 arch/arm/mach-omap2/include/mach/omap4-common.h |   11 -----------
 arch/arm/mach-omap2/omap-hotplug.c              |    7 +++----
 arch/arm/mach-omap2/pm44xx.c                    |    4 +++-
 3 files changed, 6 insertions(+), 16 deletions(-)
arch/arm/mach-omap2/include/mach/omap4-common.h +0 -11
index e4bd87619..9e8c214 100644
@@ -13,17 +13,6 @@
 #ifndef OMAP_ARCH_OMAP4_COMMON_H
 #define OMAP_ARCH_OMAP4_COMMON_H
 
-/*
- * wfi used in low power code. Directly opcode is used instead
- * of instruction to avoid mulit-omap build break
- */
-#ifdef CONFIG_THUMB2_KERNEL
-#define do_wfi() __asm__ __volatile__ ("wfi" : : : "memory")
-#else
-#define do_wfi()			\
-		__asm__ __volatile__ (".word	0xe320f003" : : : "memory")
-#endif
-
 #ifdef CONFIG_CACHE_L2X0
 extern void __iomem *l2cache_base;
 #endif
arch/arm/mach-omap2/omap-hotplug.c +3 -4
index 4976b93..3a43eb8 100644
@@ -19,6 +19,8 @@
 #include <linux/smp.h>
 
 #include <asm/cacheflush.h>
+#include <asm/system.h>
+
 #include <mach/omap4-common.h>
 
 int platform_cpu_kill(unsigned int cpu)
@@ -42,10 +44,7 @@ void platform_cpu_die(unsigned int cpu)
 		printk(KERN_CRIT "Secure clear status failed\n");
 
 	for (;;) {
-		/*
-		 * Execute WFI
-		 */
-		do_wfi();
+		wfi();
 
 		if (omap_read_auxcoreboot0() == cpu) {
 			/*
arch/arm/mach-omap2/pm44xx.c +3 -1
index 59a870b..c741ad7 100644
@@ -16,6 +16,8 @@
 #include <linux/err.h>
 #include <linux/slab.h>
 
+#include <asm/system.h>
+
 #include "powerdomain.h"
 #include <mach/omap4-common.h>
 
@@ -33,7 +35,7 @@ static LIST_HEAD(pwrst_list);
 #ifdef CONFIG_SUSPEND
 static int omap4_pm_suspend(void)
 {
-	do_wfi();
+	wfi();
 	return 0;
 }
 
Signature · 1 line
1.7.3.4
#7 lore raw

PATCH 5/5 ARM: omap4: Kill private do_wfi macro.

Quoted 9 lines · Santosh
Quoted 6 lines · Nick Bowler

The do_wfi macro duplicates the functionality of the wfi macro in common ARM code. Use the common version instead.

---
Compile tested in both ARM and Thumb-2 mode.

Thanks but this is already handle in my PM series.

OK, I will drop this patch.

Thanks,

Signature · 1 line
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)
#8 lore raw

cover Convert ARM subarchitectures to generic wfi macro.

In reply to Nick Bowler

And after all that, I forgot to CC Russell on these patches. Oops.

Quoted 23 lines · Nick Bowler

This series cleans up all remaining ARM subarchitectures that I could find to use the generic wfi macro. As I don't have any of the boards in question, I've only compile-tested these patches to the extent that I was able.

See the previous discussion in https://lkml.org/lkml/2011/8/19/433 for more background.

Nick Bowler (5):
ARM: realview: Use wfi macro in platform_do_lowpower.
ARM: exynos4: Use wfi macro in platform_do_lowpower.
ARM: shmobile: Use wfi macro in platform_cpu_die.
ARM: tegra: Use wfi macro in platform_do_lowpower.
ARM: omap4: Kill private do_wfi macro.

 arch/arm/mach-exynos4/hotplug.c                 |    9 ++-------
 arch/arm/mach-omap2/include/mach/omap4-common.h |   11 -----------
 arch/arm/mach-omap2/omap-hotplug.c              |    7 +++----
 arch/arm/mach-omap2/pm44xx.c                    |    4 +++-
 arch/arm/mach-realview/hotplug.c                |    9 ++-------
 arch/arm/mach-shmobile/hotplug.c                |   10 +++-------
 arch/arm/mach-tegra/hotplug.c                   |    9 ++-------
 7 files changed, 15 insertions(+), 44 deletions(-)
Signature · 1 line
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)
#9 lore raw

cover Convert ARM subarchitectures to generic wfi macro.

Quoted 1 line · Nick Bowler

And after all that, I forgot to CC Russell on these patches. Oops.

Doesn't matter, I get them anyway (provided lakml is in the cc).