xref: /linux/arch/riscv/include/asm/fence.h (revision da5b2ad1c2f18834cb1ce429e2e5a5cf5cbdf21b)
1 #ifndef _ASM_RISCV_FENCE_H
2 #define _ASM_RISCV_FENCE_H
3 
4 #define RISCV_FENCE_ASM(p, s)		"\tfence " #p "," #s "\n"
5 #define RISCV_FENCE(p, s) \
6 	({ __asm__ __volatile__ (RISCV_FENCE_ASM(p, s) : : : "memory"); })
7 
8 #ifdef CONFIG_SMP
9 #define RISCV_ACQUIRE_BARRIER		RISCV_FENCE_ASM(r, rw)
10 #define RISCV_RELEASE_BARRIER		RISCV_FENCE_ASM(rw, w)
11 #define RISCV_FULL_BARRIER		RISCV_FENCE_ASM(rw, rw)
12 #else
13 #define RISCV_ACQUIRE_BARRIER
14 #define RISCV_RELEASE_BARRIER
15 #define RISCV_FULL_BARRIER
16 #endif
17 
18 #endif	/* _ASM_RISCV_FENCE_H */
19