Skip to content

Commit 225b959

Browse files
mevrvdlezcano
authored andcommitted
clocksource/drivers/riscv: Patch riscv_clock_next_event() jump before first use
A static key is used to select between SBI and Sstc timer usage in riscv_clock_next_event(), but currently the direction is resolved after cpuhp_setup_state() is called (which sets the next event). The first event will therefore fall through the sbi_set_timer() path; this breaks Sstc-only systems. So, apply the jump patching before first use. Fixes: 9f7a8ff ("RISC-V: Prefer sstc extension if available") Signed-off-by: Matt Evans <[email protected]> Reviewed-by: Palmer Dabbelt <[email protected]> Acked-by: Palmer Dabbelt <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
1 parent f3af3dc commit 225b959

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/clocksource/timer-riscv.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,18 @@ static int __init riscv_timer_init_dt(struct device_node *n)
192192
return error;
193193
}
194194

195+
if (riscv_isa_extension_available(NULL, SSTC)) {
196+
pr_info("Timer interrupt in S-mode is available via sstc extension\n");
197+
static_branch_enable(&riscv_sstc_available);
198+
}
199+
195200
error = cpuhp_setup_state(CPUHP_AP_RISCV_TIMER_STARTING,
196201
"clockevents/riscv/timer:starting",
197202
riscv_timer_starting_cpu, riscv_timer_dying_cpu);
198203
if (error)
199204
pr_err("cpu hp setup state failed for RISCV timer [%d]\n",
200205
error);
201206

202-
if (riscv_isa_extension_available(NULL, SSTC)) {
203-
pr_info("Timer interrupt in S-mode is available via sstc extension\n");
204-
static_branch_enable(&riscv_sstc_available);
205-
}
206-
207207
return error;
208208
}
209209

0 commit comments

Comments
 (0)