Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copied from the kernel sources to tools/:
0004  *
0005  * Memory barrier definitions.  This is based on information published
0006  * in the Processor Abstraction Layer and the System Abstraction Layer
0007  * manual.
0008  *
0009  * Copyright (C) 1998-2003 Hewlett-Packard Co
0010  *  David Mosberger-Tang <davidm@hpl.hp.com>
0011  * Copyright (C) 1999 Asit Mallick <asit.k.mallick@intel.com>
0012  * Copyright (C) 1999 Don Dugger <don.dugger@intel.com>
0013  */
0014 #ifndef _TOOLS_LINUX_ASM_IA64_BARRIER_H
0015 #define _TOOLS_LINUX_ASM_IA64_BARRIER_H
0016 
0017 #include <linux/compiler.h>
0018 
0019 /*
0020  * Macros to force memory ordering.  In these descriptions, "previous"
0021  * and "subsequent" refer to program order; "visible" means that all
0022  * architecturally visible effects of a memory access have occurred
0023  * (at a minimum, this means the memory has been read or written).
0024  *
0025  *   wmb(): Guarantees that all preceding stores to memory-
0026  *      like regions are visible before any subsequent
0027  *      stores and that all following stores will be
0028  *      visible only after all previous stores.
0029  *   rmb(): Like wmb(), but for reads.
0030  *   mb():  wmb()/rmb() combo, i.e., all previous memory
0031  *      accesses are visible before all subsequent
0032  *      accesses and vice versa.  This is also known as
0033  *      a "fence."
0034  *
0035  * Note: "mb()" and its variants cannot be used as a fence to order
0036  * accesses to memory mapped I/O registers.  For that, mf.a needs to
0037  * be used.  However, we don't want to always use mf.a because (a)
0038  * it's (presumably) much slower than mf and (b) mf.a is supported for
0039  * sequential memory pages only.
0040  */
0041 
0042 #define mb()        ia64_mf()
0043 #define rmb()       mb()
0044 #define wmb()       mb()
0045 
0046 #define smp_store_release(p, v)         \
0047 do {                        \
0048     barrier();              \
0049     WRITE_ONCE(*p, v);          \
0050 } while (0)
0051 
0052 #define smp_load_acquire(p)         \
0053 ({                      \
0054     typeof(*p) ___p1 = READ_ONCE(*p);   \
0055     barrier();              \
0056     ___p1;                  \
0057 })
0058 
0059 #endif /* _TOOLS_LINUX_ASM_IA64_BARRIER_H */