Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 493

kernel-2.6.18-238.el5.src.rpm

From: Bhavna Sarathy <bnagendr@redhat.com>
Date: Fri, 13 Aug 2010 16:27:08 -0400
Subject: [cpufreq] powernow-k8: fix per core frequency control
Message-id: <20100813163255.16892.24230.sendpatchset@localhost.localdomain>
Patchwork-id: 27626
O-Subject: [RHEL5.6 PATCH] Fix per core frequency control in powernow-k8 driver
Bugzilla: 502397
RH-Acked-by: Jarod Wilson <jarod@redhat.com>

Resolves BZ 502397

Newer AMD CPUs including newer Opterons, the Phenoms and Phenoms II (and Kuma
core Athlons X2) support per-core power control, so one core can run at max
speed, and three others run idle, reducing power consumption and dissipated
heat amount.

Alas, the RHEL kernel powernow-k8 driver do not support per core control. It
always ties all the cores together.
"/sys/devices/system/cpu/cpu0/cpufreq/affected_cpus" keeps getting "0 1 2 3" in
it on 4 core CPU, and all cores share the same power state.

This patch provides the ability to control power per core, and fixes a
customer reported issue.  Tested and verifed by reporter on BZ.

The per core frequency control feature has existed in mainline 2.6.18
kernel.

Please review and ACK.

Signed-off-by: Jarod Wilson <jarod@redhat.com>

diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
index 16344b7..97fd19b 100644
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
@@ -1,5 +1,5 @@
 /*
- *   (c) 2003-2006 Advanced Micro Devices, Inc.
+ *   (c) 2003-2010 Advanced Micro Devices, Inc.
  *  Your use of this code is subject to the terms and conditions of the
  *  GNU general public license version 2. See "COPYING" or
  *  http://www.gnu.org/licenses/gpl.html
@@ -786,7 +786,6 @@ static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned
 }
 
 static struct acpi_processor_performance *acpi_perf_data[NR_CPUS];
-static int preregister_valid = 0;
 
 static int powernow_k8_cpu_preinit_acpi(void)
 {
@@ -809,8 +808,6 @@ static int powernow_k8_cpu_preinit_acpi(void)
 	if (preregister_acpi_perf != 0) {
 		if (acpi_processor_preregister_performance(acpi_perf_data))
 			return -ENODEV;
-		else
-			preregister_valid = 1;
 	} else {
 		printk(KERN_INFO "powernow-k8: Disabling ACPI "
 		       "pre-initialization.\n");
@@ -871,20 +868,11 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)
 	/* notify BIOS that we exist */
 	acpi_processor_notify_smm(THIS_MODULE);
 
-	/* determine affinity, from ACPI if available */
-	if (preregister_valid) {
-		if ((data->acpi_data->shared_type == CPUFREQ_SHARED_TYPE_ALL) ||
-		    (data->acpi_data->shared_type == CPUFREQ_SHARED_TYPE_ANY))
-			data->starting_core_affinity = data->acpi_data->shared_cpu_map;
-		else
-			data->starting_core_affinity = cpumask_of_cpu(data->cpu);
-	} else {
-		/* best guess from family if not */
-		if (cpu_family == CPU_HW_PSTATE)
-			data->starting_core_affinity = cpumask_of_cpu(data->cpu);
-		else
-			data->starting_core_affinity = cpu_core_map[data->cpu];
-	}
+	/* determine affinity */
+	if (cpu_family == CPU_HW_PSTATE)
+		data->starting_core_affinity = cpumask_of_cpu(data->cpu);
+	else
+		data->starting_core_affinity = cpu_core_map[data->cpu];
 
 	return 0;