Skip to content

Commit 67512a8

Browse files
pcercueitsbogend
authored andcommitted
MIPS: Avoid macro redefinitions
To be able to compile the kernel with LTO, the assembler macros cannot be declared in the global scope, or the compiler will complain about redefined macros. Update the code so that macros are defined then undefined when they are used. Note that virt support was added in 2.24 and xpa in 2.25. So we still need the TOOLCHAIN defines for them. Signed-off-by: Paul Cercueil <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 8e16049 commit 67512a8

File tree

4 files changed

+155
-92
lines changed

4 files changed

+155
-92
lines changed

arch/mips/include/asm/ginvt.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ enum ginvt_type {
1212

1313
#ifdef TOOLCHAIN_SUPPORTS_GINV
1414
# define _ASM_SET_GINV ".set ginv\n"
15+
# define _ASM_UNSET_GINV
1516
#else
16-
_ASM_MACRO_1R1I(ginvt, rs, type,
17-
_ASM_INSN_IF_MIPS(0x7c0000bd | (__rs << 21) | (\\type << 8))
18-
_ASM_INSN32_IF_MM(0x0000717c | (__rs << 16) | (\\type << 9)));
19-
# define _ASM_SET_GINV
17+
# define _ASM_SET_GINV \
18+
_ASM_MACRO_1R1I(ginvt, rs, type, \
19+
_ASM_INSN_IF_MIPS(0x7c0000bd | (__rs << 21) | (\\type << 8)) \
20+
_ASM_INSN32_IF_MM(0x0000717c | (__rs << 16) | (\\type << 9)))
21+
# define _ASM_UNSET_GINV ".purgem ginvt\n"
2022
#endif
2123

2224
static __always_inline void ginvt(unsigned long addr, enum ginvt_type type)
@@ -25,6 +27,7 @@ static __always_inline void ginvt(unsigned long addr, enum ginvt_type type)
2527
".set push\n"
2628
_ASM_SET_GINV
2729
" ginvt %0, %1\n"
30+
_ASM_UNSET_GINV
2831
".set pop"
2932
: /* no outputs */
3033
: "r"(addr), "i"(type)

arch/mips/include/asm/mach-loongson64/loongson_regs.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ static inline u32 read_cpucfg(u32 reg)
2121
u32 __res;
2222

2323
__asm__ __volatile__(
24+
_ASM_SET_PARSE_R
2425
"parse_r __res,%0\n\t"
2526
"parse_r reg,%1\n\t"
27+
_ASM_UNSET_PARSE_R
2628
".insn \n\t"
2729
".word (0xc8080118 | (reg << 21) | (__res << 11))\n\t"
2830
:"=r"(__res)
@@ -143,8 +145,10 @@ static inline u32 csr_readl(u32 reg)
143145

144146
/* RDCSR reg, val */
145147
__asm__ __volatile__(
148+
_ASM_SET_PARSE_R
146149
"parse_r __res,%0\n\t"
147150
"parse_r reg,%1\n\t"
151+
_ASM_UNSET_PARSE_R
148152
".insn \n\t"
149153
".word (0xc8000118 | (reg << 21) | (__res << 11))\n\t"
150154
:"=r"(__res)
@@ -160,8 +164,10 @@ static inline u64 csr_readq(u32 reg)
160164

161165
/* DRDCSR reg, val */
162166
__asm__ __volatile__(
167+
_ASM_SET_PARSE_R
163168
"parse_r __res,%0\n\t"
164169
"parse_r reg,%1\n\t"
170+
_ASM_UNSET_PARSE_R
165171
".insn \n\t"
166172
".word (0xc8020118 | (reg << 21) | (__res << 11))\n\t"
167173
:"=r"(__res)
@@ -175,8 +181,10 @@ static inline void csr_writel(u32 val, u32 reg)
175181
{
176182
/* WRCSR reg, val */
177183
__asm__ __volatile__(
184+
_ASM_SET_PARSE_R
178185
"parse_r reg,%0\n\t"
179186
"parse_r val,%1\n\t"
187+
_ASM_UNSET_PARSE_R
180188
".insn \n\t"
181189
".word (0xc8010118 | (reg << 21) | (val << 11))\n\t"
182190
:
@@ -189,8 +197,10 @@ static inline void csr_writeq(u64 val, u32 reg)
189197
{
190198
/* DWRCSR reg, val */
191199
__asm__ __volatile__(
200+
_ASM_SET_PARSE_R
192201
"parse_r reg,%0\n\t"
193202
"parse_r val,%1\n\t"
203+
_ASM_UNSET_PARSE_R
194204
".insn \n\t"
195205
".word (0xc8030118 | (reg << 21) | (val << 11))\n\t"
196206
:
@@ -243,8 +253,10 @@ static inline u64 drdtime(void)
243253
u64 val = 0;
244254

245255
__asm__ __volatile__(
256+
_ASM_SET_PARSE_R
246257
"parse_r rID,%0\n\t"
247258
"parse_r val,%1\n\t"
259+
_ASM_UNSET_PARSE_R
248260
".insn \n\t"
249261
".word (0xc8090118 | (rID << 21) | (val << 11))\n\t"
250262
:"=r"(rID),"=r"(val)

0 commit comments

Comments
 (0)