diff mbox

[U-Boot,1/2] ARM: add wfi assembly macro

Message ID 1354503982-1124-1-git-send-email-robherring2@gmail.com
State Accepted
Delegated to: Albert ARIBAUD
Headers show

Commit Message

Rob Herring Dec. 3, 2012, 3:06 a.m. UTC
From: Rob Herring <rob.herring@calxeda.com>

Since wfi instruction is only available on ARMv7, add a conditional
macro for it.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/include/asm/system.h |    6 ++++++
 1 file changed, 6 insertions(+)

Comments

Marek Vasut Dec. 3, 2012, 4:58 a.m. UTC | #1
Dear Rob Herring,

> From: Rob Herring <rob.herring@calxeda.com>
> 
> Since wfi instruction is only available on ARMv7, add a conditional
> macro for it.
> 
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> ---
>  arch/arm/include/asm/system.h |    6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
> index 2b28a26..2f6aecd 100644
> --- a/arch/arm/include/asm/system.h
> +++ b/arch/arm/include/asm/system.h
> @@ -61,6 +61,12 @@
> 
>  #define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
> 
> +#ifdef __ARM_ARCH_7A__
> +#define wfi() __asm__ __volatile__ ("wfi" : : : "memory")
> +#else
> +#define wfi()
> +#endif

Won't this break other (non-arm) systems? Moreover, maybe you can make this an 
(inline) function instead?

>  static inline unsigned int get_cr(void)
>  {
>  	unsigned int val;

Best regards,
Marek Vasut
Rob Herring Dec. 3, 2012, 1:32 p.m. UTC | #2
On 12/02/2012 10:58 PM, Marek Vasut wrote:
> Dear Rob Herring,
> 
>> From: Rob Herring <rob.herring@calxeda.com>
>>
>> Since wfi instruction is only available on ARMv7, add a conditional
>> macro for it.
>>
>> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
>> ---
>>  arch/arm/include/asm/system.h |    6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
>> index 2b28a26..2f6aecd 100644
>> --- a/arch/arm/include/asm/system.h
>> +++ b/arch/arm/include/asm/system.h
>> @@ -61,6 +61,12 @@
>>
>>  #define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
>>
>> +#ifdef __ARM_ARCH_7A__
>> +#define wfi() __asm__ __volatile__ ("wfi" : : : "memory")
>> +#else
>> +#define wfi()
>> +#endif
> 
> Won't this break other (non-arm) systems? Moreover, maybe you can make this an 
> (inline) function instead?

How? It is in an ARM specific header and empty on anything but ARMv7
enabled compiler. This follows the kernel implementation and the nop above.

Rob

> 
>>  static inline unsigned int get_cr(void)
>>  {
>>  	unsigned int val;
> 
> Best regards,
> Marek Vasut
>
Marek Vasut Dec. 3, 2012, 2:39 p.m. UTC | #3
Dear Rob Herring,

> On 12/02/2012 10:58 PM, Marek Vasut wrote:
> > Dear Rob Herring,
> > 
> >> From: Rob Herring <rob.herring@calxeda.com>
> >> 
> >> Since wfi instruction is only available on ARMv7, add a conditional
> >> macro for it.
> >> 
> >> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> >> ---
> >> 
> >>  arch/arm/include/asm/system.h |    6 ++++++
> >>  1 file changed, 6 insertions(+)
> >> 
> >> diff --git a/arch/arm/include/asm/system.h
> >> b/arch/arm/include/asm/system.h index 2b28a26..2f6aecd 100644
> >> --- a/arch/arm/include/asm/system.h
> >> +++ b/arch/arm/include/asm/system.h
> >> @@ -61,6 +61,12 @@
> >> 
> >>  #define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
> >> 
> >> +#ifdef __ARM_ARCH_7A__
> >> +#define wfi() __asm__ __volatile__ ("wfi" : : : "memory")
> >> +#else
> >> +#define wfi()
> >> +#endif
> > 
> > Won't this break other (non-arm) systems? Moreover, maybe you can make
> > this an (inline) function instead?
> 
> How? It is in an ARM specific header and empty on anything but ARMv7
> enabled compiler. This follows the kernel implementation and the nop above.

Ok, I missed the arch/arm. It's ok then, sorry for the noise.
[...]

Best regards,
Marek Vasut
Albert ARIBAUD Feb. 3, 2013, 2:29 p.m. UTC | #4
Hi Rob,

On Sun,  2 Dec 2012 21:06:21 -0600, Rob Herring <robherring2@gmail.com>
wrote:

> From: Rob Herring <rob.herring@calxeda.com>
> 
> Since wfi instruction is only available on ARMv7, add a conditional
> macro for it.
> 
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> ---
>  arch/arm/include/asm/system.h |    6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
> index 2b28a26..2f6aecd 100644
> --- a/arch/arm/include/asm/system.h
> +++ b/arch/arm/include/asm/system.h
> @@ -61,6 +61,12 @@
>  
>  #define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
>  
> +#ifdef __ARM_ARCH_7A__
> +#define wfi() __asm__ __volatile__ ("wfi" : : : "memory")
> +#else
> +#define wfi()
> +#endif
> +
>  static inline unsigned int get_cr(void)
>  {
>  	unsigned int val;

Applied to u-boot-arm/master, thanks!

Amicalement,
diff mbox

Patch

diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 2b28a26..2f6aecd 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -61,6 +61,12 @@ 
 
 #define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
 
+#ifdef __ARM_ARCH_7A__
+#define wfi() __asm__ __volatile__ ("wfi" : : : "memory")
+#else
+#define wfi()
+#endif
+
 static inline unsigned int get_cr(void)
 {
 	unsigned int val;