Disparate fence implementations are consolidated into fence.h. Also introduce RISCV_FENCE_ASM to make fence macro more reusable. Signed-off-by: Eric Chan <ericchancf@google.com> Reviewed-by: Andrea Parri <parri.andrea@gmail.com> Reviewed-by: Samuel Holland <samuel.holland@sifive.com> Tested-by: Samuel Holland <samuel.holland@sifive.com> Link: https://lore.kernel.org/r/20240217131316.3668927-1-ericchancf@google.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
18 lines
520 B
C
18 lines
520 B
C
#ifndef _ASM_RISCV_FENCE_H
|
|
#define _ASM_RISCV_FENCE_H
|
|
|
|
#define RISCV_FENCE_ASM(p, s) "\tfence " #p "," #s "\n"
|
|
#define RISCV_FENCE(p, s) \
|
|
({ __asm__ __volatile__ (RISCV_FENCE_ASM(p, s) : : : "memory"); })
|
|
|
|
#ifdef CONFIG_SMP
|
|
#define RISCV_ACQUIRE_BARRIER RISCV_FENCE_ASM(r, rw)
|
|
#define RISCV_RELEASE_BARRIER RISCV_FENCE_ASM(rw, w)
|
|
#define RISCV_FULL_BARRIER RISCV_FENCE_ASM(rw, rw)
|
|
#else
|
|
#define RISCV_ACQUIRE_BARRIER
|
|
#define RISCV_RELEASE_BARRIER
|
|
#define RISCV_FULL_BARRIER
|
|
#endif
|
|
|
|
#endif /* _ASM_RISCV_FENCE_H */
|