xref: /linux/arch/x86/include/asm/qspinlock.h (revision 6f7e6393d1ce636bb7ec77a7fe7b77458fddf701)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_QSPINLOCK_H
3 #define _ASM_X86_QSPINLOCK_H
4 
5 #include <linux/jump_label.h>
6 #include <asm/cpufeature.h>
7 #include <asm-generic/qspinlock_types.h>
8 #include <asm/paravirt.h>
9 #include <asm/rmwcc.h>
10 #ifdef CONFIG_PARAVIRT
11 #include <asm/paravirt-spinlock.h>
12 #endif
13 
14 #define _Q_PENDING_LOOPS	(1 << 9)
15 
16 #define queued_fetch_set_pending_acquire queued_fetch_set_pending_acquire
17 static __always_inline u32 queued_fetch_set_pending_acquire(struct qspinlock *lock)
18 {
19 	u32 val;
20 
21 	/*
22 	 * We can't use GEN_BINARY_RMWcc() inside an if() stmt because asm goto
23 	 * and CONFIG_PROFILE_ALL_BRANCHES=y results in a label inside a
24 	 * statement expression, which GCC doesn't like.
25 	 */
26 	val = GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
27 			       "I", _Q_PENDING_OFFSET) * _Q_PENDING_VAL;
28 	val |= atomic_read(&lock->val) & ~_Q_PENDING_MASK;
29 
30 	return val;
31 }
32 
33 #ifndef CONFIG_PARAVIRT
34 static inline void native_pv_lock_init(void) { }
35 #endif
36 
37 #include <asm-generic/qspinlock.h>
38 
39 #endif /* _ASM_X86_QSPINLOCK_H */
40