[PATCH 8/8 v2] cpufreq: Remove support for hardware P-state chips from powernow-k8

2012-09-04 Thread Andre Przywara
From: Matthew Garrett 

These chips are now supported by acpi-cpufreq, so we can delete all the
code handling them.

Andre: Tighten the deprecation warning message. Trigger load of
acpi-cpufreq and let the load of the module finally fail.
This avoids the problem of users ending up without any cpufreq support
after the transition.

Signed-off-by: Matthew Garrett 
Signed-off-by: Andre Przywara 
---
 drivers/cpufreq/Makefile  |   2 +-
 drivers/cpufreq/powernow-k8.c | 392 +++---
 drivers/cpufreq/powernow-k8.h |  32 
 3 files changed, 29 insertions(+), 397 deletions(-)

diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 9531fc2..b99790f 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -19,7 +19,7 @@ obj-$(CONFIG_CPU_FREQ_TABLE)  += freq_table.o
 # K8 systems. ACPI is preferred to all other hardware-specific drivers.
 # speedstep-* is preferred over p4-clockmod.
 
-obj-$(CONFIG_X86_POWERNOW_K8)  += powernow-k8.o mperf.o
+obj-$(CONFIG_X86_POWERNOW_K8)  += powernow-k8.o
 obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o mperf.o
 obj-$(CONFIG_X86_PCC_CPUFREQ)  += pcc-cpufreq.o
 obj-$(CONFIG_X86_POWERNOW_K6)  += powernow-k6.o
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index 8ff0621..c8bfeff 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -49,22 +49,12 @@
 #define PFX "powernow-k8: "
 #define VERSION "version 2.20.00"
 #include "powernow-k8.h"
-#include "mperf.h"
 
 /* serialize freq changes  */
 static DEFINE_MUTEX(fidvid_mutex);
 
 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;
-
 static struct cpufreq_driver cpufreq_amd64_driver;
 
 #ifndef CONFIG_SMP
@@ -86,12 +76,6 @@ static u32 find_khz_freq_from_fid(u32 fid)
return 1000 * find_freq_from_fid(fid);
 }
 
-static u32 find_khz_freq_from_pstate(struct cpufreq_frequency_table *data,
-u32 pstate)
-{
-   return data[ps_to_as[pstate]].frequency;
-}
-
 /* Return the vco fid for an input fid
  *
  * Each "low" fid has corresponding "high" fid, and you can get to "low" fids
@@ -114,9 +98,6 @@ static int pending_bit_stuck(void)
 {
u32 lo, hi;
 
-   if (cpu_family == CPU_HW_PSTATE)
-   return 0;
-
rdmsr(MSR_FIDVID_STATUS, lo, hi);
return lo & MSR_S_LO_CHANGE_PENDING ? 1 : 0;
 }
@@ -130,20 +111,6 @@ static int query_current_values_with_pending_wait(struct 
powernow_k8_data *data)
u32 lo, hi;
u32 i = 0;
 
-   if (cpu_family == CPU_HW_PSTATE) {
-   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 {
if (i++ > 1) {
pr_debug("detected change pending stuck\n");
@@ -300,14 +267,6 @@ static int decrease_vid_code_by_step(struct 
powernow_k8_data *data,
return 0;
 }
 
-/* Change hardware pstate by single MSR write */
-static int transition_pstate(struct powernow_k8_data *data, u32 pstate)
-{
-   wrmsr(MSR_PSTATE_CTRL, pstate, 0);
-   data->currpstate = pstate;
-   return 0;
-}
-
 /* Change Opteron/Athlon64 fid and vid, by the 3 phases. */
 static int transition_fid_vid(struct powernow_k8_data *data,
u32 reqfid, u32 reqvid)
@@ -524,8 +483,6 @@ static int core_voltage_post_transition(struct 
powernow_k8_data *data,
 static const struct x86_cpu_id powernow_k8_ids[] = {
/* IO based frequency switching */
{ X86_VENDOR_AMD, 0xf },
-   /* MSR based frequency switching supported */
-   X86_FEATURE_MATCH(X86_FEATURE_HW_PSTATE),
{}
 };
 MODULE_DEVICE_TABLE(x86cpu, powernow_k8_ids);
@@ -561,15 +518,8 @@ static void check_supported_cpu(void *_rc)
"Power state transitions not supported\n");
return;
}
-   } else { /* must be a HW Pstate capable processor */
-   cpuid(CPUID_FREQ_VOLT_CAPABILITIES, , , , );
-   if ((edx & USE_HW_PSTATE) == USE_HW_PSTATE)
-   cpu_family = CPU_HW_PSTATE;
-   else
-   return;
+   *rc = 0;
}
-
-   *rc = 0;
 }
 
 static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst,
@@ -633,18 +583,11 @@ static void 

