Commit 88d91a82 authored by Dave Jones's avatar Dave Jones

[CPUFREQ] Fix ACPI P-State driver.

from Dmitry Torokhov.

I have the following problems with ACPI P-States driver:

- It crashes because it tries to switch CPU speed without registering cpufreq
driver first but acpi_processor_set_performance calls cpufreq_notify_transition.

- When testing for capable CPUs it skips all online ones so for my single CPU
notebook it can't activate at all.

- If a processor does not support throttling then it will say that "limit"
interface is not supported even after activating performance control.

The patch below should fix these issues. It also adds some info messages since
/proc/acpi/processor/*/performance interface is marked obsolete but i still
would like to see if P-states were recognized during boot.
parent 36f111a9
...@@ -555,6 +555,7 @@ acpi_cpufreq_cpu_init ( ...@@ -555,6 +555,7 @@ acpi_cpufreq_cpu_init (
unsigned int cpu = policy->cpu; unsigned int cpu = policy->cpu;
struct acpi_processor *pr = NULL; struct acpi_processor *pr = NULL;
struct acpi_processor_performance *perf = &performance[policy->cpu]; struct acpi_processor_performance *perf = &performance[policy->cpu];
struct acpi_device *device;
unsigned int result = 0; unsigned int result = 0;
ACPI_FUNCTION_TRACE("acpi_cpufreq_cpu_init"); ACPI_FUNCTION_TRACE("acpi_cpufreq_cpu_init");
...@@ -596,6 +597,17 @@ acpi_cpufreq_cpu_init ( ...@@ -596,6 +597,17 @@ acpi_cpufreq_cpu_init (
acpi_cpufreq_add_file(pr); acpi_cpufreq_add_file(pr);
if (acpi_bus_get_device(pr->handle, &device))
device = NULL;
printk(KERN_INFO "cpufreq: %s - ACPI performance management activated.\n",
device ? acpi_device_bid(device) : "CPU??");
for (i = 0; i < pr->performance->state_count; i++)
printk(KERN_INFO "cpufreq: %cP%d: %d MHz, %d mW, %d uS\n",
(i == pr->performance->state?'*':' '), i,
(u32) pr->performance->states[i].core_frequency,
(u32) pr->performance->states[i].power,
(u32) pr->performance->states[i].transition_latency);
return_VALUE(result); return_VALUE(result);
} }
...@@ -658,16 +670,21 @@ acpi_cpufreq_init (void) ...@@ -658,16 +670,21 @@ acpi_cpufreq_init (void)
/* test it on one CPU */ /* test it on one CPU */
for (i=0; i<NR_CPUS; i++) { for (i=0; i<NR_CPUS; i++) {
if (cpu_online(i)) if (!cpu_online(i))
continue; continue;
pr = performance[i].pr; pr = performance[i].pr;
if (pr && pr->flags.performance) if (pr && pr->flags.performance)
goto found_capable_cpu; goto found_capable_cpu;
} }
result = -ENODEV; result = -ENODEV;
goto err; goto err0;
found_capable_cpu: found_capable_cpu:
result = cpufreq_register_driver(&acpi_cpufreq_driver);
if (result)
goto err0;
perf = pr->performance; perf = pr->performance;
current_state = perf->state; current_state = perf->state;
...@@ -676,7 +693,7 @@ acpi_cpufreq_init (void) ...@@ -676,7 +693,7 @@ acpi_cpufreq_init (void)
if (result) { if (result) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Disabled P-States due to failure while switching.\n")); ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Disabled P-States due to failure while switching.\n"));
result = -ENODEV; result = -ENODEV;
goto err; goto err1;
} }
} }
...@@ -684,7 +701,7 @@ acpi_cpufreq_init (void) ...@@ -684,7 +701,7 @@ acpi_cpufreq_init (void)
if (result) { if (result) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Disabled P-States due to failure while switching.\n")); ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Disabled P-States due to failure while switching.\n"));
result = -ENODEV; result = -ENODEV;
goto err; goto err1;
} }
if (current_state != 0) { if (current_state != 0) {
...@@ -692,18 +709,17 @@ acpi_cpufreq_init (void) ...@@ -692,18 +709,17 @@ acpi_cpufreq_init (void)
if (result) { if (result) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Disabled P-States due to failure while switching.\n")); ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Disabled P-States due to failure while switching.\n"));
result = -ENODEV; result = -ENODEV;
goto err; goto err1;
} }
} }
result = cpufreq_register_driver(&acpi_cpufreq_driver);
if (result)
goto err;
return_VALUE(0); return_VALUE(0);
/* error handling */ /* error handling */
err: err1:
cpufreq_unregister_driver(&acpi_cpufreq_driver);
err0:
/* unregister struct acpi_processor_performance performance */ /* unregister struct acpi_processor_performance performance */
for (i=0; i<NR_CPUS; i++) { for (i=0; i<NR_CPUS; i++) {
if (performance[i].pr) { if (performance[i].pr) {
...@@ -713,6 +729,8 @@ acpi_cpufreq_init (void) ...@@ -713,6 +729,8 @@ acpi_cpufreq_init (void)
} }
} }
kfree(performance); kfree(performance);
printk(KERN_INFO "cpufreq: No CPUs supporting ACPI performance management found.\n");
return_VALUE(result); return_VALUE(result);
} }
......
...@@ -85,7 +85,7 @@ static int acpi_processor_info_open_fs(struct inode *inode, struct file *file); ...@@ -85,7 +85,7 @@ static int acpi_processor_info_open_fs(struct inode *inode, struct file *file);
static int acpi_processor_throttling_open_fs(struct inode *inode, struct file *file); static int acpi_processor_throttling_open_fs(struct inode *inode, struct file *file);
static int acpi_processor_power_open_fs(struct inode *inode, struct file *file); static int acpi_processor_power_open_fs(struct inode *inode, struct file *file);
static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file); static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file);
static int acpi_processor_get_limit_info(struct acpi_processor *pr);
static struct acpi_driver acpi_processor_driver = { static struct acpi_driver acpi_processor_driver = {
.name = ACPI_PROCESSOR_DRIVER_NAME, .name = ACPI_PROCESSOR_DRIVER_NAME,
...@@ -770,6 +770,8 @@ acpi_processor_get_platform_limit ( ...@@ -770,6 +770,8 @@ acpi_processor_get_platform_limit (
pr->performance_platform_limit = (int) ppc; pr->performance_platform_limit = (int) ppc;
acpi_processor_get_limit_info(pr);
return_VALUE(0); return_VALUE(0);
} }
EXPORT_SYMBOL(acpi_processor_get_platform_limit); EXPORT_SYMBOL(acpi_processor_get_platform_limit);
...@@ -790,6 +792,7 @@ acpi_processor_register_performance ( ...@@ -790,6 +792,7 @@ acpi_processor_register_performance (
return_VALUE(-EBUSY); return_VALUE(-EBUSY);
(*pr)->performance = performance; (*pr)->performance = performance;
performance->pr = *pr;
return 0; return 0;
} }
EXPORT_SYMBOL(acpi_processor_register_performance); EXPORT_SYMBOL(acpi_processor_register_performance);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment