[PATCH v2] ARM: Define wfi() macro for v6 processors

Arnd Bergmann arnd at arndb.de
Tue Feb 8 10:42:52 EST 2011


On Tuesday 08 February 2011, Dave Martin wrote:
> Why not have macros for these cases?  (Which kinda brings the
> discussion full-circle...)
> 
> My immediate concern is that too often, the Thumb-2 case will be
> handled incorrectly or not at all ... and the kernel will silently
> build without flagging any error.  Macros would allow the fragile
> definitions to go in one place.

A macro to handle the thumb2 case and weird toolchains sounds good,
but if we want to build code for multiple CPUs, we need multiple
macros, not one macro that works on a specific CPU.

We could put all those macros unconditionally into a arch
specific header, e.g.

arch/arm/include/asm/system-v7.h:
#define wfi() __asm__ __volatile__ ("wfi" : : : "memory")


arch/arm/include/asm/system-v6k.h:
#define wfi() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c0, 4" \
		: : "r" (0) : "memory")

And then have each C file using them be CPU specific and include
only one (you get an gcc warning if you try to include both).
This should work fine, but it's different again from how we handle
other things like spinlocks or cache management across multiple
CPUs.

	Arnd



More information about the linux-arm-kernel mailing list