linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] powernow-k8: Misc fixes
@ 2012-01-06 14:55 Andreas Herrmann
  2012-01-06 14:56 ` [PATCH 1/3] powernow-k8: Avoid Pstate MSR accesses on systems supporting CPB Andreas Herrmann
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andreas Herrmann @ 2012-01-06 14:55 UTC (permalink / raw)
  To: Dave Jones; +Cc: cpufreq, linux-kernel

Hi Dave,

Following two fixes are required on systems where intermediate Pstates
are disabled.

Please apply.


Thanks,

Andreas



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

* [PATCH 1/3] powernow-k8: Avoid Pstate MSR accesses on systems supporting CPB
  2012-01-06 14:55 [PATCH 0/3] powernow-k8: Misc fixes Andreas Herrmann
@ 2012-01-06 14:56 ` Andreas Herrmann
  2012-01-06 14:57 ` [PATCH 2/3] powernow-k8: Fix indexing issue Andreas Herrmann
  2012-01-06 14:59 ` [PATCH 3/3] powernow-k8: Update copyright, maintainer and documentation information Andreas Herrmann
  2 siblings, 0 replies; 5+ messages in thread
From: Andreas Herrmann @ 2012-01-06 14:56 UTC (permalink / raw)
  To: Dave Jones; +Cc: cpufreq, linux-kernel


Due to CPB we can't directly map SW Pstates to Pstate MSRs. Get rid of
the paranoia check. (assuming that the ACPI Pstate information is
correct.)

Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
---
 drivers/cpufreq/powernow-k8.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index bce576d..e0329f9 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -926,23 +926,24 @@ static int fill_powernow_table_pstate(struct powernow_k8_data *data,
 			invalidate_entry(powernow_table, i);
 			continue;
 		}
-		rdmsr(MSR_PSTATE_DEF_BASE + index, lo, hi);
-		if (!(hi & HW_PSTATE_VALID_MASK)) {
-			pr_debug("invalid pstate %d, ignoring\n", index);
-			invalidate_entry(powernow_table, i);
-			continue;
-		}
-
-		powernow_table[i].index = index;
-
 		/* Frequency may be rounded for these */
 		if ((boot_cpu_data.x86 == 0x10 && boot_cpu_data.x86_model < 10)
 				 || boot_cpu_data.x86 == 0x11) {
+
+			rdmsr(MSR_PSTATE_DEF_BASE + index, lo, hi);
+			if (!(hi & HW_PSTATE_VALID_MASK)) {
+				pr_debug("invalid pstate %d, ignoring\n", index);
+				invalidate_entry(powernow_table, i);
+				continue;
+			}
+
 			powernow_table[i].frequency =
 				freq_from_fid_did(lo & 0x3f, (lo >> 6) & 7);
 		} else
 			powernow_table[i].frequency =
 				data->acpi_data.states[i].core_frequency * 1000;
+
+		powernow_table[i].index = index;
 	}
 	return 0;
 }
-- 
1.7.8.1




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

