Path: blob/master/tools/arch/powerpc/include/asm/barrier.h
26299 views
/* SPDX-License-Identifier: GPL-2.0 */1/*2* Copied from the kernel sources:3*4* Copyright (C) 1999 Cort Dougan <[email protected]>5*/6#ifndef _TOOLS_LINUX_ASM_POWERPC_BARRIER_H7#define _TOOLS_LINUX_ASM_POWERPC_BARRIER_H89/*10* Memory barrier.11* The sync instruction guarantees that all memory accesses initiated12* by this processor have been performed (with respect to all other13* mechanisms that access memory). The eieio instruction is a barrier14* providing an ordering (separately) for (a) cacheable stores and (b)15* loads and stores to non-cacheable memory (e.g. I/O devices).16*17* mb() prevents loads and stores being reordered across this point.18* rmb() prevents loads being reordered across this point.19* wmb() prevents stores being reordered across this point.20*21* *mb() variants without smp_ prefix must order all types of memory22* operations with one another. sync is the only instruction sufficient23* to do this.24*/25#define mb() __asm__ __volatile__ ("sync" : : : "memory")26#define rmb() __asm__ __volatile__ ("sync" : : : "memory")27#define wmb() __asm__ __volatile__ ("sync" : : : "memory")2829#if defined(__powerpc64__)30#define smp_lwsync() __asm__ __volatile__ ("lwsync" : : : "memory")3132#define smp_store_release(p, v) \33do { \34smp_lwsync(); \35WRITE_ONCE(*p, v); \36} while (0)3738#define smp_load_acquire(p) \39({ \40typeof(*p) ___p1 = READ_ONCE(*p); \41smp_lwsync(); \42___p1; \43})44#endif /* defined(__powerpc64__) */45#endif /* _TOOLS_LINUX_ASM_POWERPC_BARRIER_H */464748