Skip to content

Commit b344d6a

Browse files
liambeguinhdeller
authored andcommitted
parisc: add support for cmpxchg on u8 pointers
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 <[email protected]> Signed-off-by: Liam Beguin <[email protected]> Tested-by: Dave Anglin <[email protected]> Signed-off-by: Helge Deller <[email protected]>
1 parent ba47d84 commit b344d6a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

arch/parisc/include/asm/cmpxchg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ extern void __cmpxchg_called_with_bad_pointer(void);
6060
extern unsigned long __cmpxchg_u32(volatile unsigned int *m, unsigned int old,
6161
unsigned int new_);
6262
extern u64 __cmpxchg_u64(volatile u64 *ptr, u64 old, u64 new_);
63+
extern u8 __cmpxchg_u8(volatile u8 *ptr, u8 old, u8 new_);
6364

6465
/* don't worry...optimizer will get rid of most of this */
6566
static inline unsigned long
@@ -71,6 +72,7 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size)
7172
#endif
7273
case 4: return __cmpxchg_u32((unsigned int *)ptr,
7374
(unsigned int)old, (unsigned int)new_);
75+
case 1: return __cmpxchg_u8((u8 *)ptr, (u8)old, (u8)new_);
7476
}
7577
__cmpxchg_called_with_bad_pointer();
7678
return old;

arch/parisc/lib/bitops.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,15 @@ unsigned long __cmpxchg_u32(volatile unsigned int *ptr, unsigned int old, unsign
7979
_atomic_spin_unlock_irqrestore(ptr, flags);
8080
return (unsigned long)prev;
8181
}
82+
83+
u8 __cmpxchg_u8(volatile u8 *ptr, u8 old, u8 new)
84+
{
85+
unsigned long flags;
86+
u8 prev;
87+
88+
_atomic_spin_lock_irqsave(ptr, flags);
89+
if ((prev = *ptr) == old)
90+
*ptr = new;
91+
_atomic_spin_unlock_irqrestore(ptr, flags);
92+
return prev;
93+
}

0 commit comments

Comments
 (0)