Commit ff88f8a3 authored by Ralf Baechle's avatar Ralf Baechle

Use ei / di MIPS32 R2 instructions if available.

Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 1e5f1caa
...@@ -11,20 +11,25 @@ ...@@ -11,20 +11,25 @@
#ifndef _ASM_INTERRUPT_H #ifndef _ASM_INTERRUPT_H
#define _ASM_INTERRUPT_H #define _ASM_INTERRUPT_H
#include <linux/config.h>
#include <asm/hazards.h> #include <asm/hazards.h>
__asm__ ( __asm__ (
".macro\tlocal_irq_enable\n\t" " .macro local_irq_enable \n"
".set\tpush\n\t" " .set push \n"
".set\treorder\n\t" " .set reorder \n"
".set\tnoat\n\t" " .set noat \n"
"mfc0\t$1,$12\n\t" #if defined(CONFIG_CPU_MIPS32_R2) || defined(CONFIG_CPU_MIPS64_R2)
"ori\t$1,0x1f\n\t" " ei \n"
"xori\t$1,0x1e\n\t" #else
"mtc0\t$1,$12\n\t" " mfc0 $1,$12 \n"
"irq_enable_hazard\n\t" " ori $1,0x1f \n"
".set\tpop\n\t" " xori $1,0x1e \n"
".endm"); " mtc0 $1,$12 \n"
#endif
" irq_enable_hazard \n"
" .set pop \n"
" .endm");
static inline void local_irq_enable(void) static inline void local_irq_enable(void)
{ {
...@@ -43,17 +48,21 @@ static inline void local_irq_enable(void) ...@@ -43,17 +48,21 @@ static inline void local_irq_enable(void)
* no nops at all. * no nops at all.
*/ */
__asm__ ( __asm__ (
".macro\tlocal_irq_disable\n\t" " .macro local_irq_disable\n"
".set\tpush\n\t" " .set push \n"
".set\tnoat\n\t" " .set noat \n"
"mfc0\t$1,$12\n\t" #if defined(CONFIG_CPU_MIPS32_R2) || defined(CONFIG_CPU_MIPS64_R2)
"ori\t$1,1\n\t" " di \n"
"xori\t$1,1\n\t" #else
".set\tnoreorder\n\t" " mfc0 $1,$12 \n"
"mtc0\t$1,$12\n\t" " ori $1,1 \n"
"irq_disable_hazard\n\t" " xori $1,1 \n"
".set\tpop\n\t" " .set noreorder \n"
".endm"); " mtc0 $1,$12 \n"
#endif
" irq_disable_hazard \n"
" .set pop \n"
" .endm \n");
static inline void local_irq_disable(void) static inline void local_irq_disable(void)
{ {
...@@ -65,12 +74,12 @@ static inline void local_irq_disable(void) ...@@ -65,12 +74,12 @@ static inline void local_irq_disable(void)
} }
__asm__ ( __asm__ (
".macro\tlocal_save_flags flags\n\t" " .macro local_save_flags flags \n"
".set\tpush\n\t" " .set push \n"
".set\treorder\n\t" " .set reorder \n"
"mfc0\t\\flags, $12\n\t" " mfc0 \\flags, $12 \n"
".set\tpop\n\t" " .set pop \n"
".endm"); " .endm \n");
#define local_save_flags(x) \ #define local_save_flags(x) \
__asm__ __volatile__( \ __asm__ __volatile__( \
...@@ -78,18 +87,22 @@ __asm__ __volatile__( \ ...@@ -78,18 +87,22 @@ __asm__ __volatile__( \
: "=r" (x)) : "=r" (x))
__asm__ ( __asm__ (
".macro\tlocal_irq_save result\n\t" " .macro local_irq_save result \n"
".set\tpush\n\t" " .set push \n"
".set\treorder\n\t" " .set reorder \n"
".set\tnoat\n\t" " .set noat \n"
"mfc0\t\\result, $12\n\t" #if defined(CONFIG_CPU_MIPS32_R2) || defined(CONFIG_CPU_MIPS64_R2)
"ori\t$1, \\result, 1\n\t" " di \\result \n"
"xori\t$1, 1\n\t" #else
".set\tnoreorder\n\t" " mfc0 \\result, $12 \n"
"mtc0\t$1, $12\n\t" " ori $1, \\result, 1 \n"
"irq_disable_hazard\n\t" " xori $1, 1 \n"
".set\tpop\n\t" " .set noreorder \n"
".endm"); " mtc0 $1, $12 \n"
#endif
" irq_disable_hazard \n"
" .set pop \n"
" .endm \n");
#define local_irq_save(x) \ #define local_irq_save(x) \
__asm__ __volatile__( \ __asm__ __volatile__( \
...@@ -99,19 +112,38 @@ __asm__ __volatile__( \ ...@@ -99,19 +112,38 @@ __asm__ __volatile__( \
: "memory") : "memory")
__asm__ ( __asm__ (
".macro\tlocal_irq_restore flags\n\t" " .macro local_irq_restore flags \n"
".set\tnoreorder\n\t" " .set noreorder \n"
".set\tnoat\n\t" " .set noat \n"
"mfc0\t$1, $12\n\t" #if (defined(CONFIG_CPU_MIPS32_R2) || defined(CONFIG_CPU_MIPS64_R2)) && \
"andi\t\\flags, 1\n\t" defined(CONFIG_IRQ_CPU)
"ori\t$1, 1\n\t" /*
"xori\t$1, 1\n\t" * Slow, but doesn't suffer from a relativly unlikely race
"or\t\\flags, $1\n\t" * condition we're having since days 1.
"mtc0\t\\flags, $12\n\t" */
"irq_disable_hazard\n\t" " beqz \\flags, 1f \n"
".set\tat\n\t" " di \n"
".set\treorder\n\t" " ei \n"
".endm"); "1: \n"
#elif defined(CONFIG_CPU_MIPS32_R2) || defined(CONFIG_CPU_MIPS64_R2)
/*
* Fast, dangerous. Life is fun, life is good.
*/
" mfc0 $1, $12 \n"
" ins $1, \\flags, 0, 1 \n"
" mtc0 $1, $12 \n"
#else
" mfc0 $1, $12 \n"
" andi \\flags, 1 \n"
" ori $1, 1 \n"
" xori $1, 1 \n"
" or \\flags, $1 \n"
" mtc0 \\flags, $12 \n"
#endif
" irq_disable_hazard \n"
" .set at \n"
" .set reorder \n"
" .endm \n");
#define local_irq_restore(flags) \ #define local_irq_restore(flags) \
do { \ do { \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment