Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Move INTEL_ONDEMAND_CLOCKMOD -- or odcm(4) -- to th...



details:   https://anonhg.NetBSD.org/src/rev/92404c85d2a3
branches:  trunk
changeset: 762868:92404c85d2a3
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Fri Mar 04 04:48:39 2011 +0000

description:
Move INTEL_ONDEMAND_CLOCKMOD -- or odcm(4) -- to the cpufeaturebus.

diffstat:

 sys/arch/amd64/conf/GENERIC   |    8 +-
 sys/arch/i386/conf/ALL        |    8 +-
 sys/arch/i386/conf/GENERIC    |    8 +-
 sys/arch/x86/conf/files.x86   |    9 +-
 sys/arch/x86/include/cpuvar.h |   13 +-
 sys/arch/x86/x86/iclockmod.c  |  285 -----------------------------
 sys/arch/x86/x86/identcpu.c   |   11 +-
 sys/arch/x86/x86/odcm.c       |  411 ++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 428 insertions(+), 325 deletions(-)

diffs (truncated from 896 to 300 lines):

diff -r 64ab33ee28cb -r 92404c85d2a3 sys/arch/amd64/conf/GENERIC
--- a/sys/arch/amd64/conf/GENERIC       Fri Mar 04 04:25:58 2011 +0000
+++ b/sys/arch/amd64/conf/GENERIC       Fri Mar 04 04:48:39 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.315 2011/02/27 17:10:33 jruoho Exp $
+# $NetBSD: GENERIC,v 1.316 2011/03/04 04:48:40 jruoho Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.315 $"
+#ident                 "GENERIC-$Revision: 1.316 $"
 
 maxusers       64              # estimated number of users
 
@@ -82,11 +82,9 @@
 #acpicpu*      at cpu?         # ACPI CPU (including frequency scaling)
 coretemp*      at cpu?         # Intel on-die thermal sensor
 est0           at cpu0         # Intel Enhanced SpeedStep (non-ACPI)
+#odcm0         at cpu0         # On-demand clock modulation
 powernow0      at cpu0         # AMD PowerNow! and Cool'n'Quiet (non-ACPI)
 
-# Intel(R) On Demand Clock Modulation (aka ODCM)
-# options       INTEL_ONDEMAND_CLOCKMOD
-
 # Alternate buffer queue strategies for better responsiveness under high
 # disk I/O load.
 #options       BUFQ_READPRIO
diff -r 64ab33ee28cb -r 92404c85d2a3 sys/arch/i386/conf/ALL
--- a/sys/arch/i386/conf/ALL    Fri Mar 04 04:25:58 2011 +0000
+++ b/sys/arch/i386/conf/ALL    Fri Mar 04 04:48:39 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.299 2011/02/27 17:10:33 jruoho Exp $
+# $NetBSD: ALL,v 1.300 2011/03/04 04:48:40 jruoho Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "ALL-$Revision: 1.299 $"
+#ident                 "ALL-$Revision: 1.300 $"
 
 maxusers       64              # estimated number of users
 
@@ -33,13 +33,11 @@
 acpicpu*       at cpu?         # ACPI CPU (including frequency scaling)
 coretemp*      at cpu?         # Intel on-die thermal sensor
 est0           at cpu0         # Intel Enhanced SpeedStep (non-ACPI)
+odcm0          at cpu0         # On-demand clock modulation
 padlock0       at cpu0         # VIA PadLock
 powernow0      at cpu0         # AMD PowerNow! and Cool'n'Quiet (non-ACPI)
 viac7temp*     at cpu?         # VIA C7 temperature sensor
 
-# Intel(R) On Demand Clock Modulation (aka ODCM)
-options        INTEL_ONDEMAND_CLOCKMOD
-
 # XBOX support
 options        XBOX
 
