]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - arch/arm64/include/asm/barrier.h
2 * Based on arch/arm/include/asm/barrier.h
4 * Copyright (C) 2012 ARM Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef __ASM_BARRIER_H
19 #define __ASM_BARRIER_H
23 #define sev() asm volatile("sev" : : : "memory")
24 #define wfe() asm volatile("wfe" : : : "memory")
25 #define wfi() asm volatile("wfi" : : : "memory")
27 #define isb() asm volatile("isb" : : : "memory")
28 #define dmb(opt) asm volatile("dmb " #opt : : : "memory")
29 #define dsb(opt) asm volatile("dsb " #opt : : : "memory")
36 #define smp_mb() barrier()
37 #define smp_rmb() barrier()
38 #define smp_wmb() barrier()
40 #define smp_store_release(p, v) \
42 compiletime_assert_atomic_type(*p); \
44 ACCESS_ONCE(*p) = (v); \
47 #define smp_load_acquire(p) \
49 typeof(*p) ___p1 = ACCESS_ONCE(*p); \
50 compiletime_assert_atomic_type(*p); \
57 #define smp_mb() dmb(ish)
58 #define smp_rmb() dmb(ishld)
59 #define smp_wmb() dmb(ishst)
61 #define smp_store_release(p, v) \
63 compiletime_assert_atomic_type(*p); \
64 switch (sizeof(*p)) { \
66 asm volatile ("stlr %w1, %0" \
67 : "=Q" (*p) : "r" (v) : "memory"); \
70 asm volatile ("stlr %1, %0" \
71 : "=Q" (*p) : "r" (v) : "memory"); \
76 #define smp_load_acquire(p) \
79 compiletime_assert_atomic_type(*p); \
80 switch (sizeof(*p)) { \
82 asm volatile ("ldar %w0, %1" \
83 : "=r" (___p1) : "Q" (*p) : "memory"); \
86 asm volatile ("ldar %0, %1" \
87 : "=r" (___p1) : "Q" (*p) : "memory"); \
95 #define read_barrier_depends() do { } while(0)
96 #define smp_read_barrier_depends() do { } while(0)
98 #define set_mb(var, value) do { var = value; smp_mb(); } while (0)
99 #define nop() asm volatile("nop");
101 #define smp_mb__before_atomic() smp_mb()
102 #define smp_mb__after_atomic() smp_mb()
104 #endif /* __ASSEMBLY__ */
106 #endif /* __ASM_BARRIER_H */