]> xenbits.xensource.com Git - freebsd.git/commitdiff
RISC-V: Support EARLY_AP_STARTUP
authormhorne <mhorne@FreeBSD.org>
Mon, 16 Sep 2019 22:17:16 +0000 (22:17 +0000)
committermhorne <mhorne@FreeBSD.org>
Mon, 16 Sep 2019 22:17:16 +0000 (22:17 +0000)
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

sys/riscv/conf/GENERIC
sys/riscv/riscv/clock.c
sys/riscv/riscv/mp_machdep.c

index 5b647977879fd88aaa038ece8bfbac8944164910..257b836d0ed59bfbbd883afedb384e9c47bbdd21 100644 (file)
@@ -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
index e0c2d4ba3c0bf54087134883e83c229e74f682c4..f69fc321a5563c6b8d3593814baa00e84e73eb93 100644 (file)
@@ -37,10 +37,34 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/types.h>
 #include <sys/systm.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/proc.h>
+#include <sys/sched.h>
+#include <sys/smp.h>
 
 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
 }
index adffd2fa1e866519b05305792ae2aa74429342e2..f6d3dfce5cda762d3cb17ab59e359e8ad72abf1c 100644 (file)
@@ -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);