Commit 225b9596 authored by Matt Evans's avatar Matt Evans Committed by Daniel Lezcano
Browse files

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: 9f7a8ff6 ("RISC-V: Prefer sstc extension if available")
Signed-off-by: default avatarMatt Evans <mev@rivosinc.com>
Reviewed-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
Acked-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/CDDAB2D0-264E-42F3-8E31-BA210BEB8EC1@rivosinc.com


Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent f3af3dc7
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -192,6 +192,11 @@ 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);
@@ -199,11 +204,6 @@ static int __init riscv_timer_init_dt(struct device_node *n)
		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;
}