* [PATCH] MIPS: dsp: Add assembler support for DSP ASEs.
@ 2012-12-07 4:53 Steven J. Hill
2012-12-12 14:24 ` Florian Fainelli
0 siblings, 1 reply; 3+ messages in thread
From: Steven J. Hill @ 2012-12-07 4:53 UTC (permalink / raw)
To: linux-mips; +Cc: Steven J. Hill, ralf
From: "Steven J. Hill" <sjhill@mips.com>
Newer toolchains support the DSP and DSP Rev2 instructions. This patch
performs a check for that support and adds compiler and assembler
flags for only the files that need use those instructions.
Signed-off-by: Steven J. Hill <sjhill@mips.com>
---
arch/mips/include/asm/mipsregs.h | 53 ++++++++++++++++++++++++++------------
arch/mips/kernel/Makefile | 24 +++++++++++++++++
2 files changed, 60 insertions(+), 17 deletions(-)
diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index bec253f..5d400d2 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -1163,36 +1163,26 @@ do { \
: "=r" (__res)); \
__res;})
+#ifdef HAVE_AS_DSP
#define rddsp(mask) \
({ \
- unsigned int __res; \
+ unsigned int __dspctl; \
\
__asm__ __volatile__( \
- " .set push \n" \
- " .set noat \n" \
- " # rddsp $1, %x1 \n" \
- " .word 0x7c000cb8 | (%x1 << 16) \n" \
- " move %0, $1 \n" \
- " .set pop \n" \
- : "=r" (__res) \
+ " rddsp %0, %x1 \n" \
+ : "=r" (__dspctl) \
: "i" (mask)); \
- __res; \
+ __dspctl; \
})
#define wrdsp(val, mask) \
do { \
__asm__ __volatile__( \
- " .set push \n" \
- " .set noat \n" \
- " move $1, %0 \n" \
- " # wrdsp $1, %x1 \n" \
- " .word 0x7c2004f8 | (%x1 << 11) \n" \
- " .set pop \n" \
- : \
+ " wrdsp %0, %x1 \n" \
+ : \
: "r" (val), "i" (mask)); \
} while (0)
-#if 0 /* Need DSP ASE capable assembler ... */
#define mflo0() ({ long mflo0; __asm__("mflo %0, $ac0" : "=r" (mflo0)); mflo0;})
#define mflo1() ({ long mflo1; __asm__("mflo %0, $ac1" : "=r" (mflo1)); mflo1;})
#define mflo2() ({ long mflo2; __asm__("mflo %0, $ac2" : "=r" (mflo2)); mflo2;})
@@ -1215,6 +1205,35 @@ do { \
#else
+#define rddsp(mask) \
+({ \
+ unsigned int __res; \
+ \
+ __asm__ __volatile__( \
+ " .set push \n" \
+ " .set noat \n" \
+ " # rddsp $1, %x1 \n" \
+ " .word 0x7c000cb8 | (%x1 << 16) \n" \
+ " move %0, $1 \n" \
+ " .set pop \n" \
+ : "=r" (__res) \
+ : "i" (mask)); \
+ __res; \
+})
+
+#define wrdsp(val, mask) \
+do { \
+ __asm__ __volatile__( \
+ " .set push \n" \
+ " .set noat \n" \
+ " move $1, %0 \n" \
+ " # wrdsp $1, %x1 \n" \
+ " .word 0x7c2004f8 | (%x1 << 11) \n" \
+ " .set pop \n" \
+ : \
+ : "r" (val), "i" (mask)); \
+} while (0)
+
#define mfhi0() \
({ \
unsigned long __treg; \
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 99dc7f9..e034ad6 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -99,4 +99,28 @@ obj-$(CONFIG_HW_PERF_EVENTS) += perf_event_mipsxx.o
obj-$(CONFIG_JUMP_LABEL) += jump_label.o
+ifeq ($(CONFIG_CPU_MIPS32), y)
+#
+# Check if assembler supports DSP ASE
+#
+ifeq ($(call cc-option-yn,-mdsp), y)
+CFLAGS_signal.o = -mdsp -DHAVE_AS_DSP
+CFLAGS_signal32.o = -mdsp -DHAVE_AS_DSP
+CFLAGS_process.o = -mdsp -DHAVE_AS_DSP
+CFLAGS_branch.o = -mdsp -DHAVE_AS_DSP
+CFLAGS_ptrace.o = -mdsp -DHAVE_AS_DSP
+endif
+
+#
+# Check if assembler supports DSP ASE Rev2
+#
+ifeq ($(call cc-option-yn,-mdsp2), y)
+CFLAGS_signal.o = -mdsp2 -DHAVE_AS_DSP
+CFLAGS_signal32.o = -mdsp2 -DHAVE_AS_DSP
+CFLAGS_process.o = -mdsp2 -DHAVE_AS_DSP
+CFLAGS_branch.o = -mdsp2 -DHAVE_AS_DSP
+CFLAGS_ptrace.o = -mdsp2 -DHAVE_AS_DSP
+endif
+endif
+
CPPFLAGS_vmlinux.lds := $(KBUILD_CFLAGS)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] MIPS: dsp: Add assembler support for DSP ASEs.
2012-12-07 4:53 [PATCH] MIPS: dsp: Add assembler support for DSP ASEs Steven J. Hill
@ 2012-12-12 14:24 ` Florian Fainelli
2012-12-15 5:10 ` Hill, Steven
0 siblings, 1 reply; 3+ messages in thread
From: Florian Fainelli @ 2012-12-12 14:24 UTC (permalink / raw)
To: Steven J. Hill; +Cc: linux-mips, ralf
Hi Steven,
Le 12/07/12 05:53, Steven J. Hill a écrit :
> From: "Steven J. Hill" <sjhill@mips.com>
>
> Newer toolchains support the DSP and DSP Rev2 instructions. This patch
> performs a check for that support and adds compiler and assembler
> flags for only the files that need use those instructions.
>
> Signed-off-by: Steven J. Hill <sjhill@mips.com>
> ---
> arch/mips/include/asm/mipsregs.h | 53 ++++++++++++++++++++++++++------------
> arch/mips/kernel/Makefile | 24 +++++++++++++++++
> 2 files changed, 60 insertions(+), 17 deletions(-)
>
> --- a/arch/mips/kernel/Makefile
> +++ b/arch/mips/kernel/Makefile
> @@ -99,4 +99,28 @@ obj-$(CONFIG_HW_PERF_EVENTS) += perf_event_mipsxx.o
>
> obj-$(CONFIG_JUMP_LABEL) += jump_label.o
>
> +ifeq ($(CONFIG_CPU_MIPS32), y)
> +#
> +# Check if assembler supports DSP ASE
> +#
> +ifeq ($(call cc-option-yn,-mdsp), y)
> +CFLAGS_signal.o = -mdsp -DHAVE_AS_DSP
> +CFLAGS_signal32.o = -mdsp -DHAVE_AS_DSP
> +CFLAGS_process.o = -mdsp -DHAVE_AS_DSP
> +CFLAGS_branch.o = -mdsp -DHAVE_AS_DSP
> +CFLAGS_ptrace.o = -mdsp -DHAVE_AS_DSP
> +endif
> +
> +#
> +# Check if assembler supports DSP ASE Rev2
> +#
> +ifeq ($(call cc-option-yn,-mdsp2), y)
> +CFLAGS_signal.o = -mdsp2 -DHAVE_AS_DSP
> +CFLAGS_signal32.o = -mdsp2 -DHAVE_AS_DSP
> +CFLAGS_process.o = -mdsp2 -DHAVE_AS_DSP
> +CFLAGS_branch.o = -mdsp2 -DHAVE_AS_DSP
> +CFLAGS_ptrace.o = -mdsp2 -DHAVE_AS_DSP
Should not this be -mdspr2 here? My GCC man page suggests that.
By the way, should not we also check that we are building for a
MIPS32_R2 CPU when checking for -mdsp2?
> +endif
> +endif
> +
I would simplify this like this:
ifeq ($(CONFIG_CPU_MIPS32),y)
CFLAGS_DSP = -DHAVE_AS_DSP
ifeq ($(call cc-option-yn,-mdsp),y)
CFLAGS_DSP += -mdsp
endif
ifeq ($(call cc-option-yn,-mdsp2),y)
CFLAGS-DSP += -mdsp2
endif
CFLAGS_signal.o = $(CFLAGS_DSP)
...
CFLAGS_ptrace.o = $(CFLAGS_DSP)
endif
such that the day you can take advantage of a third DSP flavor it's only
3 lines worth of Makefile to get it used, and you only have one place
where you need to change CFLAGS.
--
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] MIPS: dsp: Add assembler support for DSP ASEs.
2012-12-12 14:24 ` Florian Fainelli
@ 2012-12-15 5:10 ` Hill, Steven
0 siblings, 0 replies; 3+ messages in thread
From: Hill, Steven @ 2012-12-15 5:10 UTC (permalink / raw)
To: Florian Fainelli; +Cc: linux-mips@linux-mips.org
>> +ifeq ($(call cc-option-yn,-mdsp2), y)
>> +CFLAGS_signal.o = -mdsp2 -DHAVE_AS_DSP
>> +CFLAGS_signal32.o = -mdsp2 -DHAVE_AS_DSP
>> +CFLAGS_process.o = -mdsp2 -DHAVE_AS_DSP
>> +CFLAGS_branch.o = -mdsp2 -DHAVE_AS_DSP
>> +CFLAGS_ptrace.o = -mdsp2 -DHAVE_AS_DSP
>
> Should not this be -mdspr2 here? My GCC man page suggests that.
>
Yes, corrected this.
> By the way, should not we also check that we are building for a
> MIPS32_R2 CPU when checking for -mdsp2?
>
Yes, fixed this also.
> I would simplify this like this:
>
> ifeq ($(CONFIG_CPU_MIPS32),y)
> CFLAGS_DSP = -DHAVE_AS_DSP
> ifeq ($(call cc-option-yn,-mdsp),y)
> CFLAGS_DSP += -mdsp
> endif
> ifeq ($(call cc-option-yn,-mdsp2),y)
> CFLAGS-DSP += -mdsp2
>endif
>
> CFLAGS_signal.o = $(CFLAGS_DSP)
> ...
> CFLAGS_ptrace.o = $(CFLAGS_DSP)
> endif
>
> such that the day you can take advantage of a third DSP flavor it's only
> 3 lines worth of Makefile to get it used, and you only have one place
> where you need to change CFLAGS.
>
Good idea, fixed.
I have posted a new patch for review.
-Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-15 5:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-07 4:53 [PATCH] MIPS: dsp: Add assembler support for DSP ASEs Steven J. Hill
2012-12-12 14:24 ` Florian Fainelli
2012-12-15 5:10 ` Hill, Steven
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.