diff -r 64ab33ee28cb -r 92404c85d2a3 sys/arch/i386/conf/GENERIC
--- a/sys/arch/i386/conf/GENERIC        Fri Mar 04 04:25:58 2011 +0000
+++ b/sys/arch/i386/conf/GENERIC        Fri Mar 04 04:48:39 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.1024 2011/02/27 17:10:34 jruoho Exp $
+# $NetBSD: GENERIC,v 1.1025 2011/03/04 04:48:40 jruoho Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.1024 $"
+#ident                 "GENERIC-$Revision: 1.1025 $"
 
 maxusers       64              # estimated number of users
 
@@ -41,13 +41,11 @@
 #acpicpu*      at cpu?         # ACPI CPU (including frequency scaling)
 coretemp*      at cpu?         # Intel on-die thermal sensor
 est0           at cpu0         # Intel Enhanced SpeedStep (non-ACPI)
+#odcm0         at cpu0         # On-demand clock modulation
 #padlock0      at cpu0         # VIA PadLock
 powernow0      at cpu0         # AMD PowerNow! and Cool'n'Quiet (non-ACPI)
 viac7temp*     at cpu?         # VIA C7 temperature sensor
 
-# Intel(R) On Demand Clock Modulation (aka ODCM)
-#options       INTEL_ONDEMAND_CLOCKMOD
-
 options        MTRR            # memory-type range register syscall support
 # doesn't work with MP just yet..
 #options       PERFCTRS        # performance-monitoring counters support
diff -r 64ab33ee28cb -r 92404c85d2a3 sys/arch/x86/conf/files.x86
--- a/sys/arch/x86/conf/files.x86       Fri Mar 04 04:25:58 2011 +0000
+++ b/sys/arch/x86/conf/files.x86       Fri Mar 04 04:48:39 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.x86,v 1.63 2011/02/27 17:10:33 jruoho Exp $
+#      $NetBSD: files.x86,v 1.64 2011/03/04 04:48:40 jruoho Exp $
 
 # options for MP configuration through the MP spec
 defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
@@ -13,9 +13,6 @@
 defflag opt_pcifixup.h PCI_ADDR_FIXUP PCI_BUS_FIXUP
                        PCI_INTR_FIXUP PCI_INTR_FIXUP_FORCE
 
-# Pentium 4+ Thermal Monitor ODCM (aka On Demand Clock Modulation)
-defflag opt_intel_odcm.h       INTEL_ONDEMAND_CLOCKMOD
-
 # To be able to test for NetBSD/xen in shared files
 defflag        opt_xen.h               DO_NOT_DEFINE
 
@@ -48,6 +45,10 @@
 file   arch/x86/x86/est.c              est
 file   arch/x86/x86/intel_busclock.c   est
 
+device odcm
+attach odcm at cpufeaturebus
+file   arch/x86/x86/odcm.c             odcm
+
 device padlock: opencrypto
 attach padlock at cpufeaturebus
 file   arch/x86/x86/via_padlock.c      padlock
diff -r 64ab33ee28cb -r 92404c85d2a3 sys/arch/x86/include/cpuvar.h
--- a/sys/arch/x86/include/cpuvar.h     Fri Mar 04 04:25:58 2011 +0000
+++ b/sys/arch/x86/include/cpuvar.h     Fri Mar 04 04:48:39 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpuvar.h,v 1.42 2011/02/24 15:42:17 jruoho Exp $ */
+/*     $NetBSD: cpuvar.h,v 1.43 2011/03/04 04:48:40 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
@@ -94,9 +94,6 @@
 
 #if defined(_KERNEL_OPT)
 #include "opt_multiprocessor.h"
-#ifndef XEN
-#include "opt_intel_odcm.h"
-#endif
 #endif /* defined(_KERNEL_OPT) */
 
 #ifdef MULTIPROCESSOR
@@ -122,14 +119,6 @@
 void x86_cpu_idle_xen(void);
 #endif
 
-#ifdef VIA_C7TEMP
-void viac7temp_register(struct cpu_info *);
-#endif
-
-#ifdef INTEL_ONDEMAND_CLOCKMOD
-void clockmod_init(void);
-#endif
-
 void   cpu_get_tsc_freq(struct cpu_info *);
 void   pat_init(struct cpu_info *);
 
