Skip to content

Commit edbb423

Browse files
committed
MIPS: Cleanup DSP ASE detection
Currently we hardcode a list of files for which we specify that the toolchain has DSP ASE support when building for MIPSr2 only. This has a number of problems: 1) It doesn't actually ensure that the toolchain supports the DSP ASE at all. 2) It's fragile if we try to use DSP ASE macros in other files. 3) It makes no provision for MIPSr6 & later systems which also support the DSP ASE & end up using the .word directive implementation of the DSP macros. Fix this by detecting assembler support for the DSP ASE globally, not just for a small set of files, and not just for MIPSr2. This now exposes use of toolchain DSP support to kernel builds targeting MIPSr1 and older, so we add .set MIPS_ISA_LEVEL directives prior to all .set dsp directives in order to prevent the assembler from complaining that the DSP ASE is only supported with MIPSr2 & higher. Signed-off-by: Paul Burton <paul.burton@mips.com> Patchwork: https://patchwork.linux-mips.org/patch/20901/ Cc: linux-mips@linux-mips.org
1 parent 965f22b commit edbb423

3 files changed

Lines changed: 21 additions & 19 deletions

File tree

‎arch/mips/Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ toolchain-xpa := $(call cc-option-yn,$(xpa-cflags-y) -mxpa)
231231
cflags-$(toolchain-xpa) += -DTOOLCHAIN_SUPPORTS_XPA
232232
toolchain-crc := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mcrc)
233233
cflags-$(toolchain-crc) += -DTOOLCHAIN_SUPPORTS_CRC
234+
toolchain-dsp := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mdsp)
235+
cflags-$(toolchain-dsp) += -DTOOLCHAIN_SUPPORTS_DSP
234236

235237
#
236238
# Firmware support