* [PATCH 2/3] powernow-k8: Fix indexing issue
  2012-01-06 14:55 [PATCH 0/3] powernow-k8: Misc fixes Andreas Herrmann
  2012-01-06 14:56 ` [PATCH 1/3] powernow-k8: Avoid Pstate MSR accesses on systems supporting CPB Andreas Herrmann
@ 2012-01-06 14:57 ` Andreas Herrmann
  2012-01-06 14:59 ` [PATCH 3/3] powernow-k8: Update copyright, maintainer and documentation information Andreas Herrmann
  2 siblings, 0 replies; 5+ messages in thread
From: Andreas Herrmann @ 2012-01-06 14:57 UTC (permalink / raw)
  To: Dave Jones; +Cc: cpufreq, linux-kernel


The driver uses the pstate number from the status register as index in
its table of ACPI pstates (powernow_table). This is wrong as this is
not a 1-to-1 mapping.

For example we can have _PSS information to just utilize Pstate 0 and
Pstate 4, ie.

  powernow-k8: Core Performance Boosting: on.
  powernow-k8:    0 : pstate 0 (2200 MHz)
  powernow-k8:    1 : pstate 4 (1400 MHz)

In this example the driver's powernow_table has just 2 entries. Using
the pstate number (4) as index into this table is just plain wrong.

Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
---
 drivers/cpufreq/powernow-k8.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index e0329f9..ad683ec 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -54,6 +54,9 @@ static DEFINE_PER_CPU(struct powernow_k8_data *, powernow_data);
 
 static int cpu_family = CPU_OPTERON;
 
+/* array to map SW pstate number to acpi state */
+static u32 ps_to_as[8];
+
 /* core performance boost */
 static bool cpb_capable, cpb_enabled;
 static struct msr __percpu *msrs;
@@ -80,9 +83,9 @@ static u32 find_khz_freq_from_fid(u32 fid)
 }
 
 static u32 find_khz_freq_from_pstate(struct cpufreq_frequency_table *data,
-		u32 pstate)
+				     u32 pstate)
 {
-	return data[pstate].frequency;
+	return data[ps_to_as[pstate]].frequency;
 }
 
 /* Return the vco fid for an input fid
@@ -926,6 +929,9 @@ static int fill_powernow_table_pstate(struct powernow_k8_data *data,
 			invalidate_entry(powernow_table, i);
 			continue;
 		}
+
+		ps_to_as[index] = i;
+
 		/* Frequency may be rounded for these */
 		if ((boot_cpu_data.x86 == 0x10 && boot_cpu_data.x86_model < 10)
 				 || boot_cpu_data.x86 == 0x11) {
@@ -1190,7 +1196,8 @@ static int powernowk8_target(struct cpufreq_policy *pol,
 	powernow_k8_acpi_pst_values(data, newstate);
 
 	if (cpu_family == CPU_HW_PSTATE)
-		ret = transition_frequency_pstate(data, newstate);
+		ret = transition_frequency_pstate(data,
+			data->powernow_table[newstate].index);
 	else
 		ret = transition_frequency_fidvid(data, newstate);
 	if (ret) {
@@ -1203,7 +1210,7 @@ static int powernowk8_target(struct cpufreq_policy *pol,
 
 	if (cpu_family == CPU_HW_PSTATE)
 		pol->cur = find_khz_freq_from_pstate(data->powernow_table,
-				newstate);
+				data->powernow_table[newstate].index);
 	else
 		pol->cur = find_khz_freq_from_fid(data->currfid);
 	ret = 0;
-- 
1.7.8.1




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

* [PATCH 3/3] powernow-k8: Update copyright, maintainer and documentation information
  2012-01-06 14:55 [PATCH 0/3] powernow-k8: Misc fixes Andreas Herrmann
  2012-01-06 14:56 ` [PATCH 1/3] powernow-k8: Avoid Pstate MSR accesses on systems supporting CPB Andreas Herrmann
  2012-01-06 14:57 ` [PATCH 2/3] powernow-k8: Fix indexing issue Andreas Herrmann
@ 2012-01-06 14:59 ` Andreas Herrmann
  2012-01-06 16:15   ` Mark Langsdorf
  2 siblings, 1 reply; 5+ messages in thread
From: Andreas Herrmann @ 2012-01-06 14:59 UTC (permalink / raw)
  To: Dave Jones; +Cc: cpufreq, linux-kernel


Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
---
 drivers/cpufreq/powernow-k8.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index ad683ec..8f9b2ce 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -1,10 +1,11 @@
 /*
- *   (c) 2003-2010 Advanced Micro Devices, Inc.
+ *   (c) 2003-2012 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
  *
- *  Support : mark.langsdorf@amd.com
+ *  Maintainer:
+ *  Andreas Herrmann <andreas.herrmann3@amd.com>
  *
  *  Based on the powernow-k7.c module written by Dave Jones.
  *  (C) 2003 Dave Jones on behalf of SuSE Labs
@@ -16,12 +17,14 @@
  *  Valuable input gratefully received from Dave Jones, Pavel Machek,
  *  Dominik Brodowski, Jacob Shin, and others.
  *  Originally developed by Paul Devriendt.
- *  Processor information obtained from Chapter 9 (Power and Thermal Management)
- *  of the "BIOS and Kernel Developer's Guide for the AMD Athlon 64 and AMD
- *  Opteron Processors" available for download from www.amd.com
  *
- *  Tables for specific CPUs can be inferred from
- *     http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/30430.pdf
+ *  Processor information obtained from Chapter 9 (Power and Thermal
+ *  Management) of the "BIOS and Kernel Developer's Guide (BKDG) for
+ *  the AMD Athlon 64 and AMD Opteron Processors" and section "2.x
+ *  Power Management" in BKDGs for newer AMD CPU families.
+ *
+ *  Tables for specific CPUs can be inferred from AMD's processor
+ *  power and thermal data sheets, (e.g. 30417.pdf, 30430.pdf, 43375.pdf)
  */
 
 #include <linux/kernel.h>
-- 
1.7.8.1





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

* Re: [PATCH 3/3] powernow-k8: Update copyright, maintainer and documentation information
  2012-01-06 14:59 ` [PATCH 3/3] powernow-k8: Update copyright, maintainer and documentation information Andreas Herrmann
