[PATCH v1] bsps/riscv: Give enough time for clock driver initialization

Jan Sommer jan.sommer at dlr.de
Mon Jun 7 15:47:13 UTC 2021


- Clock driver initialization for secondary cores had to take less than
one tick
- If tick time is small (i.e. <= 1ms) setting up all cores could take
too long and a fatal error is thrown.
- Give at least 10 ms time for clock initialization to avoid this error
---
 bsps/riscv/riscv/clock/clockdrv.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/bsps/riscv/riscv/clock/clockdrv.c b/bsps/riscv/riscv/clock/clockdrv.c
index 3afe86576f..102137aeab 100644
--- a/bsps/riscv/riscv/clock/clockdrv.c
+++ b/bsps/riscv/riscv/clock/clockdrv.c
@@ -211,7 +211,13 @@ static void riscv_clock_initialize(void)
   tc->interval = interval;
 
   cmpval = riscv_clock_read_mtime(&clint->mtime);
-  cmpval += interval;
+  /*
+   * For very short intervals the time of 1 tick is not enough to
+   * set up the timer on all cores in SMP systems.
+   * Give the CPU at least 10 ms.
+   */
+  interval = (10000 / us_per_tick) * interval;
+  cmpval += interval; 
 
   riscv_clock_clint_init(clint, cmpval, 0);
   riscv_clock_secondary_initialization(clint, cmpval, interval);
-- 
2.17.1



More information about the devel mailing list