[PATCH 8/8 v2] cpufreq: Remove support for hardware P-state chips from powernow-k8

2012-09-04 Thread Andre Przywara
From: Matthew Garrett m...@redhat.com

These chips are now supported by acpi-cpufreq, so we can delete all the
code handling them.

Andre: Tighten the deprecation warning message. Trigger load of
acpi-cpufreq and let the load of the module finally fail.
This avoids the problem of users ending up without any cpufreq support
after the transition.

Signed-off-by: Matthew Garrett m...@redhat.com
Signed-off-by: Andre Przywara andre.przyw...@amd.com
---
 drivers/cpufreq/Makefile  |   2 +-
 drivers/cpufreq/powernow-k8.c | 392 +++---
 drivers/cpufreq/powernow-k8.h |  32 
 3 files changed, 29 insertions(+), 397 deletions(-)

diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 9531fc2..b99790f 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -19,7 +19,7 @@ obj-$(CONFIG_CPU_FREQ_TABLE)  += freq_table.o
 # K8 systems. ACPI is preferred to all other hardware-specific drivers.
 # speedstep-* is preferred over p4-clockmod.
 
-obj-$(CONFIG_X86_POWERNOW_K8)  += powernow-k8.o mperf.o
+obj-$(CONFIG_X86_POWERNOW_K8)  += powernow-k8.o
 obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o mperf.o
 obj-$(CONFIG_X86_PCC_CPUFREQ)  += pcc-cpufreq.o
 obj-$(CONFIG_X86_POWERNOW_K6)  += powernow-k6.o
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index 8ff0621..c8bfeff 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -49,22 +49,12 @@
 #define PFX powernow-k8: 
 #define VERSION version 2.20.00
 #include powernow-k8.h
-#include mperf.h
 
 /* serialize freq changes  */
 static DEFINE_MUTEX(fidvid_mutex);
 
 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;
-
 static struct cpufreq_driver cpufreq_amd64_driver;
 
 #ifndef CONFIG_SMP
@@ -86,12 +76,6 @@ static u32 find_khz_freq_from_fid(u32 fid)
return 1000 * find_freq_from_fid(fid);
 }
 
-static u32 find_khz_freq_from_pstate(struct cpufreq_frequency_table *data,
-u32 pstate)
-{
-   return data[ps_to_as[pstate]].frequency;
-}
-
 /* Return the vco fid for an input fid
  *
  * Each low fid has corresponding high fid, and you can get to low fids
@@ -114,9 +98,6 @@ static int pending_bit_stuck(void)
 {
u32 lo, hi;
 
-   if (cpu_family == CPU_HW_PSTATE)
-   return 0;
-
rdmsr(MSR_FIDVID_STATUS, lo, hi);
return lo  MSR_S_LO_CHANGE_PENDING ? 1 : 0;
 }
@@ -130,20 +111,6 @@ static int query_current_values_with_pending_wait(struct 
powernow_k8_data *data)
u32 lo, hi;
u32 i = 0;
 
-   if (cpu_family == CPU_HW_PSTATE) {
-   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 {
if (i++  1) {
pr_debug(detected change pending stuck\n);
@@ -300,14 +267,6 @@ static int decrease_vid_code_by_step(struct 
powernow_k8_data *data,
return 0;
 }
 
-/* Change hardware pstate by single MSR write */
-static int transition_pstate(struct powernow_k8_data *data, u32 pstate)
-{
-   wrmsr(MSR_PSTATE_CTRL, pstate, 0);
-   data-currpstate = pstate;
-   return 0;
-}
-
 /* Change Opteron/Athlon64 fid and vid, by the 3 phases. */
 static int transition_fid_vid(struct powernow_k8_data *data,
u32 reqfid, u32 reqvid)
@@ -524,8 +483,6 @@ static int core_voltage_post_transition(struct 
powernow_k8_data *data,
 static const struct x86_cpu_id powernow_k8_ids[] = {
/* IO based frequency switching */
{ X86_VENDOR_AMD, 0xf },
-   /* MSR based frequency switching supported */
-   X86_FEATURE_MATCH(X86_FEATURE_HW_PSTATE),
{}
 };
 MODULE_DEVICE_TABLE(x86cpu, powernow_k8_ids);
@@ -561,15 +518,8 @@ static void check_supported_cpu(void *_rc)
Power state transitions not supported\n);
return;
}
-   } else { /* must be a HW Pstate capable processor */
-   cpuid(CPUID_FREQ_VOLT_CAPABILITIES, eax, ebx, ecx, edx);
-   if ((edx  USE_HW_PSTATE) == USE_HW_PSTATE)
-   cpu_family = CPU_HW_PSTATE;
-   else
-   return;
+   *rc = 0;
}
-
-   *rc = 0;
 }
 
 static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst,
@@