From 48fa6c128007469e3d63cb2330b36add3d90ff99 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Tue, 12 Apr 2022 13:38:59 +0300 Subject: [PATCH] arch/risc-v: Add missing DMB to mtimer / setmtimecmp The memory mapped mtimecmp lives in I/O space so must add barrier to make sure the value sticks. Otherwise a new IRQ might fire at once. --- arch/risc-v/src/common/riscv_mtimer.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/risc-v/src/common/riscv_mtimer.c b/arch/risc-v/src/common/riscv_mtimer.c index 112919e4ba4..27ce9e4e411 100644 --- a/arch/risc-v/src/common/riscv_mtimer.c +++ b/arch/risc-v/src/common/riscv_mtimer.c @@ -25,6 +25,8 @@ #include #include +#include + #include "riscv_mtimer.h" #include "riscv_internal.h" @@ -107,6 +109,10 @@ static void riscv_mtimer_set_mtimecmp(struct riscv_mtimer_lowerhalf_s *priv, putreg32(value, priv->mtimecmp); putreg32(value >> 32, priv->mtimecmp + 4); #endif + + /* Make sure it sticks */ + + __DMB(); } /****************************************************************************