Skip to content

Commit 38b7c2a

Browse files
RISC-V: Upgrade smp_mb__after_spinlock() to iorw,iorw
While digging through the recent mmiowb preemption issue it came up that we aren't actually preventing IO from crossing a scheduling boundary. While it's a bit ugly to overload smp_mb__after_spinlock() with this behavior, it's what PowerPC is doing so there's some precedent. Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 0cac21b commit 38b7c2a

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

arch/riscv/include/asm/barrier.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,16 @@ do { \
5858
* The AQ/RL pair provides a RCpc critical section, but there's not really any
5959
* way we can take advantage of that here because the ordering is only enforced
6060
* on that one lock. Thus, we're just doing a full fence.
61+
*
62+
* Since we allow writeX to be called from preemptive regions we need at least
63+
* an "o" in the predecessor set to ensure device writes are visible before the
64+
* task is marked as available for scheduling on a new hart. While I don't see
65+
* any concrete reason we need a full IO fence, it seems safer to just upgrade
66+
* this in order to avoid any IO crossing a scheduling boundary. In both
67+
* instances the scheduler pairs this with an mb(), so nothing is necessary on
68+
* the new hart.
6169
*/
62-
#define smp_mb__after_spinlock() RISCV_FENCE(rw,rw)
70+
#define smp_mb__after_spinlock() RISCV_FENCE(iorw,iorw)
6371

6472
#include <asm-generic/barrier.h>
6573

0 commit comments

Comments
 (0)