Message ID | 1313777004-4716-1-git-send-email-nbowler@elliptictech.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi Nick, On Fri, Aug 19, 2011 at 02:03:24PM -0400, Nick Bowler wrote: > Current Versatile Express CPU hotplug code includes a hardcoded WFI > instruction, in ARM encoding. When the kernel is compiled in Thumb-2 > mode, this is invalid and causes the machine to hang hard when a CPU > is offlined. > > Using the assembler mnemonic instead of hardcoding it causes the correct > instruction to be emitted in either case. > > Signed-off-by: Nick Bowler <nbowler@elliptictech.com> > --- > arch/arm/mach-vexpress/hotplug.c | 5 +---- > 1 files changed, 1 insertions(+), 4 deletions(-) > > OK. I assume that the reason for the hardcoded instruction is that > older versions of binutils did not support the mnemonic. Looking at the > binutils CVS history, support seems to have been added in 2005, and was > included in the 2.16 release. If we care about those old assembler > versions, I can resubmit this patch using ARM/THUMB macros instead, > which should work just as well. > > I imagine that other platforms which use this same construct, such as > realview, will have similar problems in thumb mode. I can't test > changes on those platforms, unfortunately. > > diff --git a/arch/arm/mach-vexpress/hotplug.c b/arch/arm/mach-vexpress/hotplug.c > index ea4cbfb..d6be197 100644 > --- a/arch/arm/mach-vexpress/hotplug.c > +++ b/arch/arm/mach-vexpress/hotplug.c > @@ -62,10 +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" > + asm("wfi\n" > : > : > : "memory", "cc"); There's a wfi() macro defined in arch/arm/include/asm/system.h that could be used here. Jamie
On 2011-08-19 19:15 +0100, Jamie Iles wrote: > On Fri, Aug 19, 2011 at 02:03:24PM -0400, Nick Bowler wrote: [...] > > - /* > > - * here's the WFI > > - */ > > - asm(".word 0xe320f003\n" > > + asm("wfi\n" > > : > > : > > : "memory", "cc"); > > There's a wfi() macro defined in arch/arm/include/asm/system.h that > could be used here. Indeed, thanks for pointing that out. I'm a little wary, however: the wfi macro does not include the "cc" clobber that this code has currently, and I don't know what the implications of removing it are. There appears to be no current users of the wfi macro. Taking a closer look, there appear to be five platforms that have a hardcoded WFI just like the above (including the "cc" clobber): exynos4, realview, shmobile, tegra and vexpress. omap defines its own do_wfi macro, *without* the "cc" clobber. Nevertheless, using the macro seems to work just fine, so I can certainly re-spin the patch with that instead.
On Fri, Aug 19, 2011 at 03:26:38PM -0400, Nick Bowler wrote: > On 2011-08-19 19:15 +0100, Jamie Iles wrote: > > On Fri, Aug 19, 2011 at 02:03:24PM -0400, Nick Bowler wrote: > [...] > > > - /* > > > - * here's the WFI > > > - */ > > > - asm(".word 0xe320f003\n" > > > + asm("wfi\n" > > > : > > > : > > > : "memory", "cc"); > > > > There's a wfi() macro defined in arch/arm/include/asm/system.h that > > could be used here. > > Indeed, thanks for pointing that out. > > I'm a little wary, however: the wfi macro does not include the "cc" > clobber that this code has currently, and I don't know what the > implications of removing it are. There appears to be no current > users of the wfi macro. As far as I can tell from the ARM ARM, the instruction shouldn't alter the condition flags so the cc clobber shouldn't be necessary. I'm not sure that my reading of the ARM ARM should be considered authoritative though! Jamie
On 19 August 2011 22:14, Jamie Iles <jamie@jamieiles.com> wrote: > On Fri, Aug 19, 2011 at 03:26:38PM -0400, Nick Bowler wrote: >> On 2011-08-19 19:15 +0100, Jamie Iles wrote: >> > On Fri, Aug 19, 2011 at 02:03:24PM -0400, Nick Bowler wrote: >> [...] >> > > - /* >> > > - * here's the WFI >> > > - */ >> > > - asm(".word 0xe320f003\n" >> > > + asm("wfi\n" >> > > : >> > > : >> > > : "memory", "cc"); >> > >> > There's a wfi() macro defined in arch/arm/include/asm/system.h that >> > could be used here. >> >> Indeed, thanks for pointing that out. >> >> I'm a little wary, however: the wfi macro does not include the "cc" >> clobber that this code has currently, and I don't know what the >> implications of removing it are. There appears to be no current >> users of the wfi macro. > > As far as I can tell from the ARM ARM, the instruction shouldn't alter > the condition flags so the cc clobber shouldn't be necessary. I also don't see why we need the 'cc' flag in here. Just use the wfi() macro.
diff --git a/arch/arm/mach-vexpress/hotplug.c b/arch/arm/mach-vexpress/hotplug.c index ea4cbfb..d6be197 100644 --- a/arch/arm/mach-vexpress/hotplug.c +++ b/arch/arm/mach-vexpress/hotplug.c @@ -62,10 +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" + asm("wfi\n" : : : "memory", "cc");
Current Versatile Express CPU hotplug code includes a hardcoded WFI instruction, in ARM encoding. When the kernel is compiled in Thumb-2 mode, this is invalid and causes the machine to hang hard when a CPU is offlined. Using the assembler mnemonic instead of hardcoding it causes the correct instruction to be emitted in either case. Signed-off-by: Nick Bowler <nbowler@elliptictech.com> --- arch/arm/mach-vexpress/hotplug.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) OK. I assume that the reason for the hardcoded instruction is that older versions of binutils did not support the mnemonic. Looking at the binutils CVS history, support seems to have been added in 2005, and was included in the 2.16 release. If we care about those old assembler versions, I can resubmit this patch using ARM/THUMB macros instead, which should work just as well. I imagine that other platforms which use this same construct, such as realview, will have similar problems in thumb mode. I can't test changes on those platforms, unfortunately.