162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copied from the kernel sources to tools/: 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Memory barrier definitions. This is based on information published 662306a36Sopenharmony_ci * in the Processor Abstraction Layer and the System Abstraction Layer 762306a36Sopenharmony_ci * manual. 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * Copyright (C) 1998-2003 Hewlett-Packard Co 1062306a36Sopenharmony_ci * David Mosberger-Tang <davidm@hpl.hp.com> 1162306a36Sopenharmony_ci * Copyright (C) 1999 Asit Mallick <asit.k.mallick@intel.com> 1262306a36Sopenharmony_ci * Copyright (C) 1999 Don Dugger <don.dugger@intel.com> 1362306a36Sopenharmony_ci */ 1462306a36Sopenharmony_ci#ifndef _TOOLS_LINUX_ASM_IA64_BARRIER_H 1562306a36Sopenharmony_ci#define _TOOLS_LINUX_ASM_IA64_BARRIER_H 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#include <linux/compiler.h> 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci/* 2062306a36Sopenharmony_ci * Macros to force memory ordering. In these descriptions, "previous" 2162306a36Sopenharmony_ci * and "subsequent" refer to program order; "visible" means that all 2262306a36Sopenharmony_ci * architecturally visible effects of a memory access have occurred 2362306a36Sopenharmony_ci * (at a minimum, this means the memory has been read or written). 2462306a36Sopenharmony_ci * 2562306a36Sopenharmony_ci * wmb(): Guarantees that all preceding stores to memory- 2662306a36Sopenharmony_ci * like regions are visible before any subsequent 2762306a36Sopenharmony_ci * stores and that all following stores will be 2862306a36Sopenharmony_ci * visible only after all previous stores. 2962306a36Sopenharmony_ci * rmb(): Like wmb(), but for reads. 3062306a36Sopenharmony_ci * mb(): wmb()/rmb() combo, i.e., all previous memory 3162306a36Sopenharmony_ci * accesses are visible before all subsequent 3262306a36Sopenharmony_ci * accesses and vice versa. This is also known as 3362306a36Sopenharmony_ci * a "fence." 3462306a36Sopenharmony_ci * 3562306a36Sopenharmony_ci * Note: "mb()" and its variants cannot be used as a fence to order 3662306a36Sopenharmony_ci * accesses to memory mapped I/O registers. For that, mf.a needs to 3762306a36Sopenharmony_ci * be used. However, we don't want to always use mf.a because (a) 3862306a36Sopenharmony_ci * it's (presumably) much slower than mf and (b) mf.a is supported for 3962306a36Sopenharmony_ci * sequential memory pages only. 4062306a36Sopenharmony_ci */ 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci#define mb() ia64_mf() 4362306a36Sopenharmony_ci#define rmb() mb() 4462306a36Sopenharmony_ci#define wmb() mb() 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci#define smp_store_release(p, v) \ 4762306a36Sopenharmony_cido { \ 4862306a36Sopenharmony_ci barrier(); \ 4962306a36Sopenharmony_ci WRITE_ONCE(*p, v); \ 5062306a36Sopenharmony_ci} while (0) 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci#define smp_load_acquire(p) \ 5362306a36Sopenharmony_ci({ \ 5462306a36Sopenharmony_ci typeof(*p) ___p1 = READ_ONCE(*p); \ 5562306a36Sopenharmony_ci barrier(); \ 5662306a36Sopenharmony_ci ___p1; \ 5762306a36Sopenharmony_ci}) 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci#endif /* _TOOLS_LINUX_ASM_IA64_BARRIER_H */ 60