[Skiboot] [RFC PATCH] Use macros rather than static inline for mfspr and mtspr

Balbir Singh bsingharora at gmail.com
Tue Jul 19 13:08:41 AEST 2016


On Wed, Jul 13, 2016 at 04:20:38PM +1000, Stewart Smith wrote:
> Fixes building skiboot without optimization.
> 
> Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
> ---
>  include/processor.h | 27 +++++++++++++++------------
>  1 file changed, 15 insertions(+), 12 deletions(-)
>

From: Balbir Singh <bsingharora at gmail.com>
Date: Tue, 19 Jul 2016 13:04:08 +1000
Subject: [PATCH] Allow mt/mfspr to compile indepdent of the optimization level

The compiler expects to see a constant value in the asm operations
involving spr's. When compiling with -O0, spr is treated as a
variable on stack when inline (this can be seen from the RTL).

We do two things to fix the issue, we mark the functions as
always_inline and we pass spr as a const so that the value is
propagated as constants to the inline asm statement

Tested with -O0

Signed-off-by: Balbir Singh <bsingharora at gmail.com>
---
 include/processor.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/processor.h b/include/processor.h
index 48bbf90..caca804 100644
--- a/include/processor.h
+++ b/include/processor.h
@@ -235,7 +235,8 @@ static inline void mtmsrd(unsigned long val, int l)
 	asm volatile("mtmsrd %0,%1" : : "r"(val), "i"(l) : "memory");
 }
 
-static inline unsigned long mfspr(unsigned int spr)
+static inline __attribute__((always_inline))
+unsigned long mfspr(const unsigned int spr)
 {
 	unsigned long val;
 
@@ -243,7 +244,8 @@ static inline unsigned long mfspr(unsigned int spr)
 	return val;
 }
 
-static inline void mtspr(unsigned int spr, unsigned long val)
+static inline __attribute__((always_inline))
+void mtspr(const unsigned int spr, unsigned long val)
 {
 	asm volatile("mtspr %0,%1" : : "i"(spr), "r"(val) : "memory");
 }
-- 
2.5.5



More information about the Skiboot mailing list