Skip to content

Commit ea845e3

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
m68k: implement xor_unlock_is_negative_byte
Using EOR to clear the guaranteed-to-be-set lock bit will test the negative flag just like the x86 implementation. This should be more efficient than the generic implementation in filemap.c. It would be better if m68k had __GCC_ASM_FLAG_OUTPUTS__. Coldfire doesn't have a byte-sized EOR, so we test bit 7 after the EOR, which is a second memory access, but it's slightly better than the current C code. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Cc: Albert Ou <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Andreas Dilger <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Ivan Kokshaysky <[email protected]> Cc: Matt Turner <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Richard Henderson <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: "Theodore Ts'o" <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Vasily Gorbik <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent e28ff5d commit ea845e3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

arch/m68k/include/asm/bitops.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,28 @@ arch___test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
319319
return test_and_change_bit(nr, addr);
320320
}
321321

322+
static inline bool xor_unlock_is_negative_byte(unsigned long mask,
323+
volatile unsigned long *p)
324+
{
325+
#ifdef CONFIG_COLDFIRE
326+
__asm__ __volatile__ ("eorl %1, %0"
327+
: "+m" (*p)
328+
: "d" (mask)
329+
: "memory");
330+
return *p & (1 << 7);
331+
#else
332+
char result;
333+
char *cp = (char *)p + 3; /* m68k is big-endian */
334+
335+
__asm__ __volatile__ ("eor.b %1, %2; smi %0"
336+
: "=d" (result)
337+
: "di" (mask), "o" (*cp)
338+
: "memory");
339+
return result;
340+
#endif
341+
}
342+
#define xor_unlock_is_negative_byte xor_unlock_is_negative_byte
343+
322344
/*
323345
* The true 68020 and more advanced processors support the "bfffo"
324346
* instruction for finding bits. ColdFire and simple 68000 parts

0 commit comments

Comments
 (0)