Skip to content

Commit

Permalink
clocksource/drivers/riscv: Patch riscv_clock_next_event() jump before…
Browse files Browse the repository at this point in the history
… 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]>
  • Loading branch information
mevrv authored and dlezcano committed Feb 13, 2023
1 parent f3af3dc commit 225b959
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/clocksource/timer-riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,18 @@ static int __init riscv_timer_init_dt(struct device_node *n)
return error;
}

if (riscv_isa_extension_available(NULL, SSTC)) {
pr_info("Timer interrupt in S-mode is available via sstc extension\n");
static_branch_enable(&riscv_sstc_available);
}

error = cpuhp_setup_state(CPUHP_AP_RISCV_TIMER_STARTING,
"clockevents/riscv/timer:starting",
riscv_timer_starting_cpu, riscv_timer_dying_cpu);
if (error)
pr_err("cpu hp setup state failed for RISCV timer [%d]\n",
error);

if (riscv_isa_extension_available(NULL, SSTC)) {
pr_info("Timer interrupt in S-mode is available via sstc extension\n");
static_branch_enable(&riscv_sstc_available);
}

return error;
}

Expand Down

0 comments on commit 225b959

Please sign in to comment.