diff options
author | Christophe Leroy <christophe.leroy@csgroup.eu> | 2021-02-06 14:47:28 +0300 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2021-02-08 17:10:15 +0300 |
commit | b842d131c7983f8f0b9c9572c073130b5f2bcf11 (patch) | |
tree | 3b5cc31cc433681125fcc4d5be9b1acd59d79fee /arch | |
parent | 179ae57dbad1b9a83eec376aa44d54fc24352e37 (diff) | |
download | linux-b842d131c7983f8f0b9c9572c073130b5f2bcf11.tar.xz |
powerpc/32s: Allow constant folding in mtsr()/mfsr()
On the same way as we did in wrtee(), add an alternative
using mtsr/mfsr instructions instead of mtsrin/mfsrin
when the segment register can be determined at compile time.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/9baed0ff9d76723ec90f1b567ddd4ac1ecc7a190.1612612022.git.christophe.leroy@csgroup.eu
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/include/asm/reg.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h index 83a7fc37d490..eb4aa889916d 100644 --- a/arch/powerpc/include/asm/reg.h +++ b/arch/powerpc/include/asm/reg.h @@ -1417,14 +1417,20 @@ static inline u32 mfsr(u32 idx) { u32 val; - asm volatile("mfsrin %0, %1" : "=r" (val): "r" (idx)); + if (__builtin_constant_p(idx)) + asm volatile("mfsr %0, %1" : "=r" (val): "i" (idx >> 28)); + else + asm volatile("mfsrin %0, %1" : "=r" (val): "r" (idx)); return val; } static inline void mtsr(u32 val, u32 idx) { - asm volatile("mtsrin %0, %1" : : "r" (val), "r" (idx)); + if (__builtin_constant_p(idx)) + asm volatile("mtsr %1, %0" : : "r" (val), "i" (idx >> 28)); + else + asm volatile("mtsrin %0, %1" : : "r" (val), "r" (idx)); } #endif |