Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Mar 2017 12:45:54 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r315450 - in head/sys: arm/qemu dev/fdt
Message-ID:  <201703171245.v2HCjsJL030342@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Fri Mar 17 12:45:53 2017
New Revision: 315450
URL: https://svnweb.freebsd.org/changeset/base/315450

Log:
  Make the default FDT implementation of platform_mp_setmaxid use the cpu
  nodes from the DTB by default. This will allow us to enumerate the CPUs
  without hard coding the CPU count into code.
  
  Reviewed by:	br
  Sponsored by:	ABT Systems Ltd
  Differential Revision:	https://reviews.freebsd.org/D9827

Modified:
  head/sys/arm/qemu/virt_machdep.c
  head/sys/arm/qemu/virt_mp.c
  head/sys/dev/fdt/fdt_arm_platform.c

Modified: head/sys/arm/qemu/virt_machdep.c
==============================================================================
--- head/sys/arm/qemu/virt_machdep.c	Fri Mar 17 12:34:57 2017	(r315449)
+++ head/sys/arm/qemu/virt_machdep.c	Fri Mar 17 12:45:53 2017	(r315450)
@@ -60,7 +60,6 @@ static platform_method_t virt_methods[] 
 
 #ifdef SMP
 	PLATFORMMETHOD(platform_mp_start_ap,	virt_mp_start_ap),
-	PLATFORMMETHOD(platform_mp_setmaxid,	virt_mp_setmaxid),
 #endif
 
 	PLATFORMMETHOD_END,

Modified: head/sys/arm/qemu/virt_mp.c
==============================================================================
--- head/sys/arm/qemu/virt_mp.c	Fri Mar 17 12:34:57 2017	(r315449)
+++ head/sys/arm/qemu/virt_mp.c	Fri Mar 17 12:45:53 2017	(r315450)
@@ -50,27 +50,6 @@ __FBSDID("$FreeBSD$");
 static int running_cpus;
 
 static boolean_t
-virt_maxid(u_int id, phandle_t node, u_int addr_cells, pcell_t *reg)
-{
-
-	if (mp_maxid < id)
-		mp_maxid = id;
-
-	return (true);
-}
-
-void
-virt_mp_setmaxid(platform_t plat)
-{
-
-	mp_maxid = PCPU_GET(cpuid);
-	mp_ncpus = ofw_cpu_early_foreach(virt_maxid, true);
-	if (mp_ncpus < 1)
-		mp_ncpus = 1;
-	mp_ncpus = MIN(mp_ncpus, MAXCPU);
-}
-
-static boolean_t
 virt_start_ap(u_int id, phandle_t node, u_int addr_cells, pcell_t *reg)
 {
 	int err;

Modified: head/sys/dev/fdt/fdt_arm_platform.c
==============================================================================
--- head/sys/dev/fdt/fdt_arm_platform.c	Fri Mar 17 12:34:57 2017	(r315449)
+++ head/sys/dev/fdt/fdt_arm_platform.c	Fri Mar 17 12:45:53 2017	(r315450)
@@ -30,12 +30,14 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
+#include <sys/smp.h>
 
 #include <arm/include/platform.h>
 #include <arm/include/platformvar.h>
 
 #include <dev/ofw/openfirm.h>
 #include <dev/ofw/ofw_bus_subr.h>
+#include <dev/ofw/ofw_cpu.h>
 #include <dev/fdt/fdt_common.h>
 
 #include "platform_if.h"
@@ -43,6 +45,10 @@ __FBSDID("$FreeBSD$");
 #define	FDT_PLATFORM(plat)	\
     ((fdt_platform_def_t *)(plat)->cls->baseclasses[0])
 
+#if defined(SMP)
+static platform_mp_setmaxid_t fdt_platform_mp_setmaxid;
+#endif
+
 static int
 fdt_platform_probe(platform_t plat)
 {
@@ -66,8 +72,36 @@ fdt_platform_probe(platform_t plat)
 	return 1;
 }
 
+#if defined(SMP)
+static boolean_t
+fdt_platform_maxid(u_int id, phandle_t node, u_int addr_cells, pcell_t *reg)
+{
+
+	if (mp_maxid < id)
+		mp_maxid = id;
+
+	return (true);
+}
+
+static void
+fdt_platform_mp_setmaxid(platform_t plat)
+{
+
+	mp_maxid = PCPU_GET(cpuid);
+	mp_ncpus = ofw_cpu_early_foreach(fdt_platform_maxid, true);
+	if (mp_ncpus < 1)
+		mp_ncpus = 1;
+	mp_ncpus = MIN(mp_ncpus, MAXCPU);
+}
+#endif
+
 platform_method_t fdt_platform_methods[] = {
 	PLATFORMMETHOD(platform_probe,	fdt_platform_probe),
+
+#if defined(SMP)
+	PLATFORMMETHOD(platform_mp_setmaxid, fdt_platform_mp_setmaxid),
+#endif
+
 	PLATFORMMETHOD_END
 };
 



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