Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
David Howells | c140d87 | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Memory barrier definitions. This is based on information published |
| 4 | * in the Processor Abstraction Layer and the System Abstraction Layer |
| 5 | * manual. |
| 6 | * |
| 7 | * Copyright (C) 1998-2003 Hewlett-Packard Co |
| 8 | * David Mosberger-Tang <davidm@hpl.hp.com> |
| 9 | * Copyright (C) 1999 Asit Mallick <asit.k.mallick@intel.com> |
| 10 | * Copyright (C) 1999 Don Dugger <don.dugger@intel.com> |
| 11 | */ |
| 12 | #ifndef _ASM_IA64_BARRIER_H |
| 13 | #define _ASM_IA64_BARRIER_H |
| 14 | |
| 15 | #include <linux/compiler.h> |
| 16 | |
| 17 | /* |
| 18 | * Macros to force memory ordering. In these descriptions, "previous" |
| 19 | * and "subsequent" refer to program order; "visible" means that all |
| 20 | * architecturally visible effects of a memory access have occurred |
| 21 | * (at a minimum, this means the memory has been read or written). |
| 22 | * |
| 23 | * wmb(): Guarantees that all preceding stores to memory- |
| 24 | * like regions are visible before any subsequent |
| 25 | * stores and that all following stores will be |
| 26 | * visible only after all previous stores. |
| 27 | * rmb(): Like wmb(), but for reads. |
| 28 | * mb(): wmb()/rmb() combo, i.e., all previous memory |
| 29 | * accesses are visible before all subsequent |
| 30 | * accesses and vice versa. This is also known as |
| 31 | * a "fence." |
| 32 | * |
| 33 | * Note: "mb()" and its variants cannot be used as a fence to order |
| 34 | * accesses to memory mapped I/O registers. For that, mf.a needs to |
| 35 | * be used. However, we don't want to always use mf.a because (a) |
| 36 | * it's (presumably) much slower than mf and (b) mf.a is supported for |
| 37 | * sequential memory pages only. |
| 38 | */ |
Alexander Duyck | 8a44971 | 2014-12-11 15:01:55 -0800 | [diff] [blame] | 39 | #define mb() ia64_mf() |
| 40 | #define rmb() mb() |
| 41 | #define wmb() mb() |
David Howells | c140d87 | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 42 | |
Alexander Duyck | 1077fa3 | 2014-12-11 15:02:06 -0800 | [diff] [blame] | 43 | #define dma_rmb() mb() |
| 44 | #define dma_wmb() mb() |
| 45 | |
Michael S. Tsirkin | eebd1b9 | 2015-12-27 15:04:42 +0200 | [diff] [blame] | 46 | # define __smp_mb() mb() |
David Howells | c140d87 | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 47 | |
Michael S. Tsirkin | eebd1b9 | 2015-12-27 15:04:42 +0200 | [diff] [blame] | 48 | #define __smp_mb__before_atomic() barrier() |
| 49 | #define __smp_mb__after_atomic() barrier() |
Peter Zijlstra | 0cd64ef | 2014-03-13 19:00:36 +0100 | [diff] [blame] | 50 | |
David Howells | c140d87 | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 51 | /* |
Peter Zijlstra | 47933ad | 2013-11-06 14:57:36 +0100 | [diff] [blame] | 52 | * IA64 GCC turns volatile stores into st.rel and volatile loads into ld.acq no |
| 53 | * need for asm trickery! |
| 54 | */ |
| 55 | |
Michael S. Tsirkin | eebd1b9 | 2015-12-27 15:04:42 +0200 | [diff] [blame] | 56 | #define __smp_store_release(p, v) \ |
Peter Zijlstra | 47933ad | 2013-11-06 14:57:36 +0100 | [diff] [blame] | 57 | do { \ |
| 58 | compiletime_assert_atomic_type(*p); \ |
| 59 | barrier(); \ |
Andrey Konovalov | 76695af | 2015-08-02 17:11:04 +0200 | [diff] [blame] | 60 | WRITE_ONCE(*p, v); \ |
Peter Zijlstra | 47933ad | 2013-11-06 14:57:36 +0100 | [diff] [blame] | 61 | } while (0) |
| 62 | |
Michael S. Tsirkin | eebd1b9 | 2015-12-27 15:04:42 +0200 | [diff] [blame] | 63 | #define __smp_load_acquire(p) \ |
Peter Zijlstra | 47933ad | 2013-11-06 14:57:36 +0100 | [diff] [blame] | 64 | ({ \ |
Andrey Konovalov | 76695af | 2015-08-02 17:11:04 +0200 | [diff] [blame] | 65 | typeof(*p) ___p1 = READ_ONCE(*p); \ |
Peter Zijlstra | 47933ad | 2013-11-06 14:57:36 +0100 | [diff] [blame] | 66 | compiletime_assert_atomic_type(*p); \ |
| 67 | barrier(); \ |
| 68 | ___p1; \ |
| 69 | }) |
| 70 | |
David Howells | c140d87 | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 71 | /* |
| 72 | * The group barrier in front of the rsm & ssm are necessary to ensure |
| 73 | * that none of the previous instructions in the same group are |
| 74 | * affected by the rsm/ssm. |
| 75 | */ |
| 76 | |
Michael S. Tsirkin | 53a05ac | 2015-12-21 09:22:18 +0200 | [diff] [blame] | 77 | #include <asm-generic/barrier.h> |
| 78 | |
David Howells | c140d87 | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 79 | #endif /* _ASM_IA64_BARRIER_H */ |