2012-03-28 17:30:01 +00:00
|
|
|
#ifndef __ASM_BARRIER_H
|
|
|
|
#define __ASM_BARRIER_H
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
2012-03-30 08:57:43 +00:00
|
|
|
#include <asm/outercache.h>
|
2012-03-28 17:30:01 +00:00
|
|
|
|
|
|
|
#define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
|
|
|
|
|
|
|
|
#if __LINUX_ARM_ARCH__ >= 7 || \
|
|
|
|
(__LINUX_ARM_ARCH__ == 6 && defined(CONFIG_CPU_32v6K))
|
|
|
|
#define sev() __asm__ __volatile__ ("sev" : : : "memory")
|
|
|
|
#define wfe() __asm__ __volatile__ ("wfe" : : : "memory")
|
|
|
|
#define wfi() __asm__ __volatile__ ("wfi" : : : "memory")
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if __LINUX_ARM_ARCH__ >= 7
|
2013-05-10 17:07:19 +00:00
|
|
|
#define isb(option) __asm__ __volatile__ ("isb " #option : : : "memory")
|
|
|
|
#define dsb(option) __asm__ __volatile__ ("dsb " #option : : : "memory")
|
|
|
|
#define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
|
2012-03-28 17:30:01 +00:00
|
|
|
#elif defined(CONFIG_CPU_XSC3) || __LINUX_ARM_ARCH__ == 6
|
2013-05-10 17:07:19 +00:00
|
|
|
#define isb(x) __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" \
|
2012-03-28 17:30:01 +00:00
|
|
|
: : "r" (0) : "memory")
|
2013-05-10 17:07:19 +00:00
|
|
|
#define dsb(x) __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \
|
2012-03-28 17:30:01 +00:00
|
|
|
: : "r" (0) : "memory")
|
2013-05-10 17:07:19 +00:00
|
|
|
#define dmb(x) __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" \
|
2012-03-28 17:30:01 +00:00
|
|
|
: : "r" (0) : "memory")
|
|
|
|
#elif defined(CONFIG_CPU_FA526)
|
2013-05-10 17:07:19 +00:00
|
|
|
#define isb(x) __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" \
|
2012-03-28 17:30:01 +00:00
|
|
|
: : "r" (0) : "memory")
|
2013-05-10 17:07:19 +00:00
|
|
|
#define dsb(x) __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \
|
2012-03-28 17:30:01 +00:00
|
|
|
: : "r" (0) : "memory")
|
2013-05-10 17:07:19 +00:00
|
|
|
#define dmb(x) __asm__ __volatile__ ("" : : : "memory")
|
2012-03-28 17:30:01 +00:00
|
|
|
#else
|
2013-05-10 17:07:19 +00:00
|
|
|
#define isb(x) __asm__ __volatile__ ("" : : : "memory")
|
|
|
|
#define dsb(x) __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \
|
2012-03-28 17:30:01 +00:00
|
|
|
: : "r" (0) : "memory")
|
2013-05-10 17:07:19 +00:00
|
|
|
#define dmb(x) __asm__ __volatile__ ("" : : : "memory")
|
2012-03-28 17:30:01 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_ARCH_HAS_BARRIERS
|
|
|
|
#include <mach/barriers.h>
|
|
|
|
#elif defined(CONFIG_ARM_DMA_MEM_BUFFERABLE) || defined(CONFIG_SMP)
|
|
|
|
#define mb() do { dsb(); outer_sync(); } while (0)
|
|
|
|
#define rmb() dsb()
|
2013-05-10 17:07:19 +00:00
|
|
|
#define wmb() do { dsb(st); outer_sync(); } while (0)
|
2012-03-28 17:30:01 +00:00
|
|
|
#else
|
2012-08-21 10:26:24 +00:00
|
|
|
#define mb() barrier()
|
|
|
|
#define rmb() barrier()
|
|
|
|
#define wmb() barrier()
|
2012-03-28 17:30:01 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_SMP
|
|
|
|
#define smp_mb() barrier()
|
|
|
|
#define smp_rmb() barrier()
|
|
|
|
#define smp_wmb() barrier()
|
|
|
|
#else
|
2013-05-10 17:07:19 +00:00
|
|
|
#define smp_mb() dmb(ish)
|
|
|
|
#define smp_rmb() smp_mb()
|
|
|
|
#define smp_wmb() dmb(ishst)
|
2012-03-28 17:30:01 +00:00
|
|
|
#endif
|
|
|
|
|
2013-11-06 13:57:36 +00:00
|
|
|
#define smp_store_release(p, v) \
|
|
|
|
do { \
|
|
|
|
compiletime_assert_atomic_type(*p); \
|
|
|
|
smp_mb(); \
|
|
|
|
ACCESS_ONCE(*p) = (v); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define smp_load_acquire(p) \
|
|
|
|
({ \
|
|
|
|
typeof(*p) ___p1 = ACCESS_ONCE(*p); \
|
|
|
|
compiletime_assert_atomic_type(*p); \
|
|
|
|
smp_mb(); \
|
|
|
|
___p1; \
|
|
|
|
})
|
|
|
|
|
2012-03-28 17:30:01 +00:00
|
|
|
#define read_barrier_depends() do { } while(0)
|
|
|
|
#define smp_read_barrier_depends() do { } while(0)
|
|
|
|
|
|
|
|
#define set_mb(var, value) do { var = value; smp_mb(); } while (0)
|
|
|
|
|
2014-03-12 16:11:00 +00:00
|
|
|
#define smp_mb__before_atomic() smp_mb()
|
|
|
|
#define smp_mb__after_atomic() smp_mb()
|
|
|
|
|
2012-03-28 17:30:01 +00:00
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
|
|
#endif /* __ASM_BARRIER_H */
|