diff -r 64ab33ee28cb -r 92404c85d2a3 sys/arch/x86/x86/iclockmod.c
--- a/sys/arch/x86/x86/iclockmod.c      Fri Mar 04 04:25:58 2011 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,285 +0,0 @@
-/*     $NetBSD: iclockmod.c,v 1.13 2009/10/05 23:59:31 rmind Exp $ */
-/*      $OpenBSD: p4tcc.c,v 1.13 2006/12/20 17:50:40 gwk Exp $ */
-
-/*
- * Copyright (c) 2007 Juan Romero Pardines
- * Copyright (c) 2003 Ted Unangst
- * 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 ``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 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.
- */
-
-/*
- * On-Demand Clock Modulation driver, to modulate the clock duty cycle
- * by software. Available on Pentium M and later models (feature TM).
- *
- * References:
- * Intel Developer's manual v.3 #245472-012
- *
- * On some models, the cpu can hang if it's running at a slow speed.
- * Workarounds included below.
- */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: iclockmod.c,v 1.13 2009/10/05 23:59:31 rmind Exp $");
-
-#include "opt_intel_odcm.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/sysctl.h>
-#include <sys/once.h>
-#include <sys/xcall.h>
-
-#include <machine/cpu.h>
-#include <machine/cpuvar.h>
-#include <machine/specialreg.h>
-
-#include <x86/cpu_msr.h>
-
-#define ODCM_ENABLE            (1 << 4) /* Enable bit 4 */
-#define ODCM_REGOFFSET         1
-#define ODCM_MAXSTATES         8
-
-static int clockmod_level;
-static int clockmod_state_target;
-static int clockmod_state_current;
-
-static struct {
-       int level;
-       int reg;
-       int errata;
-} state[] = {
-       { .level = 7, .reg = 0, .errata = 0 },
-       { .level = 6, .reg = 7, .errata = 0 },
-       { .level = 5, .reg = 6, .errata = 0 },
-       { .level = 4, .reg = 5, .errata = 0 },
-       { .level = 3, .reg = 4, .errata = 0 },
-       { .level = 2, .reg = 3, .errata = 0 },
-       { .level = 1, .reg = 2, .errata = 0 },
-       { .level = 0, .reg = 1, .errata = 0 }
-};
-
-static int     clockmod_getstate(void);
-static void    clockmod_setstate(int);
-static int     clockmod_sysctl_helper(SYSCTLFN_PROTO);
-static void    clockmod_init_main(void);
-static int     clockmod_init_once(void);
-
-static int
-clockmod_getstate(void)
-{
-       uint64_t msr;
-       int i, val = -1;
-
-       msr = rdmsr(MSR_THERM_CONTROL);
-       if ((msr & ODCM_ENABLE) == 0)
-               return (ODCM_MAXSTATES - 1);
-
-       msr = (msr >> ODCM_REGOFFSET) & (ODCM_MAXSTATES - 1);
-
-       for (i = 0; i < __arraycount(state); i++) {
-               if (msr == state[i].reg) {
-                       val = state[i].level;
-                       break;
-               }
-       }
-       KASSERT(val != -1);
-       return val;
-}
-
-static void
-clockmod_setstate(int level)
-{
-       struct msr_rw_info msr;
-       uint64_t where;
-       int i;
-
-       for (i = 0; i < __arraycount(state); i++) {
-               if (level == state[i].level && !state[i].errata)
-                       break;
-       }
-       KASSERT(i != __arraycount(state));
-
-       msr.msr_read = true;
-       msr.msr_type = MSR_THERM_CONTROL;
-       msr.msr_mask = 0x1e;
-
-       if (state[i].reg != 0)  /* bit 0 reserved */
-               msr.msr_value = (state[i].reg << ODCM_REGOFFSET) | ODCM_ENABLE;
-       else
-               msr.msr_value = 0; /* max state */
-
-       where = xc_broadcast(0, (xcfunc_t)x86_msr_xcall, &msr, NULL);
-       xc_wait(where);
-}



Home | Main Index | Thread Index | Old Index