1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2bf67fd31SWill Deacon #ifndef __ASM_MCS_LOCK_H
3bf67fd31SWill Deacon #define __ASM_MCS_LOCK_H
4bf67fd31SWill Deacon 
5bf67fd31SWill Deacon #ifdef CONFIG_SMP
6bf67fd31SWill Deacon #include <asm/spinlock.h>
7bf67fd31SWill Deacon 
8bf67fd31SWill Deacon /* MCS spin-locking. */
9bf67fd31SWill Deacon #define arch_mcs_spin_lock_contended(lock)				\
10bf67fd31SWill Deacon do {									\
11bf67fd31SWill Deacon 	/* Ensure prior stores are observed before we enter wfe. */	\
12bf67fd31SWill Deacon 	smp_mb();							\
13bf67fd31SWill Deacon 	while (!(smp_load_acquire(lock)))				\
14bf67fd31SWill Deacon 		wfe();							\
15bf67fd31SWill Deacon } while (0)								\
16bf67fd31SWill Deacon 
17bf67fd31SWill Deacon #define arch_mcs_spin_unlock_contended(lock)				\
18bf67fd31SWill Deacon do {									\
19bf67fd31SWill Deacon 	smp_store_release(lock, 1);					\
20bf67fd31SWill Deacon 	dsb_sev();							\
21bf67fd31SWill Deacon } while (0)
22bf67fd31SWill Deacon 
23bf67fd31SWill Deacon #endif	/* CONFIG_SMP */
24bf67fd31SWill Deacon #endif	/* __ASM_MCS_LOCK_H */
25