# HG changeset patch
# User Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
# Date 1308237140 -3600
# Node ID de67ab2d53212831bca81c40130c781ef4a602cb
# Parent b5955b9fc26c172cf43b204a8435c4192274e2a3
Use same data array for INTEL and AMD cpufreq handling
The AMD and INTEL specific parts of cpufreq handling used different
per-cpu data structures with nearly identical semantics. Fold the two
structures into one by adding a generic architecture data item.
Signed-off-by: Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
---
diff -r b5955b9fc26c -r de67ab2d5321 xen/arch/x86/acpi/cpufreq/cpufreq.c
--- a/xen/arch/x86/acpi/cpufreq/cpufreq.c Thu Jun 16 16:11:13 2011 +0100
+++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c Thu Jun 16 16:12:20 2011 +0100
@@ -54,7 +54,7 @@
#define INTEL_MSR_RANGE (0xffffull)
#define CPUID_6_ECX_APERFMPERF_CAPABILITY (0x1)
-static struct acpi_cpufreq_data *drv_data[NR_CPUS];
+struct acpi_cpufreq_data *cpufreq_drv_data[NR_CPUS];
static struct cpufreq_driver acpi_cpufreq_driver;
@@ -103,7 +103,7 @@
static unsigned extract_freq(u32 val, struct acpi_cpufreq_data *data)
{
- switch (data->cpu_feature) {
+ switch (data->arch_cpu_flags) {
case SYSTEM_INTEL_MSR_CAPABLE:
return extract_msr(val, data);
case SYSTEM_IO_CAPABLE:
@@ -213,17 +213,17 @@
return 0;
policy = per_cpu(cpufreq_cpu_policy, cpu);
- if (!policy || !drv_data[policy->cpu])
+ if (!policy || !cpufreq_drv_data[policy->cpu])
return 0;
- switch (drv_data[policy->cpu]->cpu_feature) {
+ switch (cpufreq_drv_data[policy->cpu]->arch_cpu_flags) {
case SYSTEM_INTEL_MSR_CAPABLE:
cmd.type = SYSTEM_INTEL_MSR_CAPABLE;
cmd.addr.msr.reg = MSR_IA32_PERF_STATUS;
break;
case SYSTEM_IO_CAPABLE:
cmd.type = SYSTEM_IO_CAPABLE;
- perf = drv_data[policy->cpu]->acpi_data;
+ perf = cpufreq_drv_data[policy->cpu]->acpi_data;
cmd.addr.io.port = perf->control_register.address;
cmd.addr.io.bit_width = perf->control_register.bit_width;
break;
@@ -372,7 +372,7 @@
if (!policy)
return 0;
- data = drv_data[policy->cpu];
+ data = cpufreq_drv_data[policy->cpu];
if (unlikely(data == NULL ||
data->acpi_data == NULL || data->freq_table == NULL))
return 0;
@@ -419,7 +419,7 @@
static int acpi_cpufreq_target(struct cpufreq_policy *policy,
unsigned int target_freq, unsigned int relation)
{
- struct acpi_cpufreq_data *data = drv_data[policy->cpu];
+ struct acpi_cpufreq_data *data = cpufreq_drv_data[policy->cpu];
struct processor_performance *perf;
struct cpufreq_freqs freqs;
cpumask_t online_policy_cpus;
@@ -456,7 +456,7 @@
return 0;
}
- switch (data->cpu_feature) {
+ switch (data->arch_cpu_flags) {
case SYSTEM_INTEL_MSR_CAPABLE:
cmd.type = SYSTEM_INTEL_MSR_CAPABLE;
cmd.addr.msr.reg = MSR_IA32_PERF_CTL;
@@ -501,7 +501,7 @@
struct acpi_cpufreq_data *data;
struct processor_performance *perf;
- if (!policy || !(data = drv_data[policy->cpu]) ||
+ if (!policy || !(data = cpufreq_drv_data[policy->cpu]) ||
!processor_pminfo[policy->cpu])
return -EINVAL;
@@ -557,7 +557,7 @@
return -ENOMEM;
memset(data, 0, sizeof(struct acpi_cpufreq_data));
- drv_data[cpu] = data;
+ cpufreq_drv_data[cpu] = data;
data->acpi_data = &processor_pminfo[cpu]->perf;
@@ -569,7 +569,7 @@
if (cpufreq_verbose)
printk("xen_pminfo: @acpi_cpufreq_cpu_init,"
"SYSTEM IO addr space\n");
- data->cpu_feature = SYSTEM_IO_CAPABLE;
+ data->arch_cpu_flags = SYSTEM_IO_CAPABLE;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
if (cpufreq_verbose)
@@ -579,7 +579,7 @@
result = -ENODEV;
goto err_unreg;
}
- data->cpu_feature = SYSTEM_INTEL_MSR_CAPABLE;
+ data->arch_cpu_flags = SYSTEM_INTEL_MSR_CAPABLE;
break;
default:
result = -ENODEV;
@@ -652,17 +652,17 @@
xfree(data->freq_table);
err_unreg:
xfree(data);
- drv_data[cpu] = NULL;
+ cpufreq_drv_data[cpu] = NULL;
return result;
}
static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy)
{
- struct acpi_cpufreq_data *data = drv_data[policy->cpu];
+ struct acpi_cpufreq_data *data = cpufreq_drv_data[policy->cpu];
if (data) {
- drv_data[policy->cpu] = NULL;
+ cpufreq_drv_data[policy->cpu] = NULL;
xfree(data->freq_table);
xfree(data);
}
diff -r b5955b9fc26c -r de67ab2d5321 xen/arch/x86/acpi/cpufreq/powernow.c
--- a/xen/arch/x86/acpi/cpufreq/powernow.c Thu Jun 16 16:11:13 2011 +0100
+++ b/xen/arch/x86/acpi/cpufreq/powernow.c Thu Jun 16 16:12:20 2011 +0100
@@ -53,15 +53,7 @@
#define MSR_PSTATE_CUR_LIMIT 0xc0010061 /* pstate current limit MSR */
#define MSR_HWCR_CPBDIS_MASK 0x02000000ULL
-struct powernow_cpufreq_data {
- struct processor_performance *acpi_data;
- struct cpufreq_frequency_table *freq_table;
- unsigned int max_freq;
- unsigned int resume;
- unsigned int cpu_feature;
-};
-
-static struct powernow_cpufreq_data *drv_data[NR_CPUS];
+#define ARCH_CPU_FLAG_RESUME 1
static struct cpufreq_driver powernow_cpufreq_driver;
@@ -92,7 +84,7 @@
static int powernow_cpufreq_target(struct cpufreq_policy *policy,
unsigned int target_freq, unsigned int relation)
{
- struct powernow_cpufreq_data *data = drv_data[policy->cpu];
+ struct acpi_cpufreq_data *data = cpufreq_drv_data[policy->cpu];
struct processor_performance *perf;
struct cpufreq_freqs freqs;
cpumask_t online_policy_cpus;
@@ -119,8 +111,8 @@
next_perf_state = data->freq_table[next_state].index;
if (perf->state == next_perf_state) {
- if (unlikely(data->resume))
- data->resume = 0;
+ if (unlikely(data->arch_cpu_flags & ARCH_CPU_FLAG_RESUME))
+ data->arch_cpu_flags &= ~ARCH_CPU_FLAG_RESUME;
else
return 0;
}
@@ -149,10 +141,10 @@
static int powernow_cpufreq_verify(struct cpufreq_policy *policy)
{
- struct powernow_cpufreq_data *data;
+ struct acpi_cpufreq_data *data;
struct processor_performance *perf;
- if (!policy || !(data = drv_data[policy->cpu]) ||
+ if (!policy || !(data = cpufreq_drv_data[policy->cpu]) ||
!processor_pminfo[policy->cpu])
return -EINVAL;
@@ -190,19 +182,19 @@
unsigned int i;
unsigned int valid_states = 0;
unsigned int cpu = policy->cpu;
- struct powernow_cpufreq_data *data;
+ struct acpi_cpufreq_data *data;
unsigned int result = 0;
struct processor_performance *perf;
u32 max_hw_pstate;
uint64_t msr_content;
struct cpuinfo_x86 *c = &cpu_data[policy->cpu];
- data = xmalloc(struct powernow_cpufreq_data);
+ data = xmalloc(struct acpi_cpufreq_data);
if (!data)
return -ENOMEM;
- memset(data, 0, sizeof(struct powernow_cpufreq_data));
+ memset(data, 0, sizeof(struct acpi_cpufreq_data));
- drv_data[cpu] = data;
+ cpufreq_drv_data[cpu] = data;
data->acpi_data = &processor_pminfo[cpu]->perf;
@@ -252,7 +244,6 @@
policy->governor = cpufreq_opt_governor ? : CPUFREQ_DEFAULT_GOVERNOR;
- data->max_freq = perf->states[0].core_frequency * 1000;
/* table init */
for (i = 0; i < perf->state_count && i <= max_hw_pstate; i++) {
if (i > 0 && perf->states[i].core_frequency >=
@@ -278,7 +269,7 @@
* the first call to ->target() should result in us actually
* writing something to the appropriate registers.
*/
- data->resume = 1;
+ data->arch_cpu_flags |= ARCH_CPU_FLAG_RESUME;
policy->cur = data->freq_table[i].frequency;
return result;
@@ -287,17 +278,17 @@
xfree(data->freq_table);
err_unreg:
xfree(data);
- drv_data[cpu] = NULL;
+ cpufreq_drv_data[cpu] = NULL;
return result;
}
static int powernow_cpufreq_cpu_exit(struct cpufreq_policy *policy)
{
- struct powernow_cpufreq_data *data = drv_data[policy->cpu];
+ struct acpi_cpufreq_data *data = cpufreq_drv_data[policy->cpu];
if (data) {
- drv_data[policy->cpu] = NULL;
+ cpufreq_drv_data[policy->cpu] = NULL;
xfree(data->freq_table);
xfree(data);
}
diff -r b5955b9fc26c -r de67ab2d5321 xen/include/acpi/cpufreq/cpufreq.h
--- a/xen/include/acpi/cpufreq/cpufreq.h Thu Jun 16 16:11:13 2011 +0100
+++ b/xen/include/acpi/cpufreq/cpufreq.h Thu Jun 16 16:12:20 2011 +0100
@@ -29,9 +29,11 @@
struct acpi_cpufreq_data {
struct processor_performance *acpi_data;
struct cpufreq_frequency_table *freq_table;
- unsigned int cpu_feature;
+ unsigned int arch_cpu_flags;
};
+extern struct acpi_cpufreq_data *cpufreq_drv_data[NR_CPUS];
+
struct cpufreq_cpuinfo {
unsigned int max_freq;
unsigned int second_max_freq; /* P1 if Turbo Mode is on */
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|