The RISC-V architecture specification says that memory read/writes are
authorkettenis <kettenis@openbsd.org>
Wed, 27 Mar 2024 23:10:18 +0000 (23:10 +0000)
committerkettenis <kettenis@openbsd.org>
Wed, 27 Mar 2024 23:10:18 +0000 (23:10 +0000)
commita3fd9ccd2992e33e45c4ee35fb816cb267314f0a
treec158a5442da1c354670ef92c704368ac3f035077
parent3fe5dae2ec441a3017833425acacc03e363b19df
The RISC-V architecture specification says that memory read/writes are
not ordered with respect to mmio read/writes.  This appears to happen on
T-Head C920 cores as I'm seeing interrupts being enabled before the lock
is released in mtx_leave() despite program order releasing the lock
before enabling interrupts.  This is fixed by adding the necessary fences
in more or less the same places where Linux uses them.

ok patrick@, jca@
sys/arch/riscv64/include/bus.h
sys/arch/riscv64/riscv64/bus_space.c