Skip to content

Commit b4171fd

Browse files
t-8charndb
authored andcommitted
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>
1 parent eed444d commit b4171fd

4 files changed

Lines changed: 1 addition & 71 deletions

File tree

arch/arc/Kconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ choice
121121
config ARC_CPU_770
122122
bool "ARC770"
123123
depends on ISA_ARCOMPACT
124-
select ARC_HAS_SWAPE
125124
help
126125
Support for ARC770 core introduced with Rel 4.10 (Summer 2011)
127126
This core has a bunch of cool new features:
@@ -340,10 +339,6 @@ config ARC_HAS_LLSC
340339
default y
341340
depends on !ARC_CANT_LLSC
342341

343-
config ARC_HAS_SWAPE
344-
bool "Insn: SWAPE (endian-swap)"
345-
default y
346-
347342
if ISA_ARCV2
348343

349344
config ARC_USE_UNALIGNED_MEM_ACCESS

arch/arc/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ifeq ($(CROSS_COMPILE),)
99
CROSS_COMPILE := $(call cc-cross-prefix, arc-linux- arceb-linux- arc-linux-gnu-)
1010
endif
1111

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__
1313

1414
tune-mcpu-def-$(CONFIG_ISA_ARCOMPACT) := -mcpu=arc700
1515
tune-mcpu-def-$(CONFIG_ISA_ARCV2) := -mcpu=hs38
@@ -41,7 +41,6 @@ endif
4141
cflags-y += -fsection-anchors
4242

4343
cflags-$(CONFIG_ARC_HAS_LLSC) += -mlock
44-
cflags-$(CONFIG_ARC_HAS_SWAPE) += -mswape
4544

4645
ifdef CONFIG_ISA_ARCV2
4746

arch/arc/include/uapi/asm/swab.h

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919

2020
#include <linux/types.h>
2121

22-
/* Native single cycle endian swap insn */
23-
#ifdef CONFIG_ARC_HAS_SWAPE
24-
2522
#define __arch_swab32(x) \
2623
({ \
2724
unsigned int tmp = x; \
@@ -32,66 +29,6 @@
3229
tmp; \
3330
})
3431

35-
#else
36-
37-
/* Several ways of Endian-Swap Emulation for ARC
38-
* 0: kernel generic
39-
* 1: ARC optimised "C"
40-
* 2: ARC Custom instruction
41-
*/
42-
#define ARC_BSWAP_TYPE 1
43-
44-
#if (ARC_BSWAP_TYPE == 1) /******* Software only ********/
45-
46-
/* The kernel default implementation of htonl is
47-
* return x<<24 | x>>24 |
48-
* (x & (__u32)0x0000ff00UL)<<8 | (x & (__u32)0x00ff0000UL)>>8;
49-
*
50-
* This generates 9 instructions on ARC (excluding the ld/st)
51-
*
52-
* 8051fd8c: ld r3,[r7,20] ; Mem op : Get the value to be swapped
53-
* 8051fd98: asl r5,r3,24 ; get 3rd Byte
54-
* 8051fd9c: lsr r2,r3,24 ; get 0th Byte
55-
* 8051fda0: and r4,r3,0xff00
56-
* 8051fda8: asl r4,r4,8 ; get 1st Byte
57-
* 8051fdac: and r3,r3,0x00ff0000
58-
* 8051fdb4: or r2,r2,r5 ; combine 0th and 3rd Bytes
59-
* 8051fdb8: lsr r3,r3,8 ; 2nd Byte at correct place in Dst Reg
60-
* 8051fdbc: or r2,r2,r4 ; combine 0,3 Bytes with 1st Byte
61-
* 8051fdc0: or r2,r2,r3 ; combine 0,3,1 Bytes with 2nd Byte
62-
* 8051fdc4: st r2,[r1,20] ; Mem op : save result back to mem
63-
*
64-
* Joern suggested a better "C" algorithm which is great since
65-
* (1) It is portable to any architecture
66-
* (2) At the same time it takes advantage of ARC ISA (rotate intrns)
67-
*/
68-
69-
#define __arch_swab32(x) \
70-
({ unsigned long __in = (x), __tmp; \
71-
__tmp = __in << 8 | __in >> 24; /* ror tmp,in,24 */ \
72-
__in = __in << 24 | __in >> 8; /* ror in,in,8 */ \
73-
__tmp ^= __in; \
74-
__tmp &= 0xff00ff; \
75-
__tmp ^ __in; \
76-
})
77-
78-
#elif (ARC_BSWAP_TYPE == 2) /* Custom single cycle bswap instruction */
79-
80-
#define __arch_swab32(x) \
81-
({ \
82-
unsigned int tmp = x; \
83-
__asm__( \
84-
" .extInstruction bswap, 7, 0x00, SUFFIX_NONE, SYNTAX_2OP \n"\
85-
" bswap %0, %1 \n"\
86-
: "=r" (tmp) \
87-
: "r" (tmp)); \
88-
tmp; \
89-
})
90-
91-
#endif /* ARC_BSWAP_TYPE=zzz */
92-
93-
#endif /* CONFIG_ARC_HAS_SWAPE */
94-
9532
#if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
9633
#define __SWAB_64_THRU_32__
9734
#endif

scripts/headers_install.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ configs=$(sed -e '
7070
#
7171
# The format is <file-name>:<CONFIG-option> in each line.
7272
config_leak_ignores="
73-
arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE
7473
arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8
7574
arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO
7675
arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT

0 commit comments

Comments
 (0)