Commit 8d13373b authored by Dominik Brodowski's avatar Dominik Brodowski Committed by Linus Torvalds

[PATCH] cpufreq: clean up CPU information

This patch moves some basic per-CPU static information (minimum frequency,
maximum frequency and maximum transition latency) into a struct
cpufreq_cpuinfo. This offers a much cleaner struct cpufreq_driver and
struct cpufreq_policy.
parent 9aa5637c
...@@ -77,8 +77,8 @@ static int integrator_verify_speed(struct cpufreq_policy *policy) ...@@ -77,8 +77,8 @@ static int integrator_verify_speed(struct cpufreq_policy *policy)
{ {
struct vco vco; struct vco vco;
if (policy->max > policy->max_cpu_freq) if (policy->max > policy->cpuinfo.max_freq)
policy->max = policy->max_cpu_freq; policy->max = policy->cpuinfo.max_freq;
if (policy->max < 12000) if (policy->max < 12000)
policy->max = 12000; policy->max = 12000;
...@@ -148,7 +148,9 @@ static int integrator_set_policy(struct cpufreq_policy *policy) ...@@ -148,7 +148,9 @@ static int integrator_set_policy(struct cpufreq_policy *policy)
static struct cpufreq_policy integrator_policy = { static struct cpufreq_policy integrator_policy = {
.cpu = 0, .cpu = 0,
.policy = CPUFREQ_POLICY_POWERSAVE, .policy = CPUFREQ_POLICY_POWERSAVE,
.max_cpu_freq = 160000, .cpuinfo.max_cpu_freq = 160000,
.cpuinfo.min_cpu_freq = 12000,
.cpuinfo.transition_latency = CPUFREQ_ETERNAL,
}; };
static struct cpufreq_driver integrator_driver = { static struct cpufreq_driver integrator_driver = {
...@@ -197,7 +199,9 @@ static int __init integrator_cpu_init(void) ...@@ -197,7 +199,9 @@ static int __init integrator_cpu_init(void)
policies[cpu].cpu = cpu; policies[cpu].cpu = cpu;
policies[cpu].policy = CPUFREQ_POLICY_POWERSAVE, policies[cpu].policy = CPUFREQ_POLICY_POWERSAVE,
policies[cpu].max_cpu_freq = 160000; policies[cpu].cpuinfo.max_freq = 160000;
policies[cpu].cpuinfo.min_freq = 12000;
policies[cpu].cpuinfo.transition_latency = CPUFREQ_ETERNAL;
policies[cpu].min = policies[cpu].min =
policies[cpu].max = vco_to_freq(vco, 1); policies[cpu].max = vco_to_freq(vco, 1);
} }
...@@ -205,8 +209,6 @@ static int __init integrator_cpu_init(void) ...@@ -205,8 +209,6 @@ static int __init integrator_cpu_init(void)
set_cpus_allowed(current, cpus_allowed); set_cpus_allowed(current, cpus_allowed);
#ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_FREQ
for (cpu=0; cpu<NR_CPUS; cpu++)
integrator_driver.cpu_min_freq[cpu] = 12000;
integrator_driver.policy = policies; integrator_driver.policy = policies;
cpufreq_register(&integrator_driver); cpufreq_register(&integrator_driver);
#else #else
......
...@@ -203,14 +203,15 @@ static int sa1100_setspeed(struct cpufreq_policy *policy) ...@@ -203,14 +203,15 @@ static int sa1100_setspeed(struct cpufreq_policy *policy)
static struct cpufreq_policy sa1100_policy = { static struct cpufreq_policy sa1100_policy = {
.cpu = 0, .cpu = 0,
.policy = CPUFREQ_POLICY_POWERSAVE, .policy = CPUFREQ_POLICY_POWERSAVE,
.max_cpu_freq = 287000, .cpuinfo.max_freq = 287000,
.cpuinfo.min_freq = 59000,
.cpuinfo.transition_latency = CPUFREQ_ETERNAL,
}; };
static struct cpufreq_driver sa1100_driver = { static struct cpufreq_driver sa1100_driver = {
.verify = sa11x0_verify_speed, .verify = sa11x0_verify_speed,
.setpolicy = sa1100_setspeed, .setpolicy = sa1100_setspeed,
.policy = &sa1100_policy, .policy = &sa1100_policy,
.cpu_min_freq[0]= 59000,
}; };
static int __init sa1100_dram_init(void) static int __init sa1100_dram_init(void)
......
...@@ -298,14 +298,15 @@ static int sa1110_setspeed(struct cpufreq_policy *policy) ...@@ -298,14 +298,15 @@ static int sa1110_setspeed(struct cpufreq_policy *policy)
static struct cpufreq_policy sa1110_policy = { static struct cpufreq_policy sa1110_policy = {
.cpu = 0, .cpu = 0,
.policy = CPUFREQ_POLICY_POWERSAVE, .policy = CPUFREQ_POLICY_POWERSAVE,
.max_cpu_freq = 287000, .cpuinfo.max_freq = 287000,
.cpuinfo.min_freq = 59000,
.cpuinfo.transition_latency = CPUFREQ_ETERNAL,
}; };
static struct cpufreq_driver sa1110_driver = { static struct cpufreq_driver sa1110_driver = {
.verify = sa11x0_verify_speed, .verify = sa11x0_verify_speed,
.setpolicy = sa1110_setspeed, .setpolicy = sa1110_setspeed,
.policy = &sa1110_policy, .policy = &sa1110_policy,
.cpu_min_freq = { 59000, },
}; };
static int __init sa1110_clk_init(void) static int __init sa1110_clk_init(void)
......
...@@ -69,8 +69,8 @@ unsigned int sa11x0_freq_to_ppcr(unsigned int khz) ...@@ -69,8 +69,8 @@ unsigned int sa11x0_freq_to_ppcr(unsigned int khz)
*/ */
int sa11x0_verify_speed(struct cpufreq_policy *policy) int sa11x0_verify_speed(struct cpufreq_policy *policy)
{ {
if (policy->max > policy->max_cpu_freq) if (policy->max > policy->cpuinfo.max_freq)
policy->max = policy->max_cpu_freq; policy->max = policy->cpuinfo.max_freq;
policy->max = cclk_frequency_100khz[sa11x0_freq_to_ppcr(policy->max)] * 100; policy->max = cclk_frequency_100khz[sa11x0_freq_to_ppcr(policy->max)] * 100;
policy->min = policy->max; policy->min = policy->max;
......
...@@ -296,7 +296,6 @@ static int __init elanfreq_init(void) ...@@ -296,7 +296,6 @@ static int __init elanfreq_init(void)
max_freq = elanfreq_get_cpu_frequency(); max_freq = elanfreq_get_cpu_frequency();
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
driver->cpu_min_freq[0] = 1000;
driver->cpu_cur_freq[0] = elanfreq_get_cpu_frequency(); driver->cpu_cur_freq[0] = elanfreq_get_cpu_frequency();
#endif #endif
...@@ -307,7 +306,9 @@ static int __init elanfreq_init(void) ...@@ -307,7 +306,9 @@ static int __init elanfreq_init(void)
driver->policy[0].min = 1000; driver->policy[0].min = 1000;
driver->policy[0].max = max_freq; driver->policy[0].max = max_freq;
driver->policy[0].policy = CPUFREQ_POLICY_PERFORMANCE; driver->policy[0].policy = CPUFREQ_POLICY_PERFORMANCE;
driver->policy[0].max_cpu_freq = max_freq; driver->policy[0].cpuinfo.max_freq = max_freq;
driver->policy[0].cpuinfo.min_freq = min_freq;
driver->policy[0].cpuinfo.transition_latency = CPUFREQ_ETERNAL;
elanfreq_driver = driver; elanfreq_driver = driver;
......
...@@ -779,7 +779,6 @@ static int __init longhaul_init (void) ...@@ -779,7 +779,6 @@ static int __init longhaul_init (void)
driver->policy = (struct cpufreq_policy *) (driver + 1); driver->policy = (struct cpufreq_policy *) (driver + 1);
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
driver->cpu_min_freq[0] = (unsigned int) lowest_speed;
driver->cpu_cur_freq[0] = currentspeed; driver->cpu_cur_freq[0] = currentspeed;
#endif #endif
...@@ -790,7 +789,9 @@ static int __init longhaul_init (void) ...@@ -790,7 +789,9 @@ static int __init longhaul_init (void)
driver->policy[0].min = (unsigned int) lowest_speed; driver->policy[0].min = (unsigned int) lowest_speed;
driver->policy[0].max = (unsigned int) highest_speed; driver->policy[0].max = (unsigned int) highest_speed;
driver->policy[0].policy = CPUFREQ_POLICY_PERFORMANCE; driver->policy[0].policy = CPUFREQ_POLICY_PERFORMANCE;
driver->policy[0].max_cpu_freq = (unsigned int) highest_speed; driver->policy[0].cpuinfo.min_freq = (unsigned int) lowest_speed;
driver->policy[0].cpuinfo.max_freq = (unsigned int) highest_speed;
driver->policy[0].cpuinfo.transition_latency = CPUFREQ_ETERNAL;
longhaul_driver = driver; longhaul_driver = driver;
......
...@@ -121,8 +121,9 @@ static int longrun_verify_policy(struct cpufreq_policy *policy) ...@@ -121,8 +121,9 @@ static int longrun_verify_policy(struct cpufreq_policy *policy)
return -EINVAL; return -EINVAL;
policy->cpu = 0; policy->cpu = 0;
cpufreq_verify_within_limits(policy, 0, cpufreq_verify_within_limits(policy,
longrun_driver->policy[0].max_cpu_freq); longrun_driver->policy[0].cpuinfo.min_freq,
longrun_driver->policy[0].cpuinfo.max_freq);
return 0; return 0;
} }
...@@ -247,12 +248,13 @@ static int __init longrun_init(void) ...@@ -247,12 +248,13 @@ static int __init longrun_init(void)
kfree(driver); kfree(driver);
return -EIO; return -EIO;
} }
driver->policy[0].max_cpu_freq = longrun_high_freq; driver->policy[0].cpuinfo.min_freq = longrun_low_freq;
driver->policy[0].cpuinfo.max_freq = longrun_high_freq;
driver->policy[0].cpuinfo.transition_latency = CPUFREQ_ETERNAL;
longrun_get_policy(&driver->policy[0]); longrun_get_policy(&driver->policy[0]);
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
driver->cpu_min_freq[0] = longrun_low_freq;
driver->cpu_cur_freq[0] = longrun_high_freq; /* dummy value */ driver->cpu_cur_freq[0] = longrun_high_freq; /* dummy value */
#endif #endif
......
...@@ -257,7 +257,6 @@ int __init cpufreq_p4_init(void) ...@@ -257,7 +257,6 @@ int __init cpufreq_p4_init(void)
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
for (i=0;i<NR_CPUS;i++) { for (i=0;i<NR_CPUS;i++) {
driver->cpu_min_freq[i] = stock_freq / 8;
driver->cpu_cur_freq[i] = stock_freq; driver->cpu_cur_freq[i] = stock_freq;
} }
#endif #endif
...@@ -272,7 +271,10 @@ int __init cpufreq_p4_init(void) ...@@ -272,7 +271,10 @@ int __init cpufreq_p4_init(void)
driver->policy[i].min = stock_freq / 8; driver->policy[i].min = stock_freq / 8;
driver->policy[i].max = stock_freq; driver->policy[i].max = stock_freq;
driver->policy[i].policy = CPUFREQ_POLICY_PERFORMANCE; driver->policy[i].policy = CPUFREQ_POLICY_PERFORMANCE;
driver->policy[i].max_cpu_freq = stock_freq; driver->policy[i].cpuinfo.min_freq = driver->policy[i].min;
driver->policy[i].cpuinfo.max_freq = stock_freq;
driver->policy[i].cpuinfo.transition_latency = CPUFREQ_ETERNAL;
driver->policy[i].cpu = i; driver->policy[i].cpu = i;
} }
......
...@@ -242,7 +242,6 @@ static int __init powernow_k6_init(void) ...@@ -242,7 +242,6 @@ static int __init powernow_k6_init(void)
driver->policy = (struct cpufreq_policy *) (driver + 1); driver->policy = (struct cpufreq_policy *) (driver + 1);
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
driver->cpu_min_freq[0] = busfreq * 20;
driver->cpu_cur_freq[0] = busfreq * max_multiplier; driver->cpu_cur_freq[0] = busfreq * max_multiplier;
#endif #endif
...@@ -253,7 +252,9 @@ static int __init powernow_k6_init(void) ...@@ -253,7 +252,9 @@ static int __init powernow_k6_init(void)
driver->policy[0].min = busfreq * 20; driver->policy[0].min = busfreq * 20;
driver->policy[0].max = busfreq * max_multiplier; driver->policy[0].max = busfreq * max_multiplier;
driver->policy[0].policy = CPUFREQ_POLICY_PERFORMANCE; driver->policy[0].policy = CPUFREQ_POLICY_PERFORMANCE;
driver->policy[0].max_cpu_freq = busfreq * max_multiplier; driver->policy[0].cpuinfo.max_freq = busfreq * max_multiplier;
driver->policy[0].cpuinfo.min_freq = busfreq * 20;
driver->policy[0].cpuinfo.transition_latency = CPUFREQ_ETERNAL;
powernow_driver = driver; powernow_driver = driver;
......
...@@ -693,7 +693,6 @@ static int __init speedstep_init(void) ...@@ -693,7 +693,6 @@ static int __init speedstep_init(void)
driver->policy = (struct cpufreq_policy *) (driver + 1); driver->policy = (struct cpufreq_policy *) (driver + 1);
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
driver->cpu_min_freq[0] = speedstep_low_freq;
driver->cpu_cur_freq[0] = speed; driver->cpu_cur_freq[0] = speed;
#endif #endif
...@@ -703,7 +702,10 @@ static int __init speedstep_init(void) ...@@ -703,7 +702,10 @@ static int __init speedstep_init(void)
driver->policy[0].cpu = 0; driver->policy[0].cpu = 0;
driver->policy[0].min = speedstep_low_freq; driver->policy[0].min = speedstep_low_freq;
driver->policy[0].max = speedstep_high_freq; driver->policy[0].max = speedstep_high_freq;
driver->policy[0].max_cpu_freq = speedstep_high_freq; driver->policy[0].cpuinfo.min_freq = speedstep_low_freq;
driver->policy[0].cpuinfo.max_freq = speedstep_high_freq;
driver->policy[0].cpuinfo.transition_latency = CPUFREQ_ETERNAL;
driver->policy[0].policy = (speed == speedstep_low_freq) ? driver->policy[0].policy = (speed == speedstep_low_freq) ?
CPUFREQ_POLICY_POWERSAVE : CPUFREQ_POLICY_PERFORMANCE; CPUFREQ_POLICY_POWERSAVE : CPUFREQ_POLICY_PERFORMANCE;
......
...@@ -1849,10 +1849,15 @@ acpi_cpufreq_init ( ...@@ -1849,10 +1849,15 @@ acpi_cpufreq_init (
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
for (i=0;i<NR_CPUS;i++) { for (i=0;i<NR_CPUS;i++) {
driver->cpu_cur_freq[0] = pr->performance.states[current_state].core_frequency * 1000; driver->cpu_cur_freq[0] = pr->performance.states[current_state].core_frequency * 1000;
driver->cpu_min_freq[0] = pr->performance.states[pr->performance.state_count - 1].core_frequency * 1000;
} }
#endif #endif
/* detect highest transition latency */
for (i=0;i<pr->performance.state_count;i++) {
if (pr->performance.states[i].transition_latency > driver->policy[0].cpuinfo.transition_latency)
driver->policy[0].cpuinfo.transition_latency = pr->performance.states[i].transition_latency;
}
driver->verify = &acpi_cpufreq_verify; driver->verify = &acpi_cpufreq_verify;
driver->setpolicy = &acpi_cpufreq_setpolicy; driver->setpolicy = &acpi_cpufreq_setpolicy;
...@@ -1860,7 +1865,9 @@ acpi_cpufreq_init ( ...@@ -1860,7 +1865,9 @@ acpi_cpufreq_init (
driver->policy[i].cpu = pr->id; driver->policy[i].cpu = pr->id;
driver->policy[i].min = pr->performance.states[pr->performance.state_count - 1].core_frequency * 1000; driver->policy[i].min = pr->performance.states[pr->performance.state_count - 1].core_frequency * 1000;
driver->policy[i].max = pr->performance.states[pr->limit.state.px].core_frequency * 1000; driver->policy[i].max = pr->performance.states[pr->limit.state.px].core_frequency * 1000;
driver->policy[i].max_cpu_freq = pr->performance.states[0].core_frequency * 1000; driver->policy[i].cpuinfo.max_freq = pr->performance.states[0].core_frequency * 1000;
driver->policy[i].cpuinfo.min_freq = pr->performance.states[pr->performance.state_count - 1].core_frequency * 1000;
driver->policy[i].cpuinfo.transition_latency = driver->policy[0].cpuinfo.transition_latency;
driver->policy[i].policy = ( pr->performance.states[current_state].core_frequency * 1000 == driver->policy[i].max) ? driver->policy[i].policy = ( pr->performance.states[current_state].core_frequency * 1000 == driver->policy[i].max) ?
CPUFREQ_POLICY_PERFORMANCE : CPUFREQ_POLICY_POWERSAVE; CPUFREQ_POLICY_PERFORMANCE : CPUFREQ_POLICY_POWERSAVE;
} }
......
...@@ -37,15 +37,26 @@ int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list); ...@@ -37,15 +37,26 @@ int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list);
#define CPUFREQ_POLICY_POWERSAVE (1) #define CPUFREQ_POLICY_POWERSAVE (1)
#define CPUFREQ_POLICY_PERFORMANCE (2) #define CPUFREQ_POLICY_PERFORMANCE (2)
/* values here are CPU kHz so that hardware which doesn't run with some /* Frequency values here are CPU kHz so that hardware which doesn't run
* frequencies can complain without having to guess what per cent / per * with some frequencies can complain without having to guess what per
* mille means. */ * cent / per mille means.
* Maximum transition latency is in nanoseconds - if it's unknown,
* CPUFREQ_ETERNAL shall be used.
*/
#define CPUFREQ_ETERNAL (-1)
struct cpufreq_cpuinfo {
unsigned int max_freq;
unsigned int min_freq;
unsigned int transition_latency;
};
struct cpufreq_policy { struct cpufreq_policy {
unsigned int cpu; /* cpu nr or CPUFREQ_ALL_CPUS */ unsigned int cpu; /* cpu nr or CPUFREQ_ALL_CPUS */
unsigned int min; /* in kHz */ unsigned int min; /* in kHz */
unsigned int max; /* in kHz */ unsigned int max; /* in kHz */
unsigned int policy; /* see above */ unsigned int policy; /* see above */
unsigned int max_cpu_freq; /* for information */ struct cpufreq_cpuinfo cpuinfo; /* see above */
}; };
#define CPUFREQ_ADJUST (0) #define CPUFREQ_ADJUST (0)
...@@ -116,7 +127,6 @@ struct cpufreq_driver { ...@@ -116,7 +127,6 @@ struct cpufreq_driver {
#endif #endif
/* 2.4. compatible API */ /* 2.4. compatible API */
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
unsigned int cpu_min_freq[NR_CPUS];
unsigned int cpu_cur_freq[NR_CPUS]; unsigned int cpu_cur_freq[NR_CPUS];
#endif #endif
}; };
......
...@@ -119,8 +119,8 @@ static int cpufreq_parse_policy(char input_string[42], struct cpufreq_policy *po ...@@ -119,8 +119,8 @@ static int cpufreq_parse_policy(char input_string[42], struct cpufreq_policy *po
if (sscanf(input_string, "%d%%%d%%%d%%%s", &cpu, &min, &max, policy_string) == 4) if (sscanf(input_string, "%d%%%d%%%d%%%s", &cpu, &min, &max, policy_string) == 4)
{ {
if (!cpufreq_get_policy(&current_policy, cpu)) { if (!cpufreq_get_policy(&current_policy, cpu)) {
policy->min = (min * current_policy.max_cpu_freq) / 100; policy->min = (min * current_policy.cpuinfo.max_freq) / 100;
policy->max = (max * current_policy.max_cpu_freq) / 100; policy->max = (max * current_policy.cpuinfo.max_freq) / 100;
policy->cpu = cpu; policy->cpu = cpu;
result = 0; result = 0;
goto scan_policy; goto scan_policy;
...@@ -138,8 +138,8 @@ static int cpufreq_parse_policy(char input_string[42], struct cpufreq_policy *po ...@@ -138,8 +138,8 @@ static int cpufreq_parse_policy(char input_string[42], struct cpufreq_policy *po
if (sscanf(input_string, "%d%%%d%%%s", &min, &max, policy_string) == 3) if (sscanf(input_string, "%d%%%d%%%s", &min, &max, policy_string) == 3)
{ {
if (!cpufreq_get_policy(&current_policy, cpu)) { if (!cpufreq_get_policy(&current_policy, cpu)) {
policy->min = (min * current_policy.max_cpu_freq) / 100; policy->min = (min * current_policy.cpuinfo.max_freq) / 100;
policy->max = (max * current_policy.max_cpu_freq) / 100; policy->max = (max * current_policy.cpuinfo.max_freq) / 100;
result = 0; result = 0;
goto scan_policy; goto scan_policy;
} }
...@@ -229,11 +229,11 @@ static int cpufreq_proc_read ( ...@@ -229,11 +229,11 @@ static int cpufreq_proc_read (
cpufreq_get_policy(&policy, i); cpufreq_get_policy(&policy, i);
if (!policy.max_cpu_freq) if (!policy.cpuinfo.max_freq)
continue; continue;
min_pctg = (policy.min * 100) / policy.max_cpu_freq; min_pctg = (policy.min * 100) / policy.cpuinfo.max_freq;
max_pctg = (policy.max * 100) / policy.max_cpu_freq; max_pctg = (policy.max * 100) / policy.cpuinfo.max_freq;
p += sprintf(p, "CPU%3d %9d kHz (%3d %%) - %9d kHz (%3d %%) - ", p += sprintf(p, "CPU%3d %9d kHz (%3d %%) - %9d kHz (%3d %%) - ",
i , policy.min, min_pctg, policy.max, max_pctg); i , policy.min, min_pctg, policy.max, max_pctg);
...@@ -279,6 +279,7 @@ static int cpufreq_proc_write ( ...@@ -279,6 +279,7 @@ static int cpufreq_proc_write (
int result = 0; int result = 0;
char proc_string[42] = {'\0'}; char proc_string[42] = {'\0'};
struct cpufreq_policy policy; struct cpufreq_policy policy;
unsigned int i = 0;
if ((count > sizeof(proc_string) - 1)) if ((count > sizeof(proc_string) - 1))
...@@ -293,7 +294,17 @@ static int cpufreq_proc_write ( ...@@ -293,7 +294,17 @@ static int cpufreq_proc_write (
if (result) if (result)
return -EFAULT; return -EFAULT;
cpufreq_set_policy(&policy); if (policy.cpu == CPUFREQ_ALL_CPUS)
{
for (i=0; i<NR_CPUS; i++)
{
policy.cpu = i;
if (cpu_online(i))
cpufreq_set_policy(&policy);
}
}
else
cpufreq_set_policy(&policy);
return count; return count;
} }
...@@ -811,7 +822,9 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu) ...@@ -811,7 +822,9 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu)
policy->min = cpufreq_driver->policy[cpu].min; policy->min = cpufreq_driver->policy[cpu].min;
policy->max = cpufreq_driver->policy[cpu].max; policy->max = cpufreq_driver->policy[cpu].max;
policy->policy = cpufreq_driver->policy[cpu].policy; policy->policy = cpufreq_driver->policy[cpu].policy;
policy->max_cpu_freq = cpufreq_driver->policy[cpu].max_cpu_freq; policy->cpuinfo.max_freq = cpufreq_driver->policy[cpu].cpuinfo.max_freq;
policy->cpuinfo.min_freq = cpufreq_driver->policy[cpu].cpuinfo.min_freq;
policy->cpuinfo.transition_latency = cpufreq_driver->policy[cpu].cpuinfo.transition_latency;
policy->cpu = cpu; policy->cpu = cpu;
up(&cpufreq_driver_sem); up(&cpufreq_driver_sem);
...@@ -835,16 +848,14 @@ int cpufreq_set_policy(struct cpufreq_policy *policy) ...@@ -835,16 +848,14 @@ int cpufreq_set_policy(struct cpufreq_policy *policy)
down(&cpufreq_driver_sem); down(&cpufreq_driver_sem);
if (!cpufreq_driver || !cpufreq_driver->verify || if (!cpufreq_driver || !cpufreq_driver->verify ||
!cpufreq_driver->setpolicy || !policy || !cpufreq_driver->setpolicy || !policy ||
(policy->cpu > NR_CPUS)) { (policy->cpu >= NR_CPUS) || (!cpu_online(policy->cpu))) {
up(&cpufreq_driver_sem); up(&cpufreq_driver_sem);
return -EINVAL; return -EINVAL;
} }
if (policy->cpu == CPUFREQ_ALL_CPUS) policy->cpuinfo.max_freq = cpufreq_driver->policy[policy->cpu].cpuinfo.max_freq;
policy->max_cpu_freq = cpufreq_driver->policy[0].max_cpu_freq; policy->cpuinfo.min_freq = cpufreq_driver->policy[policy->cpu].cpuinfo.min_freq;
else policy->cpuinfo.transition_latency = cpufreq_driver->policy[policy->cpu].cpuinfo.transition_latency;
policy->max_cpu_freq = cpufreq_driver->policy[policy->cpu].max_cpu_freq;
/* verify the cpu speed can be set within this limit */ /* verify the cpu speed can be set within this limit */
ret = cpufreq_driver->verify(policy); ret = cpufreq_driver->verify(policy);
...@@ -1039,8 +1050,8 @@ int cpufreq_register(struct cpufreq_driver *driver_data) ...@@ -1039,8 +1050,8 @@ int cpufreq_register(struct cpufreq_driver *driver_data)
down(&cpufreq_driver_sem); down(&cpufreq_driver_sem);
for (i=0; i<NR_CPUS; i++) for (i=0; i<NR_CPUS; i++)
{ {
cpu_min_freq[i] = driver_data->cpu_min_freq[i]; cpu_min_freq[i] = driver_data->policy[i].cpuinfo.min_freq;
cpu_max_freq[i] = driver_data->policy[i].max_cpu_freq; cpu_max_freq[i] = driver_data->policy[i].cpuinfo.max_freq;
cpu_cur_freq[i] = driver_data->cpu_cur_freq[i]; cpu_cur_freq[i] = driver_data->cpu_cur_freq[i];
} }
up(&cpufreq_driver_sem); up(&cpufreq_driver_sem);
......
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