From 6b641c3483b3be3351c39c50d5c8aef685407ed9 Mon Sep 17 00:00:00 2001 From: Conor Paxton Date: Mon, 16 Jan 2023 14:20:41 +0000 Subject: [PATCH] drivers: timer: get mtime cmp reg by reading mhartid It is not guaranteed that a multi-core RISC-V hart numbering scheme will match Zephyr's sequential cpu numbering scheme. Read the hartid and use that value in calculation to get mtime_cmp reg, instead of the current_cpu id. Signed-off-by: Conor Paxton --- drivers/timer/riscv_machine_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/timer/riscv_machine_timer.c b/drivers/timer/riscv_machine_timer.c index 1b3a2ee1baa..dfbdd777197 100644 --- a/drivers/timer/riscv_machine_timer.c +++ b/drivers/timer/riscv_machine_timer.c @@ -74,7 +74,7 @@ const int32_t z_sys_timer_irq_for_test = TIMER_IRQN; static uint64_t get_hart_mtimecmp(void) { - return MTIMECMP_REG + (_current_cpu->id * 8); + return MTIMECMP_REG + (arch_proc_id() * 8); } static void set_mtimecmp(uint64_t time)