@ 2012-01-06 16:15   ` Mark Langsdorf
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Langsdorf @ 2012-01-06 16:15 UTC (permalink / raw)
  To: Andreas Herrmann; +Cc: Dave Jones, cpufreq, linux-kernel

On 01/06/2012 08:59 AM, Andreas Herrmann wrote:
> 
> Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
> ---
>  drivers/cpufreq/powernow-k8.c |   17 ++++++++++-------
>  1 files changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
> index ad683ec..8f9b2ce 100644
> --- a/drivers/cpufreq/powernow-k8.c
> +++ b/drivers/cpufreq/powernow-k8.c
> @@ -1,10 +1,11 @@
>  /*
> - *   (c) 2003-2010 Advanced Micro Devices, Inc.
> + *   (c) 2003-2012 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
>   *
> - *  Support : mark.langsdorf@amd.com
> + *  Maintainer:
> + *  Andreas Herrmann <andreas.herrmann3@amd.com>
>   *
>   *  Based on the powernow-k7.c module written by Dave Jones.
>   *  (C) 2003 Dave Jones on behalf of SuSE Labs
> @@ -16,12 +17,14 @@
>   *  Valuable input gratefully received from Dave Jones, Pavel Machek,
>   *  Dominik Brodowski, Jacob Shin, and others.
>   *  Originally developed by Paul Devriendt.
> - *  Processor information obtained from Chapter 9 (Power and Thermal Management)
> - *  of the "BIOS and Kernel Developer's Guide for the AMD Athlon 64 and AMD
> - *  Opteron Processors" available for download from www.amd.com
>   *
> - *  Tables for specific CPUs can be inferred from
> - *     http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/30430.pdf
> + *  Processor information obtained from Chapter 9 (Power and Thermal
> + *  Management) of the "BIOS and Kernel Developer's Guide (BKDG) for
> + *  the AMD Athlon 64 and AMD Opteron Processors" and section "2.x
> + *  Power Management" in BKDGs for newer AMD CPU families.
> + *
> + *  Tables for specific CPUs can be inferred from AMD's processor
> + *  power and thermal data sheets, (e.g. 30417.pdf, 30430.pdf, 43375.pdf)
>   */
>  
>  #include <linux/kernel.h>

Acked-by: Mark Langsdorf <mark.langsdorf@calxeda.com>

formerly mark.langsdorf@amd.com

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

end of thread, other threads:[~2012-01-06 16:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-06 14:55 [PATCH 0/3] powernow-k8: Misc fixes Andreas Herrmann
2012-01-06 14:56 ` [PATCH 1/3] powernow-k8: Avoid Pstate MSR accesses on systems supporting CPB Andreas Herrmann
2012-01-06 14:57 ` [PATCH 2/3] powernow-k8: Fix indexing issue Andreas Herrmann
2012-01-06 14:59 ` [PATCH 3/3] powernow-k8: Update copyright, maintainer and documentation information Andreas Herrmann
2012-01-06 16:15   ` Mark Langsdorf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).