Skip to content

Commit

Permalink
MIPS: fix local_t operation on MIPS64
Browse files Browse the repository at this point in the history
Use daddu/dsubu for long int on MIPS64.

Signed-off-by: Huang Pei <huangpei@loongson.cn>
  • Loading branch information
mips-hp authored and intel-lab-lkp committed Sep 4, 2021
1 parent f1583cb commit 4a1c6e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 4 additions & 0 deletions arch/mips/include/asm/llsc.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
#define __SC "sc "
#define __INS "ins "
#define __EXT "ext "
#define __ADDU "addu "
#define __SUBU "subu "
#elif _MIPS_SZLONG == 64
#define __LL "lld "
#define __SC "scd "
#define __INS "dins "
#define __EXT "dext "
#define __ADDU "daddu "
#define __SUBU "dsubu "
#endif

/*
Expand Down
17 changes: 9 additions & 8 deletions arch/mips/include/asm/local.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <linux/percpu.h>
#include <linux/bitops.h>
#include <linux/atomic.h>
#include <asm/asm.h>
#include <asm/cmpxchg.h>
#include <asm/compiler.h>
#include <asm/war.h>
Expand Down Expand Up @@ -39,10 +40,10 @@ static __inline__ long local_add_return(long i, local_t * l)
" .set arch=r4000 \n"
__SYNC(full, loongson3_war) " \n"
"1:" __LL "%1, %2 # local_add_return \n"
" addu %0, %1, %3 \n"
__ADDU "%0, %1, %3 \n"
__SC "%0, %2 \n"
" beqzl %0, 1b \n"
" addu %0, %1, %3 \n"
__ADDU "%0, %1, %3 \n"
" .set pop \n"
: "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
: "Ir" (i), "m" (l->a.counter)
Expand All @@ -55,10 +56,10 @@ static __inline__ long local_add_return(long i, local_t * l)
" .set "MIPS_ISA_ARCH_LEVEL" \n"
__SYNC(full, loongson3_war) " \n"
"1:" __LL "%1, %2 # local_add_return \n"
" addu %0, %1, %3 \n"
__ADDU "%0, %1, %3 \n"
__SC "%0, %2 \n"
" beqz %0, 1b \n"
" addu %0, %1, %3 \n"
__ADDU "%0, %1, %3 \n"
" .set pop \n"
: "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
: "Ir" (i), "m" (l->a.counter)
Expand Down Expand Up @@ -88,10 +89,10 @@ static __inline__ long local_sub_return(long i, local_t * l)
" .set arch=r4000 \n"
__SYNC(full, loongson3_war) " \n"
"1:" __LL "%1, %2 # local_sub_return \n"
" subu %0, %1, %3 \n"
__SUBU "%0, %1, %3 \n"
__SC "%0, %2 \n"
" beqzl %0, 1b \n"
" subu %0, %1, %3 \n"
__SUBU "%0, %1, %3 \n"
" .set pop \n"
: "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
: "Ir" (i), "m" (l->a.counter)
Expand All @@ -104,10 +105,10 @@ static __inline__ long local_sub_return(long i, local_t * l)
" .set "MIPS_ISA_ARCH_LEVEL" \n"
__SYNC(full, loongson3_war) " \n"
"1:" __LL "%1, %2 # local_sub_return \n"
" subu %0, %1, %3 \n"
__SUBU "%0, %1, %3 \n"
__SC "%0, %2 \n"
" beqz %0, 1b \n"
" subu %0, %1, %3 \n"
__SUBU "%0, %1, %3 \n"
" .set pop \n"
: "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
: "Ir" (i), "m" (l->a.counter)
Expand Down

0 comments on commit 4a1c6e1

Please sign in to comment.