Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Daniel Borkmann | 09d62154 | 2018-10-19 15:51:02 +0200 | [diff] [blame] | 2 | #include <linux/compiler.h> |
Arnaldo Carvalho de Melo | 361c564 | 2015-04-30 12:33:22 -0300 | [diff] [blame] | 3 | #if defined(__i386__) || defined(__x86_64__) |
| 4 | #include "../../arch/x86/include/asm/barrier.h" |
Arnaldo Carvalho de Melo | 4f3db07 | 2015-05-07 18:14:25 -0300 | [diff] [blame] | 5 | #elif defined(__arm__) |
| 6 | #include "../../arch/arm/include/asm/barrier.h" |
| 7 | #elif defined(__aarch64__) |
| 8 | #include "../../arch/arm64/include/asm/barrier.h" |
Arnaldo Carvalho de Melo | e43a19c | 2015-05-06 18:35:20 -0300 | [diff] [blame] | 9 | #elif defined(__powerpc__) |
| 10 | #include "../../arch/powerpc/include/asm/barrier.h" |
Arnaldo Carvalho de Melo | 07d207a | 2015-05-06 18:44:53 -0300 | [diff] [blame] | 11 | #elif defined(__s390__) |
| 12 | #include "../../arch/s390/include/asm/barrier.h" |
Arnaldo Carvalho de Melo | 827634a | 2015-05-07 17:09:48 -0300 | [diff] [blame] | 13 | #elif defined(__sh__) |
| 14 | #include "../../arch/sh/include/asm/barrier.h" |
Arnaldo Carvalho de Melo | 94cdda6 | 2015-05-07 17:27:23 -0300 | [diff] [blame] | 15 | #elif defined(__sparc__) |
| 16 | #include "../../arch/sparc/include/asm/barrier.h" |
Arnaldo Carvalho de Melo | d3bd708 | 2015-05-08 10:02:00 -0300 | [diff] [blame] | 17 | #elif defined(__tile__) |
| 18 | #include "../../arch/tile/include/asm/barrier.h" |
Arnaldo Carvalho de Melo | 0da85d1 | 2015-05-07 17:52:19 -0300 | [diff] [blame] | 19 | #elif defined(__alpha__) |
| 20 | #include "../../arch/alpha/include/asm/barrier.h" |
Arnaldo Carvalho de Melo | e2164f0 | 2015-05-08 09:40:36 -0300 | [diff] [blame] | 21 | #elif defined(__mips__) |
| 22 | #include "../../arch/mips/include/asm/barrier.h" |
Arnaldo Carvalho de Melo | 163e589 | 2015-05-07 18:03:14 -0300 | [diff] [blame] | 23 | #elif defined(__ia64__) |
| 24 | #include "../../arch/ia64/include/asm/barrier.h" |
Arnaldo Carvalho de Melo | 3d3337d | 2015-05-08 08:53:26 -0300 | [diff] [blame] | 25 | #elif defined(__xtensa__) |
| 26 | #include "../../arch/xtensa/include/asm/barrier.h" |
Nickhu | ebd0975 | 2018-10-25 10:24:15 +0800 | [diff] [blame] | 27 | #elif defined(__nds32__) |
| 28 | #include "../../arch/nds32/include/asm/barrier.h" |
Arnaldo Carvalho de Melo | 42b09d7 | 2015-05-07 17:17:17 -0300 | [diff] [blame] | 29 | #else |
| 30 | #include <asm-generic/barrier.h> |
Arnaldo Carvalho de Melo | 361c564 | 2015-04-30 12:33:22 -0300 | [diff] [blame] | 31 | #endif |
Daniel Borkmann | 09d62154 | 2018-10-19 15:51:02 +0200 | [diff] [blame] | 32 | |
| 33 | /* |
| 34 | * Generic fallback smp_*() definitions for archs that haven't |
| 35 | * been updated yet. |
| 36 | */ |
| 37 | |
| 38 | #ifndef smp_rmb |
| 39 | # define smp_rmb() rmb() |
| 40 | #endif |
| 41 | |
| 42 | #ifndef smp_wmb |
| 43 | # define smp_wmb() wmb() |
| 44 | #endif |
| 45 | |
| 46 | #ifndef smp_mb |
| 47 | # define smp_mb() mb() |
| 48 | #endif |
| 49 | |
| 50 | #ifndef smp_store_release |
| 51 | # define smp_store_release(p, v) \ |
| 52 | do { \ |
| 53 | smp_mb(); \ |
| 54 | WRITE_ONCE(*p, v); \ |
| 55 | } while (0) |
| 56 | #endif |
| 57 | |
| 58 | #ifndef smp_load_acquire |
| 59 | # define smp_load_acquire(p) \ |
| 60 | ({ \ |
| 61 | typeof(*p) ___p1 = READ_ONCE(*p); \ |
| 62 | smp_mb(); \ |
| 63 | ___p1; \ |
| 64 | }) |
| 65 | #endif |