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

Stewart Smith stewart at linux.vnet.ibm.com
Tue Jul 19 19:00:23 AEST 2016


Balbir Singh <bsingharora at gmail.com> writes:
> 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)

That's a much better way to fix it!

Merged to master as of 8bc6cc59098d04bf6bfff7130f414418da496f38

-- 
Stewart Smith
OPAL Architect, IBM.



More information about the Skiboot mailing list