Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src/sys/arch Pull up the following revisions, requested by ms...



details:   https://anonhg.NetBSD.org/src/rev/d5879bb7a174
branches:  netbsd-8
changeset: 936824:d5879bb7a174
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Aug 05 16:20:08 2020 +0000

description:
Pull up the following revisions, requested by msaitoh in ticket #1593:

        sys/arch/x86/conf/files.x86                     1.108
        sys/arch/x86/include/apicvar.h                  1.7 via patch
        sys/arch/x86/include/cpu.h                      1.121
        sys/arch/x86/x86/cpu.c                          1.185 via patch
        sys/arch/x86/x86/hyperv.c                       1.7
        sys/arch/x86/x86/tsc.c                          1.41
        sys/arch/xen/conf/files.xen                     1.181

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         |  23 ++++++++++++++++-------
 sys/arch/x86/x86/hyperv.c      |  10 ++++------
 sys/arch/x86/x86/tsc.c         |   9 +++++++--
 sys/arch/xen/conf/files.xen    |   3 ++-
 7 files changed, 39 insertions(+), 19 deletions(-)

diffs (188 lines):

diff -r 87d1502aed8f -r d5879bb7a174 sys/arch/x86/conf/files.x86
--- a/sys/arch/x86/conf/files.x86       Wed Aug 05 16:14:25 2020 +0000
+++ b/sys/arch/x86/conf/files.x86       Wed Aug 05 16:20:08 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.x86,v 1.88.6.2 2019/03/09 17:10:20 martin Exp $
+#      $NetBSD: files.x86,v 1.88.6.3 2020/08/05 16:20:08 martin Exp $
 
 # options for MP configuration through the MP spec
 defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
@@ -84,6 +84,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/nmi.c              machdep
diff -r 87d1502aed8f -r d5879bb7a174 sys/arch/x86/include/apicvar.h
--- a/sys/arch/x86/include/apicvar.h    Wed Aug 05 16:14:25 2020 +0000
+++ b/sys/arch/x86/include/apicvar.h    Wed Aug 05 16:20:08 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apicvar.h,v 1.5 2008/04/28 20:23:40 martin Exp $ */
+/*     $NetBSD: apicvar.h,v 1.5.80.1 2020/08/05 16:20:08 martin Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -46,4 +46,7 @@
 
 void apic_format_redir(const char *, const char *, int, u_int32_t, u_int32_t);
 
+/* For lapic.c */
+extern uint32_t lapic_per_second;
+
 #endif /* !_X86_APICVAR_H_ */
diff -r 87d1502aed8f -r d5879bb7a174 sys/arch/x86/include/cpu.h
--- a/sys/arch/x86/include/cpu.h        Wed Aug 05 16:14:25 2020 +0000
+++ b/sys/arch/x86/include/cpu.h        Wed Aug 05 16:20:08 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.71.2.8 2019/03/09 17:10:20 martin Exp $      */
+/*     $NetBSD: cpu.h,v 1.71.2.9 2020/08/05 16:20:08 martin Exp $      */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -451,6 +451,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 87d1502aed8f -r d5879bb7a174 sys/arch/x86/x86/cpu.c
--- a/sys/arch/x86/x86/cpu.c    Wed Aug 05 16:14:25 2020 +0000
+++ b/sys/arch/x86/x86/cpu.c    Wed Aug 05 16:20:08 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.130.2.9 2020/01/21 16:47:24 martin Exp $     */
+/*     $NetBSD: cpu.c,v 1.130.2.10 2020/08/05 16:20: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.130.2.9 2020/01/21 16:47:24 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.130.2.10 2020/08/05 16:20:08 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"                /* for MPDEBUG */
@@ -1226,16 +1226,25 @@
        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()) {
-               last_tsc = cpu_counter_serializing();
-               x86_delay(100000);
-               ci->ci_data.cpu_cc_freq =
-                   (cpu_counter_serializing() - last_tsc) * 10;
+               freq = cpu_tsc_freq_cpuid(ci);
+
+               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 =
+                           (cpu_counter_serializing() - last_tsc) * 10;
+               }
        }
 }
 
diff -r 87d1502aed8f -r d5879bb7a174 sys/arch/x86/x86/hyperv.c
--- a/sys/arch/x86/x86/hyperv.c Wed Aug 05 16:14:25 2020 +0000
+++ b/sys/arch/x86/x86/hyperv.c Wed Aug 05 16:20:08 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hyperv.c,v 1.1.2.4 2019/12/05 16:54:59 bouyer Exp $    */
+/*     $NetBSD: hyperv.c,v 1.1.2.5 2020/08/05 16:20: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.1.2.4 2019/12/05 16:54:59 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.1.2.5 2020/08/05 16:20: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 87d1502aed8f -r d5879bb7a174 sys/arch/x86/x86/tsc.c
--- a/sys/arch/x86/x86/tsc.c    Wed Aug 05 16:14:25 2020 +0000
+++ b/sys/arch/x86/x86/tsc.c    Wed Aug 05 16:20:08 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tsc.c,v 1.36.22.1 2020/04/15 14:25:09 martin Exp $     */
+/*     $NetBSD: tsc.c,v 1.36.22.2 2020/08/05 16:20: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.36.22.1 2020/04/15 14:25:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.36.22.2 2020/08/05 16:20:08 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -139,6 +139,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 87d1502aed8f -r d5879bb7a174 sys/arch/xen/conf/files.xen
--- a/sys/arch/xen/conf/files.xen       Wed Aug 05 16:14:25 2020 +0000
+++ b/sys/arch/xen/conf/files.xen       Wed Aug 05 16:20:08 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.xen,v 1.147.2.3 2019/09/23 13:51:12 martin Exp $
+#      $NetBSD: files.xen,v 1.147.2.4 2020/08/05 16:20: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 
 
@@ -136,6 +136,7 @@
 file   arch/x86/x86/bus_space.c        machdep
 file   arch/xen/x86/consinit.c         machdep
 file   arch/x86/x86/identcpu.c         machdep
+file   arch/x86/x86/identcpu_subr.c    machdep
 file   arch/xen/x86/intr.c             machdep
 file   arch/xen/x86/xen_ipi.c          multiprocessor
 file   arch/x86/x86/pmap.c             machdep



Home | Main Index | Thread Index | Old Index