ARM: Fix the "WFI" instruction opcode definition.
Subsystems (5)
PATCH 1/1 ARM: Fix the "WFI" instruction opcode definition.
The current "WFI" opcode definiton causes CPU hot-plug feature fails to work if the kernel is built with CONFIG_THUMB2_KERNEL/CONFIG_CPU_ENDIAN_BE8 being defined. An invalid instruction exception will be generated.
--- arch/arm/mach-exynos/hotplug.c | 8 +++++++- arch/arm/mach-realview/hotplug.c | 8 +++++++- arch/arm/mach-shmobile/hotplug.c | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-)
arch/arm/mach-exynos/hotplug.c +7 -1
@@ -18,11 +18,17 @@#include <asm/cacheflush.h> #include <asm/cp15.h> #include <asm/smp_plat.h> +#include <asm/opcodes.h> #include <mach/regs-pmu.h> #include "common.h" +/* +* Define opcode of the WFI instruction. +*/ +#define __WFI __inst_arm_thumb16(0xe320f003, 0xbf30) +static inline void cpu_enter_lowpower (void ) {unsigned int v;
@@ -72,7 +78,7 @@ static inline void platform_do_lowpower(unsigned int cpu, int *spurious)/* * here's the WFI */ - asm(".word 0xe320f003\n" + asm(__WFI : : : "memory", "cc");
arch/arm/mach-realview/hotplug.c +7 -1
@@ -15,6 +15,12 @@#include <asm/cacheflush.h> #include <asm/cp15.h> #include <asm/smp_plat.h> +#include <asm/opcodes.h> + +/* +* Define opcode of the WFI instruction. +*/ +#define __WFI __inst_arm_thumb16(0xe320f003, 0xbf30)static inline void cpu_enter_lowpower (void ) {
@@ -64,7 +70,7 @@ static inline void platform_do_lowpower(unsigned int cpu, int *spurious)/* * here's the WFI */ - asm(".word 0xe320f003\n" + asm(__WFI : : : "memory", "cc");
arch/arm/mach-shmobile/hotplug.c +7 -1
@@ -20,6 +20,12 @@#include <mach/emev2.h> #include <asm/cacheflush.h> #include <asm/mach-types.h> +#include <asm/opcodes.h> + +/* +* Define opcode of the WFI instruction. +*/ ++#define __WFI __inst_arm_thumb16(0xe320f003, 0xbf30)static cpumask_t dead_cpus;
@@ -39,7 +45,7 @@ void shmobile_cpu_die(unsigned int cpu)/* * here's the WFI */ - asm(".word 0xe320f003\n" + asm(__WFI : : : "memory", "cc");
--
Quoted 34 lines · Yangfei (Felix)
The current "WFI" opcode definiton causes CPU hot-plug feature fails to work if the kernel is built with CONFIG_THUMB2_KERNEL/CONFIG_CPU_ENDIAN_BE8 being defined. An invalid instruction exception will be generated.
Signed-off-by yangfei.kernel at gmail.com--- arch/arm/mach-exynos/hotplug.c | 8 +++++++- arch/arm/mach-realview/hotplug.c | 8 +++++++- arch/arm/mach-shmobile/hotplug.c | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-)arch/arm/mach-exynos/hotplug.c +6
-0@@ -18,11 +18,17 @@#include <asm/cacheflush.h> #include <asm/cp15.h> #include <asm/smp_plat.h> +#include <asm/opcodes.h> #include <mach/regs-pmu.h> #include "common.h" +/* +* Define opcode of the WFI instruction. +*/ +#define __WFI __inst_arm_thumb16(0xe320f003, 0xbf30) +static inline void cpu_enter_lowpower (void ) {unsigned int v;
arch/arm/mach-exynos/hotplug.c static inline void platform_do_lowpower(unsigned int cpu, int *spurious) · line 81
Quoted 5 lines
arch/arm/mach-exynos/hotplug.c +1
-1@@ -72,7 +78,7 @@ static inline void platform_do_lowpower(unsigned int cpu, int *spurious)/* * here's the WFI */ - asm(".word 0xe320f003\n" + asm(__WFI
Wouldn't using the actual wfi instruction fix this. There is a wfi() macro.
Or just call cpu_do_idle() which will do any other things needed before wfi like a dsb instruction.
Rob
Quoted 62 lines
arch/arm/mach-exynos/hotplug.c +0
-0: : : "memory", "cc");arch/arm/mach-realview/hotplug.c +7
-1@@ -15,6 +15,12 @@#include <asm/cacheflush.h> #include <asm/cp15.h> #include <asm/smp_plat.h> +#include <asm/opcodes.h> + +/* +* Define opcode of the WFI instruction. +*/ +#define __WFI __inst_arm_thumb16(0xe320f003, 0xbf30)static inline void cpu_enter_lowpower (void ) {@@ -64,7 +70,7 @@ static inline void platform_do_lowpower(unsigned int cpu, int *spurious)/* * here's the WFI */ - asm(".word 0xe320f003\n" + asm(__WFI : : : "memory", "cc");arch/arm/mach-shmobile/hotplug.c +7
-2@@ -20,6 +20,12 @@#include <mach/emev2.h> #include <asm/cacheflush.h> #include <asm/mach-types.h> +#include <asm/opcodes.h> + +/* +* Define opcode of the WFI instruction. +*/ ++#define __WFI __inst_arm_thumb16(0xe320f003, 0xbf30)static cpumask_t dead_cpus;@@ -39,7 +45,7 @@ void shmobile_cpu_die(unsigned int cpu)/* * here's the WFI */ - asm(".word 0xe320f003\n" + asm(__WFI : : : "memory", "cc"); --_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/1 ARM: Fix the "WFI" instruction opcode definition.
2012/11/1 Rob Herring <[email protected]>:
Quoted 48 lines · Yangfei (Felix)
Quoted 37 lines
The current "WFI" opcode definiton causes CPU hot-plug feature fails to work
if the kernel is built with CONFIG_THUMB2_KERNEL/CONFIG_CPU_ENDIAN_BE8 being
defined. An invalid instruction exception will be generated.Signed-off-by yangfei.kernel at gmail.com--- arch/arm/mach-exynos/hotplug.c | 8 +++++++- arch/arm/mach-realview/hotplug.c | 8 +++++++- arch/arm/mach-shmobile/hotplug.c | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-)arch/arm/mach-exynos/hotplug.c +6
-0@@ -18,11 +18,17 @@#include <asm/cacheflush.h> #include <asm/cp15.h> #include <asm/smp_plat.h> +#include <asm/opcodes.h> #include <mach/regs-pmu.h> #include "common.h" +/* +* Define opcode of the WFI instruction. +*/ +#define __WFI __inst_arm_thumb16(0xe320f003, 0xbf30) +static inline void cpu_enter_lowpower (void ) {unsigned int v;arch/arm/mach-exynos/hotplug.c static inline void platform_do_lowpower(unsigned int · line 82
Quoted 6 lines
arch/arm/mach-exynos/hotplug.c +1
-1@@ -72,7 +78,7 @@ static inline void platform_do_lowpower(unsigned int cpu, int *spurious)/* * here's the WFI */ - asm(".word 0xe320f003\n" + asm(__WFIWouldn't using the actual wfi instruction fix this. There is a
wfi()macro.
Quoted 7 lines
Or just call
cpu_do_idle()which will do any other things needed before wfi like a dsb instruction.Rob
Quoted 3 lines
arch/arm/mach-exynos/hotplug.c +0
-0: :: "memory", "cc");
<Cut>
Hi Rob,
Thanks for the reply. The way you suggested is more elegant. But
here we worried about the version of the compiler toolchain used to build the kernel. The "WFI" assembler instruction may not be recognized if the toolchain is too old. Need the related ARM board maintainers to confirm this.
PATCH 1/1 ARM: Fix the "WFI" instruction opcode definition.
Quoted 57 lines · Fei Yang
2012/11/1 Rob Herring <[email protected]>:
Quoted 48 lines · Yangfei (Felix)
Quoted 37 lines
The current "WFI" opcode definiton causes CPU hot-plug feature fails to work
if the kernel is built with CONFIG_THUMB2_KERNEL/CONFIG_CPU_ENDIAN_BE8 being
defined. An invalid instruction exception will be generated.Signed-off-by yangfei.kernel at gmail.com--- arch/arm/mach-exynos/hotplug.c | 8 +++++++- arch/arm/mach-realview/hotplug.c | 8 +++++++- arch/arm/mach-shmobile/hotplug.c | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-)arch/arm/mach-exynos/hotplug.c +6
-0@@ -18,11 +18,17 @@#include <asm/cacheflush.h> #include <asm/cp15.h> #include <asm/smp_plat.h> +#include <asm/opcodes.h> #include <mach/regs-pmu.h> #include "common.h" +/* +* Define opcode of the WFI instruction. +*/ +#define __WFI __inst_arm_thumb16(0xe320f003, 0xbf30) +static inline void cpu_enter_lowpower (void ) {unsigned int v;arch/arm/mach-exynos/hotplug.c static inline void platform_do_lowpower(unsigned int · line 82
Quoted 6 lines
arch/arm/mach-exynos/hotplug.c +1
-1@@ -72,7 +78,7 @@ static inline void platform_do_lowpower(unsigned int cpu, int *spurious)/* * here's the WFI */ - asm(".word 0xe320f003\n" + asm(__WFIWouldn't using the actual wfi instruction fix this. There is a
wfi()macro.Quoted 7 lines
Or just call
cpu_do_idle()which will do any other things needed before wfi like a dsb instruction.Rob
Quoted 3 lines
arch/arm/mach-exynos/hotplug.c +0
-0: :: "memory", "cc");
Quoted 8 lines
<Cut>
Hi Rob,
Thanks for the reply. The way you suggested is more elegant. But
here we worried about the version of the compiler toolchain used to build the kernel. The "WFI" assembler instruction may not be recognized if the toolchain is too old. Need the related ARM board maintainers to confirm this.
Maybe all the exynos platforms are new enough for this not to be a problem?
I think mach-exynos is pretty new and v7-only anyway. If so, then it may be better to put
CFLAGS_hotplug.o := -march=armv7-a
in arch/arm/mach-exynos/Makefile, and use the real "wfi" mnemonic directly. People should _really_ not be building kernels containig v7 board support with tools that are too old to support this.
Cheers
---Dave
PATCH 1/1 ARM: Fix the "WFI" instruction opcode definition.
Quoted 1 line · Dave Martin
[...]
Quoted 24 lines
Quoted 7 lines
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +1
-1- asm(".word 0xe320f003\n" + asm(__WFIWouldn't using the actual wfi instruction fix this. There is a
wfi()macro.Or just call
cpu_do_idle()which will do any other things neededbefore
Quoted 7 lines
Quoted 6 lines
wfi like a dsb instruction.
Rob
Quoted 3 lines
: : : "memory", "cc");Quoted 8 lines
<Cut>
Hi Rob,
Thanks for the reply. The way you suggested is more elegant. But
here we worried about the version of the compiler toolchain used to build the kernel. The "WFI" assembler instruction may not be recognized if the toolchain is too old. Need the related ARM board maintainers to confirm this.
Quoted 3 lines
Maybe all the exynos platforms are new enough for this not to be a problem?
Yeah, I think there is no problem on exynos now.
Quoted 1 line
I think mach-exynos is pretty new and v7-only anyway. If so, then it
Yes, right at the moment.
BTW, if mach-exynos includes ARMv8 later?...ARMv8 platform codes will be put in the arch/arm/ or arch/arm/64/ if some platform codes share with ARMv7? Just wondering...
Quoted 8 lines
may be better to put
CFLAGS_hotplug.o := -march=armv7-a
in
arch/arm/mach-exynos/Makefile, and use the real "wfi" mnemonic directly. People should _really_ not be building kernels containig v7 board support with tools that are too old to support this.
I think so...
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
PATCH 1/1 ARM: Fix the "WFI" instruction opcode definition.
Quoted 34 lines · Kukjin Kim
Quoted 1 line · Dave Martin
[...]
Quoted 24 lines
Quoted 7 lines
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +1
-1- asm(".word 0xe320f003\n" + asm(__WFIWouldn't using the actual wfi instruction fix this. There is a
wfi()macro.Or just call
cpu_do_idle()which will do any other things neededbefore
Quoted 7 lines
Quoted 6 lines
wfi like a dsb instruction.
Rob
Quoted 3 lines
: : : "memory", "cc");Quoted 8 lines
<Cut>
Hi Rob,
Thanks for the reply. The way you suggested is more elegant. But
here we worried about the version of the compiler toolchain used to build the kernel. The "WFI" assembler instruction may not be recognized if the toolchain is too old. Need the related ARM board maintainers to confirm this.Quoted 3 lines
Maybe all the exynos platforms are new enough for this not to be a problem?
Yeah, I think there is no problem on exynos now.
Quoted 7 lines
Quoted 1 line
I think mach-exynos is pretty new and v7-only anyway. If so, then it
Yes, right at the moment.
BTW, if mach-exynos includes ARMv8 later?...ARMv8 platform codes will be put in the
arch/arm/orarch/arm/64/if some platform codes share with ARMv7? Just wondering...
That's a question for Catalin, I guess.
Quoted 9 lines
Quoted 8 lines
may be better to put
CFLAGS_hotplug.o := -march=armv7-a
in
arch/arm/mach-exynos/Makefile, and use the real "wfi" mnemonic directly. People should _really_ not be building kernels containig v7 board support with tools that are too old to support this.I think so...
OK, thanks for commenting.
Cheers
---Dave
PATCH 1/1 ARM: Fix the "WFI" instruction opcode definition.
In reply to Kukjin KimQuoted 3 lines · Kukjin Kim
BTW, if mach-exynos includes ARMv8 later?...ARMv8 platform codes will be put in the
arch/arm/orarch/arm/64/if some platform codes share with ARMv7? Just wondering...
If mach-exynos would support ARMv8 at some point, I would expect most of the code to go under various drivers/ subsystems (mfd, power etc.). I don't see any point in using opcodes. For wfi just use a macro or cpu_do_idle() (as Rob said, it does the required dsb as well).
I'm also pushing for a standard hotplug.c implementation that is shared by multiple platforms and uses the power state coordination interface implemented by the firmware.
Signature · 1 line
Catalin