Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ARC: Always use SWAPE instructions for __arch_swab32()

Since commit 67a697e7576 ("ARC: retire ARC750 support") all supported
CPUs have the 'swape' instruction.

Always use the implementation of __arch_swabe() which uses 'swape'.
ARCH_USE_BUILTIN_BSWAP can not be used as that results on libcalls on
-mcpu=arc700.

As as side-effect, remove a leak of an internal kconfig symbol through
the UAPI headers.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/lkml/0ae2688a-5a22-405b-adaf-9b5ad712b245@app.fastmail.com/
Suggested-by: Vineet Gupta <vgupta@kernel.org>
Link: https://lore.kernel.org/lkml/a033a402-e3c5-4982-9fff-b6a4c55817ae@kernel.org/
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

authored by

Thomas Weißschuh and committed by
Arnd Bergmann
b4171fd0 eed444d0

+1 -71
-5
arch/arc/Kconfig
··· 121 121 config ARC_CPU_770 122 122 bool "ARC770" 123 123 depends on ISA_ARCOMPACT 124 - select ARC_HAS_SWAPE 125 124 help 126 125 Support for ARC770 core introduced with Rel 4.10 (Summer 2011) 127 126 This core has a bunch of cool new features: ··· 338 339 bool "Insn: LLOCK/SCOND (efficient atomic ops)" 339 340 default y 340 341 depends on !ARC_CANT_LLSC 341 - 342 - config ARC_HAS_SWAPE 343 - bool "Insn: SWAPE (endian-swap)" 344 - default y 345 342 346 343 if ISA_ARCV2 347 344
+1 -2
arch/arc/Makefile
··· 9 9 CROSS_COMPILE := $(call cc-cross-prefix, arc-linux- arceb-linux- arc-linux-gnu-) 10 10 endif 11 11 12 - cflags-y += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__ 12 + cflags-y += -fno-common -pipe -fno-builtin -mmedium-calls -mswape -D__linux__ 13 13 14 14 tune-mcpu-def-$(CONFIG_ISA_ARCOMPACT) := -mcpu=arc700 15 15 tune-mcpu-def-$(CONFIG_ISA_ARCV2) := -mcpu=hs38 ··· 41 41 cflags-y += -fsection-anchors 42 42 43 43 cflags-$(CONFIG_ARC_HAS_LLSC) += -mlock 44 - cflags-$(CONFIG_ARC_HAS_SWAPE) += -mswape 45 44 46 45 ifdef CONFIG_ISA_ARCV2 47 46
-63
arch/arc/include/uapi/asm/swab.h
··· 19 19 20 20 #include <linux/types.h> 21 21 22 - /* Native single cycle endian swap insn */ 23 - #ifdef CONFIG_ARC_HAS_SWAPE 24 - 25 22 #define __arch_swab32(x) \ 26 23 ({ \ 27 24 unsigned int tmp = x; \ ··· 28 31 : "r" (tmp)); \ 29 32 tmp; \ 30 33 }) 31 - 32 - #else 33 - 34 - /* Several ways of Endian-Swap Emulation for ARC 35 - * 0: kernel generic 36 - * 1: ARC optimised "C" 37 - * 2: ARC Custom instruction 38 - */ 39 - #define ARC_BSWAP_TYPE 1 40 - 41 - #if (ARC_BSWAP_TYPE == 1) /******* Software only ********/ 42 - 43 - /* The kernel default implementation of htonl is 44 - * return x<<24 | x>>24 | 45 - * (x & (__u32)0x0000ff00UL)<<8 | (x & (__u32)0x00ff0000UL)>>8; 46 - * 47 - * This generates 9 instructions on ARC (excluding the ld/st) 48 - * 49 - * 8051fd8c: ld r3,[r7,20] ; Mem op : Get the value to be swapped 50 - * 8051fd98: asl r5,r3,24 ; get 3rd Byte 51 - * 8051fd9c: lsr r2,r3,24 ; get 0th Byte 52 - * 8051fda0: and r4,r3,0xff00 53 - * 8051fda8: asl r4,r4,8 ; get 1st Byte 54 - * 8051fdac: and r3,r3,0x00ff0000 55 - * 8051fdb4: or r2,r2,r5 ; combine 0th and 3rd Bytes 56 - * 8051fdb8: lsr r3,r3,8 ; 2nd Byte at correct place in Dst Reg 57 - * 8051fdbc: or r2,r2,r4 ; combine 0,3 Bytes with 1st Byte 58 - * 8051fdc0: or r2,r2,r3 ; combine 0,3,1 Bytes with 2nd Byte 59 - * 8051fdc4: st r2,[r1,20] ; Mem op : save result back to mem 60 - * 61 - * Joern suggested a better "C" algorithm which is great since 62 - * (1) It is portable to any architecture 63 - * (2) At the same time it takes advantage of ARC ISA (rotate intrns) 64 - */ 65 - 66 - #define __arch_swab32(x) \ 67 - ({ unsigned long __in = (x), __tmp; \ 68 - __tmp = __in << 8 | __in >> 24; /* ror tmp,in,24 */ \ 69 - __in = __in << 24 | __in >> 8; /* ror in,in,8 */ \ 70 - __tmp ^= __in; \ 71 - __tmp &= 0xff00ff; \ 72 - __tmp ^ __in; \ 73 - }) 74 - 75 - #elif (ARC_BSWAP_TYPE == 2) /* Custom single cycle bswap instruction */ 76 - 77 - #define __arch_swab32(x) \ 78 - ({ \ 79 - unsigned int tmp = x; \ 80 - __asm__( \ 81 - " .extInstruction bswap, 7, 0x00, SUFFIX_NONE, SYNTAX_2OP \n"\ 82 - " bswap %0, %1 \n"\ 83 - : "=r" (tmp) \ 84 - : "r" (tmp)); \ 85 - tmp; \ 86 - }) 87 - 88 - #endif /* ARC_BSWAP_TYPE=zzz */ 89 - 90 - #endif /* CONFIG_ARC_HAS_SWAPE */ 91 34 92 35 #if !defined(__STRICT_ANSI__) || defined(__KERNEL__) 93 36 #define __SWAB_64_THRU_32__
-1
scripts/headers_install.sh
··· 70 70 # 71 71 # The format is <file-name>:<CONFIG-option> in each line. 72 72 config_leak_ignores=" 73 - arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE 74 73 arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8 75 74 arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO 76 75 arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT