Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86 Use the TSC and current multiplier to calculate...



details:   https://anonhg.NetBSD.org/src/rev/962ea2df7f4d
branches:  trunk
changeset: 747790:962ea2df7f4d
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Fri Oct 02 15:05:42 2009 +0000

description:
Use the TSC and current multiplier to calculate bus clock on VIA C7 Esther.
Probably needed for all C7 and Nano processors, but to be safe only use
this alternate method on Esther for now.

Now est on my C7-M 1.6GHz properly reports frequencies from 1600 to 400,
instead of 2133 to 533.

diffstat:

 sys/arch/x86/include/cpuvar.h     |   3 ++-
 sys/arch/x86/x86/est.c            |  18 +++++++++++++-----
 sys/arch/x86/x86/intel_busclock.c |  19 +++++++++++++++++--
 3 files changed, 32 insertions(+), 8 deletions(-)

diffs (96 lines):

diff -r ee61e30bb847 -r 962ea2df7f4d sys/arch/x86/include/cpuvar.h
--- a/sys/arch/x86/include/cpuvar.h     Fri Oct 02 15:03:45 2009 +0000
+++ b/sys/arch/x86/include/cpuvar.h     Fri Oct 02 15:05:42 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpuvar.h,v 1.29 2009/08/05 20:15:36 jym Exp $ */
+/*     $NetBSD: cpuvar.h,v 1.30 2009/10/02 15:05:42 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
@@ -129,6 +129,7 @@
 #ifdef ENHANCED_SPEEDSTEP
 void   est_init(int);
 int    via_get_bus_clock(struct cpu_info *);
+int    viac7_get_bus_clock(struct cpu_info *);
 int    p3_get_bus_clock(struct cpu_info *);
 int    p4_get_bus_clock(struct cpu_info *);
 #endif
diff -r ee61e30bb847 -r 962ea2df7f4d sys/arch/x86/x86/est.c
--- a/sys/arch/x86/x86/est.c    Fri Oct 02 15:03:45 2009 +0000
+++ b/sys/arch/x86/x86/est.c    Fri Oct 02 15:05:42 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: est.c,v 1.11 2009/03/25 22:53:51 dyoung Exp $  */
+/*     $NetBSD: est.c,v 1.12 2009/10/02 15:05:42 jmcneill Exp $        */
 /*
  * Copyright (c) 2003 Michael Eriksson.
  * All rights reserved.
@@ -81,7 +81,7 @@
 /* #define EST_DEBUG */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: est.c,v 1.11 2009/03/25 22:53:51 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: est.c,v 1.12 2009/10/02 15:05:42 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1089,9 +1089,17 @@
        if (CPUID2FAMILY(curcpu()->ci_signature) == 15)
                bus_clock = p4_get_bus_clock(curcpu());
        else if (CPUID2FAMILY(curcpu()->ci_signature) == 6) {
-               if (vendor == CPUVENDOR_IDT)
-                       bus_clock = via_get_bus_clock(curcpu());
-               else
+               if (vendor == CPUVENDOR_IDT) {
+                       switch (CPUID2MODEL(curcpu()->ci_signature)) {
+                       case 0xa: /* C7 Esther */
+                       case 0xd: /* C7 Esther */
+                               bus_clock = viac7_get_bus_clock(curcpu());
+                               break;
+                       default:
+                               bus_clock = via_get_bus_clock(curcpu());
+                               break;
+                       }
+               } else
                        bus_clock = p3_get_bus_clock(curcpu());
        }
 
diff -r ee61e30bb847 -r 962ea2df7f4d sys/arch/x86/x86/intel_busclock.c
--- a/sys/arch/x86/x86/intel_busclock.c Fri Oct 02 15:03:45 2009 +0000
+++ b/sys/arch/x86/x86/intel_busclock.c Fri Oct 02 15:05:42 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intel_busclock.c,v 1.7 2009/03/25 22:53:51 dyoung Exp $        */
+/*     $NetBSD: intel_busclock.c,v 1.8 2009/10/02 15:05:42 jmcneill Exp $      */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_busclock.c,v 1.7 2009/03/25 22:53:51 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_busclock.c,v 1.8 2009/10/02 15:05:42 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -73,6 +73,21 @@
 }
 
 int
+viac7_get_bus_clock(struct cpu_info *ci)
+{
+       uint64_t msr;
+       int mult;
+
+       msr = rdmsr(MSR_PERF_STATUS);
+       mult = (msr >> 8) & 0xff;
+       if (mult == 0)
+               return 0;
+
+       return ((ci->ci_data.cpu_cc_freq + 10000000) / 10000000 * 10000000) /
+                mult / 10000;
+}
+
+int
 p3_get_bus_clock(struct cpu_info *ci)
 {
        uint64_t msr;



Home | Main Index | Thread Index | Old Index