Module Name: src
Committed By: snj
Date: Tue Jun 16 02:19:44 UTC 2009
Modified Files:
src/sys/arch/x86/conf [netbsd-5]: files.x86
src/sys/arch/x86/include [netbsd-5]: cpu.h
src/sys/arch/x86/x86 [netbsd-5]: identcpu.c
Added Files:
src/sys/arch/x86/x86 [netbsd-5]: cpu_topology.c
Log Message:
Pull up following revision(s) (requested by rmind in ticket #782):
sys/arch/x86/conf/files.x86: revision 1.52 via patch
sys/arch/x86/include/cpu.h: revision 1.17
sys/arch/x86/x86/cpu_topology.c: revision 1.1
sys/arch/x86/x86/identcpu.c: revision 1.16 via patch
Move x86 CPU topology detection code into the separate file (as it was
originally).
OK by <yamt>.
To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.4.1 src/sys/arch/x86/conf/files.x86
cvs rdiff -u -r1.9 -r1.9.4.1 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r0 -r1.2.2.2 src/sys/arch/x86/x86/cpu_topology.c
cvs rdiff -u -r1.10.4.2 -r1.10.4.3 src/sys/arch/x86/x86/identcpu.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/x86/conf/files.x86
diff -u src/sys/arch/x86/conf/files.x86:1.44 src/sys/arch/x86/conf/files.x86:1.44.4.1
--- src/sys/arch/x86/conf/files.x86:1.44 Sun Aug 3 19:32:03 2008
+++ src/sys/arch/x86/conf/files.x86 Tue Jun 16 02:19:44 2009
@@ -1,4 +1,4 @@
-# $NetBSD: files.x86,v 1.44 2008/08/03 19:32:03 joerg Exp $
+# $NetBSD: files.x86,v 1.44.4.1 2009/06/16 02:19:44 snj Exp $
# options for MP configuration through the MP spec
defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
@@ -45,6 +45,7 @@
file arch/x86/x86/bus_dma.c
file arch/x86/x86/bus_space.c
file arch/x86/x86/consinit.c
+file arch/x86/x86/cpu_topology.c
file arch/x86/x86/errata.c
file arch/x86/x86/identcpu.c
file arch/x86/x86/i8259.c
Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.9 src/sys/arch/x86/include/cpu.h:1.9.4.1
--- src/sys/arch/x86/include/cpu.h:1.9 Sat Oct 25 19:13:40 2008
+++ src/sys/arch/x86/include/cpu.h Tue Jun 16 02:19:44 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.9 2008/10/25 19:13:40 mrg Exp $ */
+/* $NetBSD: cpu.h,v 1.9.4.1 2009/06/16 02:19:44 snj Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -337,6 +337,9 @@
void cpu_probe(struct cpu_info *);
void cpu_identify(struct cpu_info *);
+/* cpu_topology.c */
+void x86_cpu_toplogy(struct cpu_info *);
+
/* vm_machdep.c */
void cpu_proc_fork(struct proc *, struct proc *);
Index: src/sys/arch/x86/x86/identcpu.c
diff -u src/sys/arch/x86/x86/identcpu.c:1.10.4.2 src/sys/arch/x86/x86/identcpu.c:1.10.4.3
--- src/sys/arch/x86/x86/identcpu.c:1.10.4.2 Mon Feb 2 18:50:01 2009
+++ src/sys/arch/x86/x86/identcpu.c Tue Jun 16 02:19:44 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: identcpu.c,v 1.10.4.2 2009/02/02 18:50:01 snj Exp $ */
+/* $NetBSD: identcpu.c,v 1.10.4.3 2009/06/16 02:19:44 snj Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -29,34 +29,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-/*-
- * Copyright (c)2008 YAMAMOTO Takashi,
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.10.4.2 2009/02/02 18:50:01 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.10.4.3 2009/06/16 02:19:44 snj Exp $");
#include "opt_enhanced_speedstep.h"
#include "opt_intel_odcm.h"
@@ -70,7 +44,6 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
-#include <sys/bitops.h>
#include <uvm/uvm_extern.h>
@@ -132,56 +105,6 @@
}
static void
-cpu_probe_p6(struct cpu_info *ci)
-{
- u_int lp_max = 1; /* logical processors per package */
- u_int smt_max; /* smt per core */
- u_int core_max = 1; /* core per package */
- int smt_bits, core_bits;
- uint32_t descs[4];
-
- if (cpu_vendor != CPUVENDOR_INTEL ||
- CPUID2FAMILY(ci->ci_signature) < 6)
- return;
-
- /* Determine the extended feature flags. */
- x86_cpuid(0x80000000, descs);
- if (descs[0] >= 0x80000001) {
- x86_cpuid(0x80000001, descs);
- ci->ci_feature3_flags |= descs[3]; /* %edx */
- }
-
- /* Determine topology. 253668.pdf 7.10.2. */
- ci->ci_packageid = ci->ci_initapicid;
- ci->ci_coreid = 0;
- ci->ci_smtid = 0;
- if ((ci->ci_feature_flags & CPUID_HTT) != 0) {
- x86_cpuid(1, descs);
- lp_max = (descs[1] >> 16) & 0xff;
- }
- x86_cpuid(0, descs);
- if (descs[0] >= 4) {
- x86_cpuid2(4, 0, descs);
- core_max = (descs[0] >> 26) + 1;
- }
- KASSERT(lp_max >= core_max);
- smt_max = lp_max / core_max;
- smt_bits = ilog2(smt_max - 1) + 1;
- core_bits = ilog2(core_max - 1) + 1;
- if (smt_bits + core_bits) {
- ci->ci_packageid = ci->ci_initapicid >> (smt_bits + core_bits);
- }
- if (core_bits) {
- u_int core_mask = __BITS(smt_bits, smt_bits + core_bits - 1);
- ci->ci_coreid = __SHIFTOUT(ci->ci_initapicid, core_mask);
- }
- if (smt_bits) {
- u_int smt_mask = __BITS(0, smt_bits - 1);
- ci->ci_smtid = __SHIFTOUT(ci->ci_initapicid, smt_mask);
- }
-}
-
-static void
cpu_probe_amd_cache(struct cpu_info *ci)
{
const struct x86_cache_info *cp;
@@ -684,7 +607,6 @@
}
}
- cpu_probe_p6(ci);
cpu_probe_k5(ci);
cpu_probe_k678(ci);
cpu_probe_cyrix(ci);
@@ -692,6 +614,8 @@
cpu_probe_c3(ci);
cpu_probe_geode(ci);
+ x86_cpu_toplogy(ci);
+
if (cpu_vendor != CPUVENDOR_AMD && (ci->ci_feature_flags & CPUID_TM) &&
(rdmsr(MSR_MISC_ENABLE) & (1 << 3)) == 0) {
/* Enable thermal monitor 1. */
Added files:
Index: src/sys/arch/x86/x86/cpu_topology.c
diff -u /dev/null src/sys/arch/x86/x86/cpu_topology.c:1.2.2.2
--- /dev/null Tue Jun 16 02:19:44 2009
+++ src/sys/arch/x86/x86/cpu_topology.c Tue Jun 16 02:19:44 2009
@@ -0,0 +1,90 @@
+/* $NetBSD: cpu_topology.c,v 1.2.2.2 2009/06/16 02:19:44 snj Exp $ */
+
+/*-
+ * Copyright (c)2008 YAMAMOTO Takashi,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.2.2.2 2009/06/16 02:19:44 snj Exp $");
+
+#include <sys/param.h>
+#include <sys/bitops.h>
+
+#include <machine/specialreg.h>
+#include <machine/cpu.h>
+
+#include <x86/cpufunc.h>
+#include <x86/cputypes.h>
+#include <x86/cpuvar.h>
+
+void
+x86_cpu_toplogy(struct cpu_info *ci)
+{
+ u_int lp_max = 1; /* logical processors per package */
+ u_int smt_max; /* smt per core */
+ u_int core_max = 1; /* core per package */
+ int smt_bits, core_bits;
+ uint32_t descs[4];
+
+ if (cpu_vendor != CPUVENDOR_INTEL ||
+ CPUID2FAMILY(ci->ci_signature) < 6)
+ return;
+
+ /* Determine the extended feature flags. */
+ x86_cpuid(0x80000000, descs);
+ if (descs[0] >= 0x80000001) {
+ x86_cpuid(0x80000001, descs);
+ ci->ci_feature3_flags |= descs[3]; /* %edx */
+ }
+
+ /* Determine topology. 253668.pdf 7.10.2. */
+ ci->ci_packageid = ci->ci_initapicid;
+ ci->ci_coreid = 0;
+ ci->ci_smtid = 0;
+ if ((ci->ci_feature_flags & CPUID_HTT) != 0) {
+ x86_cpuid(1, descs);
+ lp_max = (descs[1] >> 16) & 0xff;
+ }
+ x86_cpuid(0, descs);
+ if (descs[0] >= 4) {
+ x86_cpuid2(4, 0, descs);
+ core_max = (descs[0] >> 26) + 1;
+ }
+ KASSERT(lp_max >= core_max);
+ smt_max = lp_max / core_max;
+ smt_bits = ilog2(smt_max - 1) + 1;
+ core_bits = ilog2(core_max - 1) + 1;
+ if (smt_bits + core_bits) {
+ ci->ci_packageid = ci->ci_initapicid >> (smt_bits + core_bits);
+ }
+ if (core_bits) {
+ u_int core_mask = __BITS(smt_bits, smt_bits + core_bits - 1);
+ ci->ci_coreid = __SHIFTOUT(ci->ci_initapicid, core_mask);
+ }
+ if (smt_bits) {
+ u_int smt_mask = __BITS(0, smt_bits - 1);
+ ci->ci_smtid = __SHIFTOUT(ci->ci_initapicid, smt_mask);
+ }
+}