diff options
author | Chen Jie <chenj@lemote.com> | 2014-08-15 04:56:58 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-09-22 07:35:46 -0400 |
commit | 3c09bae43ba92a07a6a7b7d42360deb32d289cc0 (patch) | |
tree | 7648425d5b309e76a60612ca46ba4b88bfdf729b | |
parent | 0f33be009b89d2268e94194dc4fd01a7851b6d51 (diff) |
MIPS: Use WSBH/DSBH/DSHD on Loongson 3A
Signed-off-by: chenj <chenj@lemote.com>
Cc: linux-mips@linux-mips.org
Cc: chenhc@lemote.com
Patchwork: https://patchwork.linux-mips.org/patch/7542/
Patchwork: https://patchwork.linux-mips.org/patch/7550/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/include/asm/cpu-features.h | 10 | ||||
-rw-r--r-- | arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h | 1 | ||||
-rw-r--r-- | arch/mips/include/asm/mach-loongson/cpu-feature-overrides.h | 2 | ||||
-rw-r--r-- | arch/mips/include/uapi/asm/swab.h | 18 | ||||
-rw-r--r-- | arch/mips/lib/csum_partial.S | 10 | ||||
-rw-r--r-- | arch/mips/net/bpf_jit.c | 2 |
6 files changed, 36 insertions, 7 deletions
diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h index e079598ae051..3325f3eb248c 100644 --- a/arch/mips/include/asm/cpu-features.h +++ b/arch/mips/include/asm/cpu-features.h | |||
@@ -231,6 +231,16 @@ | |||
231 | #define cpu_has_clo_clz cpu_has_mips_r | 231 | #define cpu_has_clo_clz cpu_has_mips_r |
232 | #endif | 232 | #endif |
233 | 233 | ||
234 | /* | ||
235 | * MIPS32 R2, MIPS64 R2, Loongson 3A and Octeon have WSBH. | ||
236 | * MIPS64 R2, Loongson 3A and Octeon have WSBH, DSBH and DSHD. | ||
237 | * This indicates the availability of WSBH and in case of 64 bit CPUs also | ||
238 | * DSBH and DSHD. | ||
239 | */ | ||
240 | #ifndef cpu_has_wsbh | ||
241 | #define cpu_has_wsbh cpu_has_mips_r2 | ||
242 | #endif | ||
243 | |||
234 | #ifndef cpu_has_dsp | 244 | #ifndef cpu_has_dsp |
235 | #define cpu_has_dsp (cpu_data[0].ases & MIPS_ASE_DSP) | 245 | #define cpu_has_dsp (cpu_data[0].ases & MIPS_ASE_DSP) |
236 | #endif | 246 | #endif |
diff --git a/arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h b/arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h index cf8022872892..fa1f3cfbae8d 100644 --- a/arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h +++ b/arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h | |||
@@ -57,6 +57,7 @@ | |||
57 | #define cpu_has_vint 0 | 57 | #define cpu_has_vint 0 |
58 | #define cpu_has_veic 0 | 58 | #define cpu_has_veic 0 |
59 | #define cpu_hwrena_impl_bits 0xc0000000 | 59 | #define cpu_hwrena_impl_bits 0xc0000000 |
60 | #define cpu_has_wsbh 1 | ||
60 | 61 | ||
61 | #define cpu_has_rixi (cpu_data[0].cputype != CPU_CAVIUM_OCTEON) | 62 | #define cpu_has_rixi (cpu_data[0].cputype != CPU_CAVIUM_OCTEON) |
62 | 63 | ||
diff --git a/arch/mips/include/asm/mach-loongson/cpu-feature-overrides.h b/arch/mips/include/asm/mach-loongson/cpu-feature-overrides.h index c0f3ef45c2c1..7d28f95b0512 100644 --- a/arch/mips/include/asm/mach-loongson/cpu-feature-overrides.h +++ b/arch/mips/include/asm/mach-loongson/cpu-feature-overrides.h | |||
@@ -59,4 +59,6 @@ | |||
59 | #define cpu_has_watch 1 | 59 | #define cpu_has_watch 1 |
60 | #define cpu_has_local_ebase 0 | 60 | #define cpu_has_local_ebase 0 |
61 | 61 | ||
62 | #define cpu_has_wsbh IS_ENABLED(CONFIG_CPU_LOONGSON3) | ||
63 | |||
62 | #endif /* __ASM_MACH_LOONGSON_CPU_FEATURE_OVERRIDES_H */ | 64 | #endif /* __ASM_MACH_LOONGSON_CPU_FEATURE_OVERRIDES_H */ |
diff --git a/arch/mips/include/uapi/asm/swab.h b/arch/mips/include/uapi/asm/swab.h index ac9a8f9cd1fb..8f2d184dbe9f 100644 --- a/arch/mips/include/uapi/asm/swab.h +++ b/arch/mips/include/uapi/asm/swab.h | |||
@@ -13,12 +13,16 @@ | |||
13 | 13 | ||
14 | #define __SWAB_64_THRU_32__ | 14 | #define __SWAB_64_THRU_32__ |
15 | 15 | ||
16 | #if defined(__mips_isa_rev) && (__mips_isa_rev >= 2) | 16 | #if (defined(__mips_isa_rev) && (__mips_isa_rev >= 2)) || \ |
17 | defined(_MIPS_ARCH_LOONGSON3A) | ||
17 | 18 | ||
18 | static inline __attribute_const__ __u16 __arch_swab16(__u16 x) | 19 | static inline __attribute_const__ __u16 __arch_swab16(__u16 x) |
19 | { | 20 | { |
20 | __asm__( | 21 | __asm__( |
22 | " .set push \n" | ||
23 | " .set arch=mips32r2 \n" | ||
21 | " wsbh %0, %1 \n" | 24 | " wsbh %0, %1 \n" |
25 | " .set pop \n" | ||
22 | : "=r" (x) | 26 | : "=r" (x) |
23 | : "r" (x)); | 27 | : "r" (x)); |
24 | 28 | ||
@@ -29,8 +33,11 @@ static inline __attribute_const__ __u16 __arch_swab16(__u16 x) | |||
29 | static inline __attribute_const__ __u32 __arch_swab32(__u32 x) | 33 | static inline __attribute_const__ __u32 __arch_swab32(__u32 x) |
30 | { | 34 | { |
31 | __asm__( | 35 | __asm__( |
36 | " .set push \n" | ||
37 | " .set arch=mips32r2 \n" | ||
32 | " wsbh %0, %1 \n" | 38 | " wsbh %0, %1 \n" |
33 | " rotr %0, %0, 16 \n" | 39 | " rotr %0, %0, 16 \n" |
40 | " .set pop \n" | ||
34 | : "=r" (x) | 41 | : "=r" (x) |
35 | : "r" (x)); | 42 | : "r" (x)); |
36 | 43 | ||
@@ -46,8 +53,11 @@ static inline __attribute_const__ __u32 __arch_swab32(__u32 x) | |||
46 | static inline __attribute_const__ __u64 __arch_swab64(__u64 x) | 53 | static inline __attribute_const__ __u64 __arch_swab64(__u64 x) |
47 | { | 54 | { |
48 | __asm__( | 55 | __asm__( |
49 | " dsbh %0, %1\n" | 56 | " .set push \n" |
50 | " dshd %0, %0" | 57 | " .set arch=mips64r2 \n" |
58 | " dsbh %0, %1 \n" | ||
59 | " dshd %0, %0 \n" | ||
60 | " .set pop \n" | ||
51 | : "=r" (x) | 61 | : "=r" (x) |
52 | : "r" (x)); | 62 | : "r" (x)); |
53 | 63 | ||
@@ -55,5 +65,5 @@ static inline __attribute_const__ __u64 __arch_swab64(__u64 x) | |||
55 | } | 65 | } |
56 | #define __arch_swab64 __arch_swab64 | 66 | #define __arch_swab64 __arch_swab64 |
57 | #endif /* __mips64 */ | 67 | #endif /* __mips64 */ |
58 | #endif /* MIPS R2 or newer */ | 68 | #endif /* MIPS R2 or newer or Loongson 3A */ |
59 | #endif /* _ASM_SWAB_H */ | 69 | #endif /* _ASM_SWAB_H */ |
diff --git a/arch/mips/lib/csum_partial.S b/arch/mips/lib/csum_partial.S index 9901237563c5..4c721e247ac9 100644 --- a/arch/mips/lib/csum_partial.S +++ b/arch/mips/lib/csum_partial.S | |||
@@ -277,9 +277,12 @@ LEAF(csum_partial) | |||
277 | #endif | 277 | #endif |
278 | 278 | ||
279 | /* odd buffer alignment? */ | 279 | /* odd buffer alignment? */ |
280 | #ifdef CONFIG_CPU_MIPSR2 | 280 | #if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_CPU_LOONGSON3) |
281 | .set push | ||
282 | .set arch=mips32r2 | ||
281 | wsbh v1, sum | 283 | wsbh v1, sum |
282 | movn sum, v1, t7 | 284 | movn sum, v1, t7 |
285 | .set pop | ||
283 | #else | 286 | #else |
284 | beqz t7, 1f /* odd buffer alignment? */ | 287 | beqz t7, 1f /* odd buffer alignment? */ |
285 | lui v1, 0x00ff | 288 | lui v1, 0x00ff |
@@ -726,9 +729,12 @@ LEAF(csum_partial) | |||
726 | addu sum, v1 | 729 | addu sum, v1 |
727 | #endif | 730 | #endif |
728 | 731 | ||
729 | #ifdef CONFIG_CPU_MIPSR2 | 732 | #if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_CPU_LOONGSON3) |
733 | .set push | ||
734 | .set arch=mips32r2 | ||
730 | wsbh v1, sum | 735 | wsbh v1, sum |
731 | movn sum, v1, odd | 736 | movn sum, v1, odd |
737 | .set pop | ||
732 | #else | 738 | #else |
733 | beqz odd, 1f /* odd buffer alignment? */ | 739 | beqz odd, 1f /* odd buffer alignment? */ |
734 | lui v1, 0x00ff | 740 | lui v1, 0x00ff |
diff --git a/arch/mips/net/bpf_jit.c b/arch/mips/net/bpf_jit.c index 9f7ecbda250c..ae8cc8477389 100644 --- a/arch/mips/net/bpf_jit.c +++ b/arch/mips/net/bpf_jit.c | |||
@@ -1263,7 +1263,7 @@ jmp_cmp: | |||
1263 | emit_half_load(r_A, r_skb, off, ctx); | 1263 | emit_half_load(r_A, r_skb, off, ctx); |
1264 | #ifdef CONFIG_CPU_LITTLE_ENDIAN | 1264 | #ifdef CONFIG_CPU_LITTLE_ENDIAN |
1265 | /* This needs little endian fixup */ | 1265 | /* This needs little endian fixup */ |
1266 | if (cpu_has_mips_r2) { | 1266 | if (cpu_has_wsbh) { |
1267 | /* R2 and later have the wsbh instruction */ | 1267 | /* R2 and later have the wsbh instruction */ |
1268 | emit_wsbh(r_A, r_A, ctx); | 1268 | emit_wsbh(r_A, r_A, ctx); |
1269 | } else { | 1269 | } else { |