]> www.infradead.org Git - users/willy/xarray.git/commitdiff
parisc: add support for cmpxchg on u8 pointers
authorLiam Beguin <liambeguin@gmail.com>
Sat, 18 Jul 2020 20:10:21 +0000 (16:10 -0400)
committerHelge Deller <deller@gmx.de>
Tue, 21 Jul 2020 06:11:12 +0000 (08:11 +0200)
The kernel test bot reported[1] that using set_mask_bits on a u8 causes
the following issue on parisc:

hppa-linux-ld: drivers/phy/ti/phy-tusb1210.o: in function `tusb1210_probe':
>> (.text+0x2f4): undefined reference to `__cmpxchg_called_with_bad_pointer'
>> hppa-linux-ld: (.text+0x324): undefined reference to `__cmpxchg_called_with_bad_pointer'
hppa-linux-ld: (.text+0x354): undefined reference to `__cmpxchg_called_with_bad_pointer'

Add support for cmpxchg on u8 pointers.

[1] https://lore.kernel.org/patchwork/patch/1272617/#1468946

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Liam Beguin <liambeguin@gmail.com>
Tested-by: Dave Anglin <dave.anglin@bell.net>
Signed-off-by: Helge Deller <deller@gmx.de>
arch/parisc/include/asm/cmpxchg.h
arch/parisc/lib/bitops.c

index ab5c215cf46c3d81a5ef840fe46ffe740174c7ec..068958575871781355486cafe95bdba8c76b8658 100644 (file)
@@ -60,6 +60,7 @@ extern void __cmpxchg_called_with_bad_pointer(void);
 extern unsigned long __cmpxchg_u32(volatile unsigned int *m, unsigned int old,
                                   unsigned int new_);
 extern u64 __cmpxchg_u64(volatile u64 *ptr, u64 old, u64 new_);
+extern u8 __cmpxchg_u8(volatile u8 *ptr, u8 old, u8 new_);
 
 /* don't worry...optimizer will get rid of most of this */
 static inline unsigned long
@@ -71,6 +72,7 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size)
 #endif
        case 4: return __cmpxchg_u32((unsigned int *)ptr,
                                     (unsigned int)old, (unsigned int)new_);
+       case 1: return __cmpxchg_u8((u8 *)ptr, (u8)old, (u8)new_);
        }
        __cmpxchg_called_with_bad_pointer();
        return old;
index 70ffbcf889b8e34f6e4195e98d2c494f190693a9..2e4d1f05a92646b36b7d4eaabffaad6637bac430 100644 (file)
@@ -79,3 +79,15 @@ unsigned long __cmpxchg_u32(volatile unsigned int *ptr, unsigned int old, unsign
        _atomic_spin_unlock_irqrestore(ptr, flags);
        return (unsigned long)prev;
 }
+
+u8 __cmpxchg_u8(volatile u8 *ptr, u8 old, u8 new)
+{
+       unsigned long flags;
+       u8 prev;
+
+       _atomic_spin_lock_irqsave(ptr, flags);
+       if ((prev = *ptr) == old)
+               *ptr = new;
+       _atomic_spin_unlock_irqrestore(ptr, flags);
+       return prev;
+}