From df89bbad4692500e7c089e131a134fe2ff9bc5e1 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 31 Mar 2022 02:22:02 +0000 Subject: [PATCH 30/49] ena: Fix rmb/wmb/mb to match Linux on x86 and aarch64. This is not right but it's not worse than it was before. --- sys/external/bsd/ena-com/ena_plat.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/sys/external/bsd/ena-com/ena_plat.h b/sys/external/bsd/ena-com/ena_plat.h index b280a2adb224..28c41b04aba1 100644 --- a/sys/external/bsd/ena-com/ena_plat.h +++ b/sys/external/bsd/ena-com/ena_plat.h @@ -378,8 +378,23 @@ void prefetch(void *x) #include "ena_defs/ena_includes.h" -#define rmb() membar_enter() -#define wmb() membar_exit() +/* + * XXX This is not really right. Need to adjust the driver to use + * bus_space_barrier or bus_dmamap_sync. + */ +#if defined(__i386__) || defined(__x86_64__) +#include +#define rmb() x86_lfence() +#define wmb() x86_sfence() +#define mb() x86_mfence() +#elif defined(__aarch64__) +#define rmb() __asm __volatile("dsb ld" ::: "memory") +#define wmb() __asm __volatile("dsb st" ::: "memory") +#define mb() __asm __volatile("dsb sy" ::: "memory") +#else +#define rmb() membar_acquire() +#define wmb() membar_release() #define mb() membar_sync() +#endif #endif /* ENA_PLAT_H_ */