mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] powernow-k8: fix incorrect value reported in cpuinfo_cur_freq
@ 2009-06-11 15:26 Naga Chumbalkar
  2009-06-11 15:26 ` [PATCH 1/2] powernow-k8: read P-state from HW Naga Chumbalkar
  2009-06-11 15:26 ` [PATCH 2/2] powernow-k8: get drv data for correct CPU Naga Chumbalkar
  0 siblings, 2 replies; 3+ messages in thread
From: Naga Chumbalkar @ 2009-06-11 15:26 UTC (permalink / raw)
  To: davej
  Cc: Naga Chumbalkar, andreas.herrmann3, linux-kernel, cpufreq,
	mark.langsdorf, trenn

The "cpuinfo_cur_freq" value reported in /sys is incorrect.

For example, on a 1P quad-core AMD platform (cores: 0,1,2,3) if you want the
"cpuinfo_cur_freq" for core2, you will actually get the value for core0. The
bug is apparent when all the cores are not at the same frequency.

Prior to 2.6.27.8, "cpuinfo_cur_freq" used to return the correct value because
query_current_values_with_pending_wait() obtained the P-state for core2 from
HW, and overwrote the "currpstate" for core0 with it.

However, that got broken with the commit:
a266d9f1253a38ec2d5655ebcd6846298b0554f4

This patch fixes the regression by:
- special-casing the AMD erratum 311 (discussed in the above commit) to AMD
Family 11h processors only
- cleaning up the way powernowk8_get() obtains the per-CPU data

 arch/x86/kernel/cpu/cpufreq/powernow-k8.c |   31 +++++++++++-----------------
 1 files changed, 12 insertions(+), 19 deletions(-)

Thanks,
- naga -



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] powernow-k8: read P-state from HW
  2009-06-11 15:26 [PATCH 0/2] powernow-k8: fix incorrect value reported in cpuinfo_cur_freq Naga Chumbalkar
@ 2009-06-11 15:26 ` Naga Chumbalkar
  2009-06-11 15:26 ` [PATCH 2/2] powernow-k8: get drv data for correct CPU Naga Chumbalkar
  1 sibling, 0 replies; 3+ messages in thread
From: Naga Chumbalkar @ 2009-06-11 15:26 UTC (permalink / raw)
  To: davej
  Cc: Naga Chumbalkar, andreas.herrmann3, linux-kernel, cpufreq,
	mark.langsdorf, trenn


By definition, "cpuinfo_cur_freq" should report the value from HW. So, don't
depend on the cached value. Instead read P-state directly from HW, while
taking into account the erratum 311 workaround for Fam 11h processors.


Cc: Andreas Herrmann <andreas.herrmann3@amd.com>
Cc: Langsdorf, Mark <mark.langsdorf@amd.com>
Cc: Thomas Renninger <trenn@suse.de>

Signed-off-by: Naga Chumbalkar <nagananda.chumbalkar@hp.com>
Reviewed-by: Andreas Herrmann <andreas.herrmann3@amd.com>
Tested-by: Andreas Herrmann <andreas.herrmann3@amd.com>
Acked-by: Langsdorf, Mark <mark.langsdorf@amd.com>
Signed-off-by: Thomas Renninger <trenn@suse.de>

---
 arch/x86/kernel/cpu/cpufreq/powernow-k8.c |   25 +++++++++++--------------
 1 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
index cf52215..700ede9 100644
--- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
@@ -117,20 +117,17 @@ static int query_current_values_with_pending_wait(struct powernow_k8_data *data)
 	u32 i = 0;
 
 	if (cpu_family == CPU_HW_PSTATE) {
-		if (data->currpstate == HW_PSTATE_INVALID) {
-			/* read (initial) hw pstate if not yet set */
-			rdmsr(MSR_PSTATE_STATUS, lo, hi);
-			i = lo & HW_PSTATE_MASK;
-
-			/*
-			 * a workaround for family 11h erratum 311 might cause
-			 * an "out-of-range Pstate if the core is in Pstate-0
-			 */
-			if (i >= data->numps)
-				data->currpstate = HW_PSTATE_0;
-			else
-				data->currpstate = i;
-		}
+		rdmsr(MSR_PSTATE_STATUS, lo, hi);
+		i = lo & HW_PSTATE_MASK;
+		data->currpstate = i;
+
+		/*
+		 * a workaround for family 11h erratum 311 might cause
+		 * an "out-of-range Pstate if the core is in Pstate-0
+		 */
+		if ((boot_cpu_data.x86 == 0x11) && (i >= data->numps))
+			data->currpstate = HW_PSTATE_0;
+
 		return 0;
 	}
 	do {
-- 
1.6.2.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] powernow-k8: get drv data for correct CPU
  2009-06-11 15:26 [PATCH 0/2] powernow-k8: fix incorrect value reported in cpuinfo_cur_freq Naga Chumbalkar
  2009-06-11 15:26 ` [PATCH 1/2] powernow-k8: read P-state from HW Naga Chumbalkar
@ 2009-06-11 15:26 ` Naga Chumbalkar
  1 sibling, 0 replies; 3+ messages in thread
From: Naga Chumbalkar @ 2009-06-11 15:26 UTC (permalink / raw)
  To: davej
  Cc: Naga Chumbalkar, andreas.herrmann3, linux-kernel, cpufreq,
	mark.langsdorf, trenn


Make powernowk8_get() similar to powernowk8_target() and powernowk8_verify()
in the way it obtains "powernow_data" for a given CPU.

Cc: Andreas Herrmann <andreas.herrmann3@amd.com>
Cc: Langsdorf, Mark <mark.langsdorf@amd.com>
Cc: Thomas Renninger <trenn@suse.de>

Signed-off-by: Naga Chumbalkar <nagananda.chumbalkar@hp.com>
Reviewed-by: Andreas Herrmann <andreas.herrmann3@amd.com>
Tested-by: Andreas Herrmann <andreas.herrmann3@amd.com>
Acked-by: Langsdorf, Mark <mark.langsdorf@amd.com>
Signed-off-by: Thomas Renninger <trenn@suse.de>

---
 arch/x86/kernel/cpu/cpufreq/powernow-k8.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
index 700ede9..069c825 100644
--- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
@@ -1371,13 +1371,9 @@ static int __devexit powernowk8_cpu_exit(struct cpufreq_policy *pol)
 
 static unsigned int powernowk8_get(unsigned int cpu)
 {
-	struct powernow_k8_data *data;
+	struct powernow_k8_data *data = per_cpu(powernow_data, cpu);
 	cpumask_t oldmask = current->cpus_allowed;
 	unsigned int khz = 0;
-	unsigned int first;
-
-	first = cpumask_first(cpu_core_mask(cpu));
-	data = per_cpu(powernow_data, first);
 
 	if (!data)
 		return -EINVAL;
-- 
1.6.2.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-06-11 15:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-11 15:26 [PATCH 0/2] powernow-k8: fix incorrect value reported in cpuinfo_cur_freq Naga Chumbalkar
2009-06-11 15:26 ` [PATCH 1/2] powernow-k8: read P-state from HW Naga Chumbalkar
2009-06-11 15:26 ` [PATCH 2/2] powernow-k8: get drv data for correct CPU Naga Chumbalkar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®