From: mhorne Date: Mon, 16 Sep 2019 22:17:16 +0000 (+0000) Subject: RISC-V: Support EARLY_AP_STARTUP X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e9360c33ab5621b4dc17a3a02423abd84ab52241;p=freebsd.git RISC-V: Support EARLY_AP_STARTUP The EARLY_AP_STARTUP option initializes non-boot processors much sooner during startup. This adds support for this option on RISC-V and enables it by default for GENERIC. Reviewed by: jhb, markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D21661 --- diff --git a/sys/riscv/conf/GENERIC b/sys/riscv/conf/GENERIC index 5b647977879..257b836d0ed 100644 --- a/sys/riscv/conf/GENERIC +++ b/sys/riscv/conf/GENERIC @@ -71,6 +71,7 @@ options RACCT # Resource accounting framework options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default options RCTL # Resource limits options SMP +options EARLY_AP_STARTUP options INTRNG # RISC-V SBI console diff --git a/sys/riscv/riscv/clock.c b/sys/riscv/riscv/clock.c index e0c2d4ba3c0..f69fc321a55 100644 --- a/sys/riscv/riscv/clock.c +++ b/sys/riscv/riscv/clock.c @@ -37,10 +37,34 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include +#include +#include +#include void cpu_initclocks(void) { +#ifdef EARLY_AP_STARTUP + struct thread *td; + int i; + td = curthread; cpu_initclocks_bsp(); + CPU_FOREACH(i) { + if (i == 0) + continue; + thread_lock(td); + sched_bind(td, i); + thread_unlock(td); + cpu_initclocks_ap(); + } + thread_lock(td); + if (sched_is_bound(td)) + sched_unbind(td); + thread_unlock(td); +#else + cpu_initclocks_bsp(); +#endif } diff --git a/sys/riscv/riscv/mp_machdep.c b/sys/riscv/riscv/mp_machdep.c index adffd2fa1e8..f6d3dfce5cd 100644 --- a/sys/riscv/riscv/mp_machdep.c +++ b/sys/riscv/riscv/mp_machdep.c @@ -257,8 +257,10 @@ init_secondary(uint64_t hart) /* Enable software interrupts */ riscv_unmask_ipi(); +#ifndef EARLY_AP_STARTUP /* Start per-CPU event timers. */ cpu_initclocks_ap(); +#endif /* Enable external (PLIC) interrupts */ csr_set(sie, SIE_SEIE);