Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

riscv/barrier: Define __smp_{store_release,load_acquire}

Introduce __smp_{store_release,load_acquire}, and rely on the generic
definitions for smp_{store_release,load_acquire}. This avoids the use
of full ("rw,rw") fences on SMP.

Signed-off-by: Andrea Parri <parri.andrea@gmail.com>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>

authored by

Andrea Parri and committed by
Palmer Dabbelt
8d235b17 0adb3285

+15
+15
arch/riscv/include/asm/barrier.h
··· 38 38 #define __smp_rmb() RISCV_FENCE(r,r) 39 39 #define __smp_wmb() RISCV_FENCE(w,w) 40 40 41 + #define __smp_store_release(p, v) \ 42 + do { \ 43 + compiletime_assert_atomic_type(*p); \ 44 + RISCV_FENCE(rw,w); \ 45 + WRITE_ONCE(*p, v); \ 46 + } while (0) 47 + 48 + #define __smp_load_acquire(p) \ 49 + ({ \ 50 + typeof(*p) ___p1 = READ_ONCE(*p); \ 51 + compiletime_assert_atomic_type(*p); \ 52 + RISCV_FENCE(r,rw); \ 53 + ___p1; \ 54 + }) 55 + 41 56 /* 42 57 * This is a very specific barrier: it's currently only used in two places in 43 58 * the kernel, both in the scheduler. See include/linux/spinlock.h for the two