‎arch/mips/include/asm/mipsregs.h‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2287,13 +2287,14 @@ do { \
22872287
_write_32bit_cp1_register(dest, val, )
22882288
#endif
22892289

2290-
#ifdef HAVE_AS_DSP
2290+
#ifdef TOOLCHAIN_SUPPORTS_DSP
22912291
#define rddsp(mask) \
22922292
({ \
22932293
unsigned int __dspctl; \
22942294
\
22952295
__asm__ __volatile__( \
22962296
" .set push \n" \
2297+
" .set " MIPS_ISA_LEVEL " \n" \
22972298
" .set dsp \n" \
22982299
" rddsp %0, %x1 \n" \
22992300
" .set pop \n" \
@@ -2306,6 +2307,7 @@ do { \
23062307
do { \
23072308
__asm__ __volatile__( \
23082309
" .set push \n" \
2310+
" .set " MIPS_ISA_LEVEL " \n" \
23092311
" .set dsp \n" \
23102312
" wrdsp %0, %x1 \n" \
23112313
" .set pop \n" \
@@ -2318,6 +2320,7 @@ do { \
23182320
long mflo0; \
23192321
__asm__( \
23202322
" .set push \n" \
2323+
" .set " MIPS_ISA_LEVEL " \n" \
23212324
" .set dsp \n" \
23222325
" mflo %0, $ac0 \n" \
23232326
" .set pop \n" \
@@ -2330,6 +2333,7 @@ do { \
23302333
long mflo1; \
23312334
__asm__( \
23322335
" .set push \n" \
2336+
" .set " MIPS_ISA_LEVEL " \n" \
23332337
" .set dsp \n" \
23342338
" mflo %0, $ac1 \n" \
23352339
" .set pop \n" \
@@ -2342,6 +2346,7 @@ do { \
23422346
long mflo2; \
23432347
__asm__( \
23442348
" .set push \n" \
2349+
" .set " MIPS_ISA_LEVEL " \n" \
23452350
" .set dsp \n" \
23462351
" mflo %0, $ac2 \n" \
23472352
" .set pop \n" \
@@ -2354,6 +2359,7 @@ do { \
23542359
long mflo3; \
23552360
__asm__( \
23562361
" .set push \n" \
2362+
" .set " MIPS_ISA_LEVEL " \n" \
23572363
" .set dsp \n" \
23582364
" mflo %0, $ac3 \n" \
23592365
" .set pop \n" \
@@ -2366,6 +2372,7 @@ do { \
23662372
long mfhi0; \
23672373
__asm__( \
23682374
" .set push \n" \
2375+
" .set " MIPS_ISA_LEVEL " \n" \
23692376
" .set dsp \n" \
23702377
" mfhi %0, $ac0 \n" \
23712378
" .set pop \n" \
@@ -2378,6 +2385,7 @@ do { \
23782385
long mfhi1; \
23792386
__asm__( \
23802387
" .set push \n" \
2388+
" .set " MIPS_ISA_LEVEL " \n" \
23812389
" .set dsp \n" \
23822390
" mfhi %0, $ac1 \n" \
23832391
" .set pop \n" \
@@ -2390,6 +2398,7 @@ do { \
23902398
long mfhi2; \
23912399
__asm__( \
23922400
" .set push \n" \
2401+
" .set " MIPS_ISA_LEVEL " \n" \
23932402
" .set dsp \n" \
23942403
" mfhi %0, $ac2 \n" \
23952404
" .set pop \n" \
@@ -2402,6 +2411,7 @@ do { \
24022411
long mfhi3; \
24032412
__asm__( \
24042413
" .set push \n" \
2414+
" .set " MIPS_ISA_LEVEL " \n" \
24052415
" .set dsp \n" \
24062416
" mfhi %0, $ac3 \n" \
24072417
" .set pop \n" \
@@ -2414,6 +2424,7 @@ do { \
24142424
({ \
24152425
__asm__( \
24162426
" .set push \n" \
2427+
" .set " MIPS_ISA_LEVEL " \n" \
24172428
" .set dsp \n" \
24182429
" mtlo %0, $ac0 \n" \
24192430
" .set pop \n" \
@@ -2425,6 +2436,7 @@ do { \
24252436
({ \
24262437
__asm__( \
24272438
" .set push \n" \
2439+
" .set " MIPS_ISA_LEVEL " \n" \
24282440
" .set dsp \n" \
24292441
" mtlo %0, $ac1 \n" \
24302442
" .set pop \n" \
@@ -2436,6 +2448,7 @@ do { \
24362448
({ \
24372449
__asm__( \
24382450
" .set push \n" \
2451+
" .set " MIPS_ISA_LEVEL " \n" \
24392452
" .set dsp \n" \
24402453
" mtlo %0, $ac2 \n" \
24412454
" .set pop \n" \
@@ -2447,6 +2460,7 @@ do { \
24472460
({ \
24482461
__asm__( \
24492462
" .set push \n" \
2463+
" .set " MIPS_ISA_LEVEL " \n" \
24502464
" .set dsp \n" \
24512465
" mtlo %0, $ac3 \n" \
24522466
" .set pop \n" \
@@ -2458,6 +2472,7 @@ do { \
24582472
({ \
24592473
__asm__( \
24602474
" .set push \n" \
2475+
" .set " MIPS_ISA_LEVEL " \n" \
24612476
" .set dsp \n" \
24622477
" mthi %0, $ac0 \n" \
24632478
" .set pop \n" \
@@ -2469,6 +2484,7 @@ do { \
24692484
({ \
24702485
__asm__( \
24712486
" .set push \n" \
2487+
" .set " MIPS_ISA_LEVEL " \n" \
24722488
" .set dsp \n" \
24732489
" mthi %0, $ac1 \n" \
24742490
" .set pop \n" \
@@ -2480,6 +2496,7 @@ do { \
24802496
({ \
24812497
__asm__( \
24822498
" .set push \n" \
2499+
" .set " MIPS_ISA_LEVEL " \n" \
24832500
" .set dsp \n" \
24842501
" mthi %0, $ac2 \n" \
24852502
" .set pop \n" \
@@ -2491,6 +2508,7 @@ do { \
24912508
({ \
24922509
__asm__( \
24932510
" .set push \n" \
2511+
" .set " MIPS_ISA_LEVEL " \n" \
24942512
" .set dsp \n" \
24952513
" mthi %0, $ac3 \n" \
24962514
" .set pop \n" \

‎arch/mips/kernel/Makefile‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,22 +113,4 @@ obj-$(CONFIG_MIPS_CPC) += mips-cpc.o
113113
obj-$(CONFIG_CPU_PM) += pm.o
114114
obj-$(CONFIG_MIPS_CPS_PM) += pm-cps.o
115115

116-
#
117-
# DSP ASE supported for MIPS32 or MIPS64 Release 2 cores only. It is not
118-
# safe to unconditionnaly use the assembler -mdsp / -mdspr2 switches
119-
# here because the compiler may use DSP ASE instructions (such as lwx) in
120-
# code paths where we cannot check that the CPU we are running on supports it.
121-
# Proper abstraction using HAVE_AS_DSP and macros is done in
122-
# arch/mips/include/asm/mipsregs.h.
123-
#
124-
ifeq ($(CONFIG_CPU_MIPSR2), y)
125-
CFLAGS_DSP = -DHAVE_AS_DSP
126-
127-
CFLAGS_signal.o = $(CFLAGS_DSP)
128-
CFLAGS_signal32.o = $(CFLAGS_DSP)
129-
CFLAGS_process.o = $(CFLAGS_DSP)
130-
CFLAGS_branch.o = $(CFLAGS_DSP)
131-
CFLAGS_ptrace.o = $(CFLAGS_DSP)
132-
endif
133-
134116
CPPFLAGS_vmlinux.lds := $(KBUILD_CFLAGS)

0 commit comments

Comments
 (0)