Path: blob/master/tools/arch/riscv/include/asm/barrier.h
26308 views
/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Copied from the kernel sources to tools/arch/riscv:3*4* Copyright (C) 2012 ARM Ltd.5* Copyright (C) 2013 Regents of the University of California6* Copyright (C) 2017 SiFive7*/89#ifndef _TOOLS_LINUX_ASM_RISCV_BARRIER_H10#define _TOOLS_LINUX_ASM_RISCV_BARRIER_H1112#include <asm/fence.h>13#include <linux/compiler.h>1415/* These barriers need to enforce ordering on both devices and memory. */16#define mb() RISCV_FENCE(iorw, iorw)17#define rmb() RISCV_FENCE(ir, ir)18#define wmb() RISCV_FENCE(ow, ow)1920/* These barriers do not need to enforce ordering on devices, just memory. */21#define smp_mb() RISCV_FENCE(rw, rw)22#define smp_rmb() RISCV_FENCE(r, r)23#define smp_wmb() RISCV_FENCE(w, w)2425#define smp_store_release(p, v) \26do { \27RISCV_FENCE(rw, w); \28WRITE_ONCE(*p, v); \29} while (0)3031#define smp_load_acquire(p) \32({ \33typeof(*p) ___p1 = READ_ONCE(*p); \34RISCV_FENCE(r, rw); \35___p1; \36})3738#endif /* _TOOLS_LINUX_ASM_RISCV_BARRIER_H */394041