Commit dad2ad82 authored by Linus Torvalds's avatar Linus Torvalds

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

parents 7079060f b7fb358c
...@@ -377,10 +377,9 @@ acpi_cpufreq_cpu_init ( ...@@ -377,10 +377,9 @@ acpi_cpufreq_cpu_init (
arg0.buffer.length = 12; arg0.buffer.length = 12;
arg0.buffer.pointer = (u8 *) arg0_buf; arg0.buffer.pointer = (u8 *) arg0_buf;
data = kmalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL); data = kzalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL);
if (!data) if (!data)
return (-ENOMEM); return (-ENOMEM);
memset(data, 0, sizeof(struct cpufreq_acpi_io));
acpi_io_data[cpu] = data; acpi_io_data[cpu] = data;
......
...@@ -171,10 +171,9 @@ static int get_ranges (unsigned char *pst) ...@@ -171,10 +171,9 @@ static int get_ranges (unsigned char *pst)
unsigned int speed; unsigned int speed;
u8 fid, vid; u8 fid, vid;
powernow_table = kmalloc((sizeof(struct cpufreq_frequency_table) * (number_scales + 1)), GFP_KERNEL); powernow_table = kzalloc((sizeof(struct cpufreq_frequency_table) * (number_scales + 1)), GFP_KERNEL);
if (!powernow_table) if (!powernow_table)
return -ENOMEM; return -ENOMEM;
memset(powernow_table, 0, (sizeof(struct cpufreq_frequency_table) * (number_scales + 1)));
for (j=0 ; j < number_scales; j++) { for (j=0 ; j < number_scales; j++) {
fid = *pst++; fid = *pst++;
...@@ -305,16 +304,13 @@ static int powernow_acpi_init(void) ...@@ -305,16 +304,13 @@ static int powernow_acpi_init(void)
goto err0; goto err0;
} }
acpi_processor_perf = kmalloc(sizeof(struct acpi_processor_performance), acpi_processor_perf = kzalloc(sizeof(struct acpi_processor_performance),
GFP_KERNEL); GFP_KERNEL);
if (!acpi_processor_perf) { if (!acpi_processor_perf) {
retval = -ENOMEM; retval = -ENOMEM;
goto err0; goto err0;
} }
memset(acpi_processor_perf, 0, sizeof(struct acpi_processor_performance));
if (acpi_processor_register_performance(acpi_processor_perf, 0)) { if (acpi_processor_register_performance(acpi_processor_perf, 0)) {
retval = -EIO; retval = -EIO;
goto err1; goto err1;
...@@ -337,14 +333,12 @@ static int powernow_acpi_init(void) ...@@ -337,14 +333,12 @@ static int powernow_acpi_init(void)
goto err2; goto err2;
} }
powernow_table = kmalloc((number_scales + 1) * (sizeof(struct cpufreq_frequency_table)), GFP_KERNEL); powernow_table = kzalloc((number_scales + 1) * (sizeof(struct cpufreq_frequency_table)), GFP_KERNEL);
if (!powernow_table) { if (!powernow_table) {
retval = -ENOMEM; retval = -ENOMEM;
goto err2; goto err2;
} }
memset(powernow_table, 0, ((number_scales + 1) * sizeof(struct cpufreq_frequency_table)));
pc.val = (unsigned long) acpi_processor_perf->states[0].control; pc.val = (unsigned long) acpi_processor_perf->states[0].control;
for (i = 0; i < number_scales; i++) { for (i = 0; i < number_scales; i++) {
u8 fid, vid; u8 fid, vid;
......
...@@ -462,7 +462,6 @@ static int check_supported_cpu(unsigned int cpu) ...@@ -462,7 +462,6 @@ static int check_supported_cpu(unsigned int cpu)
oldmask = current->cpus_allowed; oldmask = current->cpus_allowed;
set_cpus_allowed(current, cpumask_of_cpu(cpu)); set_cpus_allowed(current, cpumask_of_cpu(cpu));
schedule();
if (smp_processor_id() != cpu) { if (smp_processor_id() != cpu) {
printk(KERN_ERR "limiting to cpu %u failed\n", cpu); printk(KERN_ERR "limiting to cpu %u failed\n", cpu);
...@@ -497,9 +496,7 @@ static int check_supported_cpu(unsigned int cpu) ...@@ -497,9 +496,7 @@ static int check_supported_cpu(unsigned int cpu)
out: out:
set_cpus_allowed(current, oldmask); set_cpus_allowed(current, oldmask);
schedule();
return rc; return rc;
} }
static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst, u8 maxvid) static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst, u8 maxvid)
...@@ -913,7 +910,6 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi ...@@ -913,7 +910,6 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
/* only run on specific CPU from here on */ /* only run on specific CPU from here on */
oldmask = current->cpus_allowed; oldmask = current->cpus_allowed;
set_cpus_allowed(current, cpumask_of_cpu(pol->cpu)); set_cpus_allowed(current, cpumask_of_cpu(pol->cpu));
schedule();
if (smp_processor_id() != pol->cpu) { if (smp_processor_id() != pol->cpu) {
printk(KERN_ERR "limiting to cpu %u failed\n", pol->cpu); printk(KERN_ERR "limiting to cpu %u failed\n", pol->cpu);
...@@ -968,8 +964,6 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi ...@@ -968,8 +964,6 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
err_out: err_out:
set_cpus_allowed(current, oldmask); set_cpus_allowed(current, oldmask);
schedule();
return ret; return ret;
} }
...@@ -991,12 +985,11 @@ static int __init powernowk8_cpu_init(struct cpufreq_policy *pol) ...@@ -991,12 +985,11 @@ static int __init powernowk8_cpu_init(struct cpufreq_policy *pol)
if (!check_supported_cpu(pol->cpu)) if (!check_supported_cpu(pol->cpu))
return -ENODEV; return -ENODEV;
data = kmalloc(sizeof(struct powernow_k8_data), GFP_KERNEL); data = kzalloc(sizeof(struct powernow_k8_data), GFP_KERNEL);
if (!data) { if (!data) {
printk(KERN_ERR PFX "unable to alloc powernow_k8_data"); printk(KERN_ERR PFX "unable to alloc powernow_k8_data");
return -ENOMEM; return -ENOMEM;
} }
memset(data,0,sizeof(struct powernow_k8_data));
data->cpu = pol->cpu; data->cpu = pol->cpu;
...@@ -1026,7 +1019,6 @@ static int __init powernowk8_cpu_init(struct cpufreq_policy *pol) ...@@ -1026,7 +1019,6 @@ static int __init powernowk8_cpu_init(struct cpufreq_policy *pol)
/* only run on specific CPU from here on */ /* only run on specific CPU from here on */
oldmask = current->cpus_allowed; oldmask = current->cpus_allowed;
set_cpus_allowed(current, cpumask_of_cpu(pol->cpu)); set_cpus_allowed(current, cpumask_of_cpu(pol->cpu));
schedule();
if (smp_processor_id() != pol->cpu) { if (smp_processor_id() != pol->cpu) {
printk(KERN_ERR "limiting to cpu %u failed\n", pol->cpu); printk(KERN_ERR "limiting to cpu %u failed\n", pol->cpu);
...@@ -1045,7 +1037,6 @@ static int __init powernowk8_cpu_init(struct cpufreq_policy *pol) ...@@ -1045,7 +1037,6 @@ static int __init powernowk8_cpu_init(struct cpufreq_policy *pol)
/* run on any CPU again */ /* run on any CPU again */
set_cpus_allowed(current, oldmask); set_cpus_allowed(current, oldmask);
schedule();
pol->governor = CPUFREQ_DEFAULT_GOVERNOR; pol->governor = CPUFREQ_DEFAULT_GOVERNOR;
pol->cpus = cpu_core_map[pol->cpu]; pol->cpus = cpu_core_map[pol->cpu];
...@@ -1080,7 +1071,6 @@ static int __init powernowk8_cpu_init(struct cpufreq_policy *pol) ...@@ -1080,7 +1071,6 @@ static int __init powernowk8_cpu_init(struct cpufreq_policy *pol)
err_out: err_out:
set_cpus_allowed(current, oldmask); set_cpus_allowed(current, oldmask);
schedule();
powernow_k8_cpu_exit_acpi(data); powernow_k8_cpu_exit_acpi(data);
kfree(data); kfree(data);
...@@ -1116,17 +1106,14 @@ static unsigned int powernowk8_get (unsigned int cpu) ...@@ -1116,17 +1106,14 @@ static unsigned int powernowk8_get (unsigned int cpu)
set_cpus_allowed(current, oldmask); set_cpus_allowed(current, oldmask);
return 0; return 0;
} }
preempt_disable();
if (query_current_values_with_pending_wait(data)) if (query_current_values_with_pending_wait(data))
goto out; goto out;
khz = find_khz_freq_from_fid(data->currfid); khz = find_khz_freq_from_fid(data->currfid);
out: out:
preempt_enable_no_resched();
set_cpus_allowed(current, oldmask); set_cpus_allowed(current, oldmask);
return khz; return khz;
} }
......
...@@ -423,12 +423,11 @@ static int centrino_cpu_init_acpi(struct cpufreq_policy *policy) ...@@ -423,12 +423,11 @@ static int centrino_cpu_init_acpi(struct cpufreq_policy *policy)
} }
} }
centrino_model[cpu] = kmalloc(sizeof(struct cpu_model), GFP_KERNEL); centrino_model[cpu] = kzalloc(sizeof(struct cpu_model), GFP_KERNEL);
if (!centrino_model[cpu]) { if (!centrino_model[cpu]) {
result = -ENOMEM; result = -ENOMEM;
goto err_unreg; goto err_unreg;
} }
memset(centrino_model[cpu], 0, sizeof(struct cpu_model));
centrino_model[cpu]->model_name=NULL; centrino_model[cpu]->model_name=NULL;
centrino_model[cpu]->max_freq = p.states[0].core_frequency * 1000; centrino_model[cpu]->max_freq = p.states[0].core_frequency * 1000;
......
...@@ -593,12 +593,11 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) ...@@ -593,12 +593,11 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
goto module_out; goto module_out;
} }
policy = kmalloc(sizeof(struct cpufreq_policy), GFP_KERNEL); policy = kzalloc(sizeof(struct cpufreq_policy), GFP_KERNEL);
if (!policy) { if (!policy) {
ret = -ENOMEM; ret = -ENOMEM;
goto nomem_out; goto nomem_out;
} }
memset(policy, 0, sizeof(struct cpufreq_policy));
policy->cpu = cpu; policy->cpu = cpu;
policy->cpus = cpumask_of_cpu(cpu); policy->cpus = cpumask_of_cpu(cpu);
......
...@@ -48,7 +48,10 @@ ...@@ -48,7 +48,10 @@
* All times here are in uS. * All times here are in uS.
*/ */
static unsigned int def_sampling_rate; static unsigned int def_sampling_rate;
#define MIN_SAMPLING_RATE (def_sampling_rate / 2) #define MIN_SAMPLING_RATE_RATIO (2)
/* for correct statistics, we need at least 10 ticks between each measure */
#define MIN_STAT_SAMPLING_RATE (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10))
#define MIN_SAMPLING_RATE (def_sampling_rate / MIN_SAMPLING_RATE_RATIO)
#define MAX_SAMPLING_RATE (500 * def_sampling_rate) #define MAX_SAMPLING_RATE (500 * def_sampling_rate)
#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) #define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000)
#define DEF_SAMPLING_DOWN_FACTOR (1) #define DEF_SAMPLING_DOWN_FACTOR (1)
...@@ -416,13 +419,16 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, ...@@ -416,13 +419,16 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
if (dbs_enable == 1) { if (dbs_enable == 1) {
unsigned int latency; unsigned int latency;
/* policy latency is in nS. Convert it to uS first */ /* policy latency is in nS. Convert it to uS first */
latency = policy->cpuinfo.transition_latency / 1000;
if (latency == 0)
latency = 1;
latency = policy->cpuinfo.transition_latency; def_sampling_rate = latency *
if (latency < 1000)
latency = 1000;
def_sampling_rate = (latency / 1000) *
DEF_SAMPLING_RATE_LATENCY_MULTIPLIER; DEF_SAMPLING_RATE_LATENCY_MULTIPLIER;
if (def_sampling_rate < MIN_STAT_SAMPLING_RATE)
def_sampling_rate = MIN_STAT_SAMPLING_RATE;
dbs_tuners_ins.sampling_rate = def_sampling_rate; dbs_tuners_ins.sampling_rate = def_sampling_rate;
dbs_tuners_ins.ignore_nice = 0; dbs_tuners_ins.ignore_nice = 0;
......
...@@ -193,11 +193,15 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy, ...@@ -193,11 +193,15 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
unsigned int cpu = policy->cpu; unsigned int cpu = policy->cpu;
if (cpufreq_stats_table[cpu]) if (cpufreq_stats_table[cpu])
return -EBUSY; return -EBUSY;
if ((stat = kmalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL) if ((stat = kzalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
memset(stat, 0, sizeof (struct cpufreq_stats));
data = cpufreq_cpu_get(cpu); data = cpufreq_cpu_get(cpu);
if (data == NULL) {
ret = -EINVAL;
goto error_get_fail;
}
if ((ret = sysfs_create_group(&data->kobj, &stats_attr_group))) if ((ret = sysfs_create_group(&data->kobj, &stats_attr_group)))
goto error_out; goto error_out;
...@@ -217,12 +221,11 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy, ...@@ -217,12 +221,11 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
alloc_size += count * count * sizeof(int); alloc_size += count * count * sizeof(int);
#endif #endif
stat->max_state = count; stat->max_state = count;
stat->time_in_state = kmalloc(alloc_size, GFP_KERNEL); stat->time_in_state = kzalloc(alloc_size, GFP_KERNEL);
if (!stat->time_in_state) { if (!stat->time_in_state) {
ret = -ENOMEM; ret = -ENOMEM;
goto error_out; goto error_out;
} }
memset(stat->time_in_state, 0, alloc_size);
stat->freq_table = (unsigned int *)(stat->time_in_state + count); stat->freq_table = (unsigned int *)(stat->time_in_state + count);
#ifdef CONFIG_CPU_FREQ_STAT_DETAILS #ifdef CONFIG_CPU_FREQ_STAT_DETAILS
...@@ -245,6 +248,7 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy, ...@@ -245,6 +248,7 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
return 0; return 0;
error_out: error_out:
cpufreq_cpu_put(data); cpufreq_cpu_put(data);
error_get_fail:
kfree(stat); kfree(stat);
cpufreq_stats_table[cpu] = NULL; cpufreq_stats_table[cpu] = NULL;
return ret; return ret;
......
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