Commit 7f6c69dc authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq

* git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq:
  [CPUFREQ] Make acpi-cpufreq more robust against BIOS freq changes behind our back.
  [CPUFREQ] change cpu freq tables to per_cpu variables
  [CPUFREQ] fix show_trans_table
  [CPUFREQ] Warn when cpufreq_register_notifier called before pure initcalls
  [CPUFREQ] Refactor locking in cpufreq_add_dev
  [CPUFREQ] more CodingStyle
  [CPUFREQ] CodingStyle
  [CPUFREQ] Slightly shorten the error paths of cpufreq_suspend/cpufreq_resume
parents 1e5ad9a3 e56a727b
...@@ -339,6 +339,7 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu) ...@@ -339,6 +339,7 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
{ {
struct acpi_cpufreq_data *data = per_cpu(drv_data, cpu); struct acpi_cpufreq_data *data = per_cpu(drv_data, cpu);
unsigned int freq; unsigned int freq;
unsigned int cached_freq;
dprintk("get_cur_freq_on_cpu (%d)\n", cpu); dprintk("get_cur_freq_on_cpu (%d)\n", cpu);
...@@ -347,7 +348,16 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu) ...@@ -347,7 +348,16 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
return 0; return 0;
} }
cached_freq = data->freq_table[data->acpi_data->state].frequency;
freq = extract_freq(get_cur_val(&cpumask_of_cpu(cpu)), data); freq = extract_freq(get_cur_val(&cpumask_of_cpu(cpu)), data);
if (freq != cached_freq) {
/*
* The dreaded BIOS frequency change behind our back.
* Force set the frequency on next target call.
*/
data->resume = 1;
}
dprintk("cur freq = %u\n", freq); dprintk("cur freq = %u\n", freq);
return freq; return freq;
......
...@@ -97,7 +97,7 @@ static int acpi_processor_apply_limit(struct acpi_processor *pr) ...@@ -97,7 +97,7 @@ static int acpi_processor_apply_limit(struct acpi_processor *pr)
#define CPUFREQ_THERMAL_MIN_STEP 0 #define CPUFREQ_THERMAL_MIN_STEP 0
#define CPUFREQ_THERMAL_MAX_STEP 3 #define CPUFREQ_THERMAL_MAX_STEP 3
static unsigned int cpufreq_thermal_reduction_pctg[NR_CPUS]; static DEFINE_PER_CPU(unsigned int, cpufreq_thermal_reduction_pctg);
static unsigned int acpi_thermal_cpufreq_is_init = 0; static unsigned int acpi_thermal_cpufreq_is_init = 0;
static int cpu_has_cpufreq(unsigned int cpu) static int cpu_has_cpufreq(unsigned int cpu)
...@@ -113,9 +113,9 @@ static int acpi_thermal_cpufreq_increase(unsigned int cpu) ...@@ -113,9 +113,9 @@ static int acpi_thermal_cpufreq_increase(unsigned int cpu)
if (!cpu_has_cpufreq(cpu)) if (!cpu_has_cpufreq(cpu))
return -ENODEV; return -ENODEV;
if (cpufreq_thermal_reduction_pctg[cpu] < if (per_cpu(cpufreq_thermal_reduction_pctg, cpu) <
CPUFREQ_THERMAL_MAX_STEP) { CPUFREQ_THERMAL_MAX_STEP) {
cpufreq_thermal_reduction_pctg[cpu]++; per_cpu(cpufreq_thermal_reduction_pctg, cpu)++;
cpufreq_update_policy(cpu); cpufreq_update_policy(cpu);
return 0; return 0;
} }
...@@ -128,14 +128,14 @@ static int acpi_thermal_cpufreq_decrease(unsigned int cpu) ...@@ -128,14 +128,14 @@ static int acpi_thermal_cpufreq_decrease(unsigned int cpu)
if (!cpu_has_cpufreq(cpu)) if (!cpu_has_cpufreq(cpu))
return -ENODEV; return -ENODEV;
if (cpufreq_thermal_reduction_pctg[cpu] > if (per_cpu(cpufreq_thermal_reduction_pctg, cpu) >
(CPUFREQ_THERMAL_MIN_STEP + 1)) (CPUFREQ_THERMAL_MIN_STEP + 1))
cpufreq_thermal_reduction_pctg[cpu]--; per_cpu(cpufreq_thermal_reduction_pctg, cpu)--;
else else
cpufreq_thermal_reduction_pctg[cpu] = 0; per_cpu(cpufreq_thermal_reduction_pctg, cpu) = 0;
cpufreq_update_policy(cpu); cpufreq_update_policy(cpu);
/* We reached max freq again and can leave passive mode */ /* We reached max freq again and can leave passive mode */
return !cpufreq_thermal_reduction_pctg[cpu]; return !per_cpu(cpufreq_thermal_reduction_pctg, cpu);
} }
static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb, static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb,
...@@ -147,9 +147,10 @@ static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb, ...@@ -147,9 +147,10 @@ static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb,
if (event != CPUFREQ_ADJUST) if (event != CPUFREQ_ADJUST)
goto out; goto out;
max_freq = max_freq = (
(policy->cpuinfo.max_freq * policy->cpuinfo.max_freq *
(100 - cpufreq_thermal_reduction_pctg[policy->cpu] * 20)) / 100; (100 - per_cpu(cpufreq_thermal_reduction_pctg, policy->cpu) * 20)
) / 100;
cpufreq_verify_within_limits(policy, 0, max_freq); cpufreq_verify_within_limits(policy, 0, max_freq);
...@@ -174,7 +175,7 @@ static int cpufreq_get_cur_state(unsigned int cpu) ...@@ -174,7 +175,7 @@ static int cpufreq_get_cur_state(unsigned int cpu)
if (!cpu_has_cpufreq(cpu)) if (!cpu_has_cpufreq(cpu))
return 0; return 0;
return cpufreq_thermal_reduction_pctg[cpu]; return per_cpu(cpufreq_thermal_reduction_pctg, cpu);
} }
static int cpufreq_set_cur_state(unsigned int cpu, int state) static int cpufreq_set_cur_state(unsigned int cpu, int state)
...@@ -182,7 +183,7 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state) ...@@ -182,7 +183,7 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state)
if (!cpu_has_cpufreq(cpu)) if (!cpu_has_cpufreq(cpu))
return 0; return 0;
cpufreq_thermal_reduction_pctg[cpu] = state; per_cpu(cpufreq_thermal_reduction_pctg, cpu) = state;
cpufreq_update_policy(cpu); cpufreq_update_policy(cpu);
return 0; return 0;
} }
...@@ -191,8 +192,9 @@ void acpi_thermal_cpufreq_init(void) ...@@ -191,8 +192,9 @@ void acpi_thermal_cpufreq_init(void)
{ {
int i; int i;
for (i = 0; i < NR_CPUS; i++) for (i = 0; i < nr_cpu_ids; i++)
cpufreq_thermal_reduction_pctg[i] = 0; if (cpu_present(i))
per_cpu(cpufreq_thermal_reduction_pctg, i) = 0;
i = cpufreq_register_notifier(&acpi_thermal_cpufreq_notifier_block, i = cpufreq_register_notifier(&acpi_thermal_cpufreq_notifier_block,
CPUFREQ_POLICY_NOTIFIER); CPUFREQ_POLICY_NOTIFIER);
......
This diff is collapsed.
...@@ -114,7 +114,7 @@ show_trans_table(struct cpufreq_policy *policy, char *buf) ...@@ -114,7 +114,7 @@ show_trans_table(struct cpufreq_policy *policy, char *buf)
stat->freq_table[i]); stat->freq_table[i]);
} }
if (len >= PAGE_SIZE) if (len >= PAGE_SIZE)
return len; return PAGE_SIZE;
len += snprintf(buf + len, PAGE_SIZE - len, "\n"); len += snprintf(buf + len, PAGE_SIZE - len, "\n");
...@@ -131,8 +131,12 @@ show_trans_table(struct cpufreq_policy *policy, char *buf) ...@@ -131,8 +131,12 @@ show_trans_table(struct cpufreq_policy *policy, char *buf)
len += snprintf(buf + len, PAGE_SIZE - len, "%9u ", len += snprintf(buf + len, PAGE_SIZE - len, "%9u ",
stat->trans_table[i*stat->max_state+j]); stat->trans_table[i*stat->max_state+j]);
} }
if (len >= PAGE_SIZE)
break;
len += snprintf(buf + len, PAGE_SIZE - len, "\n"); len += snprintf(buf + len, PAGE_SIZE - len, "\n");
} }
if (len >= PAGE_SIZE)
return PAGE_SIZE;
return len; return len;
} }
CPUFREQ_STATDEVICE_ATTR(trans_table,0444,show_trans_table); CPUFREQ_STATDEVICE_ATTR(trans_table,0444,show_trans_table);
......
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