summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2012-03-27 06:44:02 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2012-03-27 06:44:02 +0000
commitb74f031094ba7c74fef80101c104faa1c33cdefd (patch)
tree12e1d75ed3ef8ff9aafae5e6284332886b4adf02 /sys
parent788d032942801f767dfd403d9165cd3f3f3f62ea (diff)
Make the bus_clock calculations happen later in the boot process so
they can be conditionally called in future. This makes the i386 speedstep code closer to the amd64 code (though still with the added complications of VIA support and the *_update_cpuspeed callbacks)
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/i386/i386/est.c16
-rw-r--r--sys/arch/i386/i386/machdep.c24
-rw-r--r--sys/arch/i386/include/cpu.h4
3 files changed, 27 insertions, 17 deletions
diff --git a/sys/arch/i386/i386/est.c b/sys/arch/i386/i386/est.c
index a86d1247ecd..fd6cd4a4121 100644
--- a/sys/arch/i386/i386/est.c
+++ b/sys/arch/i386/i386/est.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: est.c,v 1.37 2011/05/13 11:30:26 jasper Exp $ */
+/* $OpenBSD: est.c,v 1.38 2012/03/27 06:44:01 jsg Exp $ */
/*
* Copyright (c) 2003 Michael Eriksson.
* All rights reserved.
@@ -960,6 +960,10 @@ static struct fqlist *est_fqlist;
extern int setperf_prio;
extern int perflevel;
+void p4_get_bus_clock(struct cpu_info *);
+void p3_get_bus_clock(struct cpu_info *);
+void cyrix3_get_bus_clock(struct cpu_info *);
+
#if NACPICPU > 0
struct fqlist * est_acpi_init(void);
void est_acpi_pss_changed(struct acpicpu_pss *, int);
@@ -1044,8 +1048,9 @@ est_acpi_pss_changed(struct acpicpu_pss *pss, int npss)
#endif
void
-est_init(const char *cpu_device, int vendor)
+est_init(struct cpu_info *ci, int vendor)
{
+ const char *cpu_device = ci->ci_dev.dv_xname;
int i, low, high;
u_int64_t msr;
u_int16_t idhi, idlo, cur;
@@ -1072,6 +1077,13 @@ est_init(const char *cpu_device, int vendor)
est_fqlist = est_acpi_init();
#endif
+ if (vendor == CPUVENDOR_VIA)
+ cyrix3_get_bus_clock(ci);
+ else if (ci->ci_family == 0xf)
+ p4_get_bus_clock(ci);
+ else if (ci->ci_family == 6)
+ p3_get_bus_clock(ci);
+
/*
* Interpreting the values of PERF_STATUS is not valid
* on recent processors so don't do it on anything unknown
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 4dba2b20078..4495a83e55d 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.508 2012/03/23 15:51:25 guenther Exp $ */
+/* $OpenBSD: machdep.c,v 1.509 2012/03/27 06:44:01 jsg Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -1053,7 +1053,7 @@ cyrix3_setperf_setup(struct cpu_info *ci)
{
if (cpu_ecxfeature & CPUIDECX_EST) {
if (rdmsr(MSR_MISC_ENABLE) & (1 << 16))
- est_init(ci->ci_dev.dv_xname, CPUVENDOR_VIA);
+ est_init(ci, CPUVENDOR_VIA);
else
printf("%s: Enhanced SpeedStep disabled by BIOS\n",
ci->ci_dev.dv_xname);
@@ -1076,8 +1076,6 @@ cyrix3_cpu_setup(struct cpu_info *ci)
pagezero = i686_pagezero;
- cyrix3_get_bus_clock(ci);
-
setperf_setup = cyrix3_setperf_setup;
#endif
@@ -1443,7 +1441,7 @@ intel686_setperf_setup(struct cpu_info *ci)
if (cpu_ecxfeature & CPUIDECX_EST) {
if (rdmsr(MSR_MISC_ENABLE) & (1 << 16))
- est_init(ci->ci_dev.dv_xname, CPUVENDOR_INTEL);
+ est_init(ci, CPUVENDOR_INTEL);
else
printf("%s: Enhanced SpeedStep disabled by BIOS\n",
ci->ci_dev.dv_xname);
@@ -1485,10 +1483,6 @@ intel686_cpu_setup(struct cpu_info *ci)
int step = ci->ci_signature & 15;
u_quad_t msr119;
-#if !defined(SMALL_KERNEL)
- p3_get_bus_clock(ci);
-#endif
-
intel686_common_cpu_setup(ci);
/*
@@ -1521,10 +1515,6 @@ intel686_cpu_setup(struct cpu_info *ci)
void
intel686_p4_cpu_setup(struct cpu_info *ci)
{
-#if !defined(SMALL_KERNEL)
- p4_get_bus_clock(ci);
-#endif
-
intel686_common_cpu_setup(ci);
#if !defined(SMALL_KERNEL)
@@ -2156,9 +2146,13 @@ print_msr:
void
p4_update_cpuspeed(void)
{
+ struct cpu_info *ci;
u_int64_t msr;
int mult;
+ ci = curcpu();
+ p4_get_bus_clock(ci);
+
if (bus_clock == 0) {
printf("p4_update_cpuspeed: unknown bus clock\n");
return;
@@ -2173,11 +2167,15 @@ p4_update_cpuspeed(void)
void
p3_update_cpuspeed(void)
{
+ struct cpu_info *ci;
u_int64_t msr;
int mult;
const u_int8_t mult_code[] = {
50, 30, 40, 0, 55, 35, 45, 0, 0, 70, 80, 60, 0, 75, 0, 65 };
+ ci = curcpu();
+ p3_get_bus_clock(ci);
+
if (bus_clock == 0) {
printf("p3_update_cpuspeed: unknown bus clock\n");
return;
diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h
index 81eb8ab03da..348031f950f 100644
--- a/sys/arch/i386/include/cpu.h
+++ b/sys/arch/i386/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.121 2011/11/02 23:53:44 jsg Exp $ */
+/* $OpenBSD: cpu.h,v 1.122 2012/03/27 06:44:01 jsg Exp $ */
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
/*-
@@ -388,7 +388,7 @@ void i8254_inittimecounter_simple(void);
#if !defined(SMALL_KERNEL)
/* est.c */
-void est_init(const char *, int);
+void est_init(struct cpu_info *, int);
void est_setperf(int);
/* longrun.c */
void longrun_init(void);