Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Sep 2019 22:17:17 +0000 (UTC)
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r352430 - in head/sys/riscv: conf riscv
Message-ID:  <201909162217.x8GMHHat030196@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mhorne
Date: Mon Sep 16 22:17:16 2019
New Revision: 352430
URL: https://svnweb.freebsd.org/changeset/base/352430

Log:
  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

Modified:
  head/sys/riscv/conf/GENERIC
  head/sys/riscv/riscv/clock.c
  head/sys/riscv/riscv/mp_machdep.c

Modified: head/sys/riscv/conf/GENERIC
==============================================================================
--- head/sys/riscv/conf/GENERIC	Mon Sep 16 22:02:14 2019	(r352429)
+++ head/sys/riscv/conf/GENERIC	Mon Sep 16 22:17:16 2019	(r352430)
@@ -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

Modified: head/sys/riscv/riscv/clock.c
==============================================================================
--- head/sys/riscv/riscv/clock.c	Mon Sep 16 22:02:14 2019	(r352429)
+++ head/sys/riscv/riscv/clock.c	Mon Sep 16 22:17:16 2019	(r352430)
@@ -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
 }

Modified: head/sys/riscv/riscv/mp_machdep.c
==============================================================================
--- head/sys/riscv/riscv/mp_machdep.c	Mon Sep 16 22:02:14 2019	(r352429)
+++ head/sys/riscv/riscv/mp_machdep.c	Mon Sep 16 22:17:16 2019	(r352430)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909162217.x8GMHHat030196>