18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2018 ARM Limited
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci#ifndef __COMPAT_BARRIER_H
68c2ecf20Sopenharmony_ci#define __COMPAT_BARRIER_H
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
98c2ecf20Sopenharmony_ci/*
108c2ecf20Sopenharmony_ci * Warning: This code is meant to be used with
118c2ecf20Sopenharmony_ci * ENABLE_COMPAT_VDSO only.
128c2ecf20Sopenharmony_ci */
138c2ecf20Sopenharmony_ci#ifndef ENABLE_COMPAT_VDSO
148c2ecf20Sopenharmony_ci#error This header is meant to be used with ENABLE_COMPAT_VDSO only
158c2ecf20Sopenharmony_ci#endif
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#ifdef dmb
188c2ecf20Sopenharmony_ci#undef dmb
198c2ecf20Sopenharmony_ci#endif
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
248c2ecf20Sopenharmony_ci#define aarch32_smp_mb()	dmb(ish)
258c2ecf20Sopenharmony_ci#define aarch32_smp_rmb()	dmb(ishld)
268c2ecf20Sopenharmony_ci#define aarch32_smp_wmb()	dmb(ishst)
278c2ecf20Sopenharmony_ci#else
288c2ecf20Sopenharmony_ci#define aarch32_smp_mb()	dmb(ish)
298c2ecf20Sopenharmony_ci#define aarch32_smp_rmb()	aarch32_smp_mb()
308c2ecf20Sopenharmony_ci#define aarch32_smp_wmb()	dmb(ishst)
318c2ecf20Sopenharmony_ci#endif
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#undef smp_mb
358c2ecf20Sopenharmony_ci#undef smp_rmb
368c2ecf20Sopenharmony_ci#undef smp_wmb
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#define smp_mb()	aarch32_smp_mb()
398c2ecf20Sopenharmony_ci#define smp_rmb()	aarch32_smp_rmb()
408c2ecf20Sopenharmony_ci#define smp_wmb()	aarch32_smp_wmb()
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#endif /* __COMPAT_BARRIER_H */
45