Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/sys/arch Pull up the following, requested by msaitoh in t...
details: https://anonhg.NetBSD.org/src/rev/2f6949b51eb6
branches: netbsd-9
changeset: 936017:2f6949b51eb6
user: martin <martin%NetBSD.org@localhost>
date: Wed Jul 15 17:25:08 2020 +0000
description:
Pull up the following, requested by msaitoh in ticket #1015
sys/arch/x86/conf/files.x86 1.108 (via patch)
sys/arch/x86/include/apicvar.h 1.7 (via patch)
sys/arch/x86/include/cpu.h 1.121 (via patch)
sys/arch/x86/x86/cpu.c 1.185 (via patch)
sys/arch/x86/x86/hyperv.c 1.7 (via patch)
sys/arch/x86/x86/tsc.c 1.41 (via patch)
sys/arch/xen/conf/files.xen 1.181 (via patch)
Get TSC frequency from CPUID 0x15 and/or x16 if it's available.
This change fixes a problem that newer Intel processors' timer
counts very slowly.
diffstat:
sys/arch/x86/conf/files.x86 | 3 ++-
sys/arch/x86/include/apicvar.h | 5 ++++-
sys/arch/x86/include/cpu.h | 5 ++++-
sys/arch/x86/x86/cpu.c | 16 ++++++++++++----
sys/arch/x86/x86/hyperv.c | 10 ++++------
sys/arch/x86/x86/tsc.c | 9 +++++++--
sys/arch/xen/conf/files.xen | 3 ++-
7 files changed, 35 insertions(+), 16 deletions(-)
diffs (180 lines):
diff -r d5a13a4d98f6 -r 2f6949b51eb6 sys/arch/x86/conf/files.x86
--- a/sys/arch/x86/conf/files.x86 Wed Jul 15 17:16:59 2020 +0000
+++ b/sys/arch/x86/conf/files.x86 Wed Jul 15 17:25:08 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.x86,v 1.107 2019/02/15 08:54:01 nonaka Exp $
+# $NetBSD: files.x86,v 1.107.4.1 2020/07/15 17:25:08 martin Exp $
# options for MP configuration through the MP spec
defflag opt_mpbios.h MPBIOS MPDEBUG MPBIOS_SCANPCI
@@ -91,6 +91,7 @@
file arch/x86/x86/errata.c machdep
file arch/x86/x86/genfb_machdep.c machdep
file arch/x86/x86/identcpu.c machdep
+file arch/x86/x86/identcpu_subr.c machdep
file arch/x86/x86/i8259.c machdep
file arch/x86/x86/intr.c machdep
file arch/x86/x86/kgdb_machdep.c kgdb
diff -r d5a13a4d98f6 -r 2f6949b51eb6 sys/arch/x86/include/apicvar.h
--- a/sys/arch/x86/include/apicvar.h Wed Jul 15 17:16:59 2020 +0000
+++ b/sys/arch/x86/include/apicvar.h Wed Jul 15 17:25:08 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: apicvar.h,v 1.6 2019/06/14 09:23:42 msaitoh Exp $ */
+/* $NetBSD: apicvar.h,v 1.6.2.1 2020/07/15 17:25:08 martin Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -54,4 +54,7 @@
void apic_format_redir(const char *, const char *, int, int, uint32_t,
uint32_t);
+/* For lapic.c */
+extern uint32_t lapic_per_second;
+
#endif /* !_X86_APICVAR_H_ */
diff -r d5a13a4d98f6 -r 2f6949b51eb6 sys/arch/x86/include/cpu.h
--- a/sys/arch/x86/include/cpu.h Wed Jul 15 17:16:59 2020 +0000
+++ b/sys/arch/x86/include/cpu.h Wed Jul 15 17:25:08 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.107 2019/06/26 12:29:00 mgorny Exp $ */
+/* $NetBSD: cpu.h,v 1.107.2.1 2020/07/15 17:25:08 martin Exp $ */
/*
* Copyright (c) 1990 The Regents of the University of California.
@@ -483,6 +483,9 @@
void cpu_identify(struct cpu_info *);
void identify_hypervisor(void);
+/* identcpu_subr.c */
+uint64_t cpu_tsc_freq_cpuid(struct cpu_info *);
+
typedef enum vm_guest {
VM_GUEST_NO = 0,
VM_GUEST_VM,
diff -r d5a13a4d98f6 -r 2f6949b51eb6 sys/arch/x86/x86/cpu.c
--- a/sys/arch/x86/x86/cpu.c Wed Jul 15 17:16:59 2020 +0000
+++ b/sys/arch/x86/x86/cpu.c Wed Jul 15 17:25:08 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.171.2.1 2020/01/21 11:36:36 martin Exp $ */
+/* $NetBSD: cpu.c,v 1.171.2.2 2020/07/15 17:25:08 martin Exp $ */
/*
* Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.171.2.1 2020/01/21 11:36:36 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.171.2.2 2020/07/15 17:25:08 martin Exp $");
#include "opt_ddb.h"
#include "opt_mpbios.h" /* for MPDEBUG */
@@ -1261,12 +1261,20 @@
return cpu_stop(dv);
}
+/* Get the TSC frequency and set it to ci->ci_data.cpu_cc_freq. */
void
cpu_get_tsc_freq(struct cpu_info *ci)
{
- uint64_t last_tsc;
+ uint64_t freq = 0, last_tsc;
+
+ if (cpu_hascounter())
+ freq = cpu_tsc_freq_cpuid(ci);
- if (cpu_hascounter()) {
+ if (freq != 0) {
+ /* Use TSC frequency taken from CPUID. */
+ ci->ci_data.cpu_cc_freq = freq;
+ } else {
+ /* Calibrate TSC frequency. */
last_tsc = cpu_counter_serializing();
x86_delay(100000);
ci->ci_data.cpu_cc_freq =
diff -r d5a13a4d98f6 -r 2f6949b51eb6 sys/arch/x86/x86/hyperv.c
--- a/sys/arch/x86/x86/hyperv.c Wed Jul 15 17:16:59 2020 +0000
+++ b/sys/arch/x86/x86/hyperv.c Wed Jul 15 17:25:08 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hyperv.c,v 1.4.4.1 2019/12/08 13:09:28 martin Exp $ */
+/* $NetBSD: hyperv.c,v 1.4.4.2 2020/07/15 17:25:08 martin Exp $ */
/*-
* Copyright (c) 2009-2012,2016-2017 Microsoft Corp.
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
#ifdef __KERNEL_RCSID
-__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.4.4.1 2019/12/08 13:09:28 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.4.4.2 2020/07/15 17:25:08 martin Exp $");
#endif
#ifdef __FBSDID
__FBSDID("$FreeBSD: head/sys/dev/hyperv/vmbus/hyperv.c 331757 2018-03-30 02:25:12Z emaste $");
@@ -67,6 +67,7 @@
#include <machine/cputypes.h>
#include <machine/cpuvar.h>
#include <machine/cpu_counter.h>
+#include <x86/apicvar.h>
#include <x86/efi.h>
#include <dev/wsfb/genfbvar.h>
@@ -536,11 +537,8 @@
#if NLAPIC > 0
if ((hyperv_features & CPUID_HV_MSR_TIME_FREQ) &&
- (hyperv_features3 & CPUID3_HV_TIME_FREQ)) {
- extern uint32_t lapic_per_second;
-
+ (hyperv_features3 & CPUID3_HV_TIME_FREQ))
lapic_per_second = rdmsr(MSR_HV_APIC_FREQUENCY);
- }
#endif
return hyperv_init_hypercall();
diff -r d5a13a4d98f6 -r 2f6949b51eb6 sys/arch/x86/x86/tsc.c
--- a/sys/arch/x86/x86/tsc.c Wed Jul 15 17:16:59 2020 +0000
+++ b/sys/arch/x86/x86/tsc.c Wed Jul 15 17:25:08 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tsc.c,v 1.37.8.1 2020/04/14 17:15:02 martin Exp $ */
+/* $NetBSD: tsc.c,v 1.37.8.2 2020/07/15 17:25:08 martin Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.37.8.1 2020/04/14 17:15:02 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.37.8.2 2020/07/15 17:25:08 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -142,6 +142,11 @@
return invariant;
}
+/*
+ * Initialize timecounter(9) of TSC.
+ * This function is called after all secondary processors were up and
+ * calculated the drift.
+ */
void
tsc_tc_init(void)
{
diff -r d5a13a4d98f6 -r 2f6949b51eb6 sys/arch/xen/conf/files.xen
--- a/sys/arch/xen/conf/files.xen Wed Jul 15 17:16:59 2020 +0000
+++ b/sys/arch/xen/conf/files.xen Wed Jul 15 17:25:08 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.xen,v 1.178 2019/02/14 08:18:26 cherry Exp $
+# $NetBSD: files.xen,v 1.178.4.1 2020/07/15 17:25:08 martin Exp $
# NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp
# NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp
@@ -145,6 +145,7 @@
file arch/xen/x86/consinit.c machdep & xenpv
file arch/x86/x86/consinit.c machdep & xenpvhvm
file arch/x86/x86/identcpu.c machdep
+file arch/x86/x86/identcpu_subr.c machdep
file arch/xen/x86/pintr.c machdep & dom0ops & xenpv
file arch/xen/x86/xen_ipi.c multiprocessor & xenpv
file arch/x86/x86/idt.c machdep
Home |
Main Index |
Thread Index |
Old Index