Skip to contentSkip to conversation

Set CONST_LOOPS flag for P4 with Enhanced Speedstep Technology

PATCH New Venkatesh Pallipadi 1 participant 1 message Dec 30, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Set CONST_LOOPS flag for P4 with Enhanced Speedstep Technology

[CPUFREQ] speedstep-centrino and acpi-cpufreq

In P4, CPU tsc rate won't change with CPU frequency change while using Enhanced Speedstep Technology.
Tested with both speedstep-centrino and acpi-cpufreq on both i386 and x86-64.

arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c renamed from arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c.org +7 -0
@@ -38,6 +38,8 @@
 #include <linux/acpi.h>
 #include <acpi/processor.h>
 
+#include "speedstep-est-common.h"
+
 #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "acpi-cpufreq", msg)
 
 MODULE_AUTHOR("Paul Diefenbaugh, Dominik Brodowski");
@@ -52,6 +54,7 @@ struct cpufreq_acpi_io {
 
 static struct cpufreq_acpi_io	*acpi_io_data[NR_CPUS];
 
+static struct cpufreq_driver acpi_cpufreq_driver;
 
 static int
 acpi_processor_write_port(
@@ -368,6 +371,10 @@ acpi_cpufreq_cpu_init (
 	if (result)
 		goto err_free;
 
+	if (is_const_loops_cpu(cpu)) {
+		acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
+	}
+
 	/* capability check */
 	if (data->acpi_data.state_count <= 1) {
 		dprintk("No P-States\n");
arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c renamed from arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c.org +8 -0
@@ -32,6 +32,8 @@
 #include <asm/processor.h>
 #include <asm/cpufeature.h>
 
+#include "speedstep-est-common.h"
+
 #define PFX		"speedstep-centrino: "
 #define MAINTAINER	"Jeremy Fitzhardinge <[email protected]>"
 
@@ -74,6 +76,8 @@ static int centrino_verify_cpu_id(const 
 static struct cpu_model *centrino_model;
 static const struct cpu_id *centrino_cpu;
 
+static struct cpufreq_driver centrino_driver;
+
 #ifdef CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE
 
 /* Computes the correct form for IA32_PERF_CTL MSR for a particular
@@ -475,6 +479,10 @@ static int centrino_cpu_init(struct cpuf
 	if (i != N_IDS)
 		centrino_cpu = &cpu_ids[i];
 
+	if (is_const_loops_cpu(policy->cpu)) {
+		centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
+	}
+
 	if (centrino_cpu_init_acpi(policy)) {
 		if (policy->cpu != 0)
 			return -ENODEV;
arch/i386/kernel/cpu/cpufreq/speedstep-est-common.h renamed from arch/i386/kernel/cpu/cpufreq/speedstep-est-common.h.org +40 -0
@@ -0,0 +1,40 @@
+/*
+ * Routines common for drivers handling Enhanced Speedstep Technology
+ *  Copyright (C) 2004 Venkatesh Pallipadi <[email protected]>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or (at
+ *  your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+static inline int is_const_loops_cpu(unsigned int cpu)
+{
+	struct cpuinfo_x86 	*c = cpu_data + cpu;
+
+	if (c->x86_vendor != X86_VENDOR_INTEL || !cpu_has(c, X86_FEATURE_EST))
+		return 0;
+
+	/* 
+	 * on P-4s, the TSC runs with constant frequency independent of cpu freq
+	 * when we use EST 
+	 */
+	if (c->x86 == 0xf)
+		return 1;
+
+	return 0;
+}
+