Some GCC versions (e.g. 4.8.3) can incorrectly inline a function with MIPS32 instructions into another function with MIPS16 code [1], causing the assembler to genereate incorrect binary code or fail right away complaining about unrecognized opcode. In the case of __arch_swab{16,32}, when inlined by the compiler with flags `-mips32r2 -mips16 -Os', the assembler can fail with the following error. {standard input}:79: Error: unrecognized opcode `wsbh $2,$2' For performance concerns and to workaround the issue already existing in older compilers, just ignore these 2 functions when compiling with mips16 enabled. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55777 Signed-off-by: Yousong Zhou <yszhou4tech@xxxxxxxxx> --- v2 <- v1 Also ignore __arch_swab64 instead of just __arch_swab{16,32}. arch/mips/include/uapi/asm/swab.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/mips/include/uapi/asm/swab.h b/arch/mips/include/uapi/asm/swab.h index 8f2d184..8b9a390 100644 --- a/arch/mips/include/uapi/asm/swab.h +++ b/arch/mips/include/uapi/asm/swab.h @@ -8,6 +8,11 @@ #ifndef _ASM_SWAB_H #define _ASM_SWAB_H +/* + * Enable the optimized version only when compiling without MIPS16. + */ +#ifndef __mips16 + #include <linux/compiler.h> #include <linux/types.h> @@ -66,4 +71,5 @@ static inline __attribute_const__ __u64 __arch_swab64(__u64 x) #define __arch_swab64 __arch_swab64 #endif /* __mips64 */ #endif /* MIPS R2 or newer or Loongson 3A */ +#endif /* ifndef __mips16 */ #endif /* _ASM_SWAB_H */ -- 1.7.10.4