aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-11-07 16:28:20 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-07 16:28:20 -0500
commitdad2ad82c5f058367df79de022bd12d36afcd065 (patch)
tree426a1a6ca8762356b375527768bedc2de0bd25e9 /drivers
parent7079060f3e86ea4c1d4e9c1e356592ef9dcaaa1f (diff)
parentb7fb358c7c36a14927d5523ea674e69f90c51d1d (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
Diffstat (limited to 'drivers')
-rw-r--r--drivers/cpufreq/cpufreq.c3
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c18
-rw-r--r--drivers/cpufreq/cpufreq_stats.c12
3 files changed, 21 insertions, 12 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 6c6121b85a54..25acf478c9e8 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -593,12 +593,11 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
593 goto module_out; 593 goto module_out;
594 } 594 }
595 595
596 policy = kmalloc(sizeof(struct cpufreq_policy), GFP_KERNEL); 596 policy = kzalloc(sizeof(struct cpufreq_policy), GFP_KERNEL);
597 if (!policy) { 597 if (!policy) {
598 ret = -ENOMEM; 598 ret = -ENOMEM;
599 goto nomem_out; 599 goto nomem_out;
600 } 600 }
601 memset(policy, 0, sizeof(struct cpufreq_policy));
602 601
603 policy->cpu = cpu; 602 policy->cpu = cpu;
604 policy->cpus = cpumask_of_cpu(cpu); 603 policy->cpus = cpumask_of_cpu(cpu);
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index c1fc9c62bb51..17741111246b 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -48,7 +48,10 @@
48 * All times here are in uS. 48 * All times here are in uS.
49 */ 49 */
50static unsigned int def_sampling_rate; 50static unsigned int def_sampling_rate;
51#define MIN_SAMPLING_RATE (def_sampling_rate / 2) 51#define MIN_SAMPLING_RATE_RATIO (2)
52/* for correct statistics, we need at least 10 ticks between each measure */
53#define MIN_STAT_SAMPLING_RATE (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10))
54#define MIN_SAMPLING_RATE (def_sampling_rate / MIN_SAMPLING_RATE_RATIO)
52#define MAX_SAMPLING_RATE (500 * def_sampling_rate) 55#define MAX_SAMPLING_RATE (500 * def_sampling_rate)
53#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) 56#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000)
54#define DEF_SAMPLING_DOWN_FACTOR (1) 57#define DEF_SAMPLING_DOWN_FACTOR (1)
@@ -416,13 +419,16 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
416 if (dbs_enable == 1) { 419 if (dbs_enable == 1) {
417 unsigned int latency; 420 unsigned int latency;
418 /* policy latency is in nS. Convert it to uS first */ 421 /* policy latency is in nS. Convert it to uS first */
422 latency = policy->cpuinfo.transition_latency / 1000;
423 if (latency == 0)
424 latency = 1;
419 425
420 latency = policy->cpuinfo.transition_latency; 426 def_sampling_rate = latency *
421 if (latency < 1000)
422 latency = 1000;
423
424 def_sampling_rate = (latency / 1000) *
425 DEF_SAMPLING_RATE_LATENCY_MULTIPLIER; 427 DEF_SAMPLING_RATE_LATENCY_MULTIPLIER;
428
429 if (def_sampling_rate < MIN_STAT_SAMPLING_RATE)
430 def_sampling_rate = MIN_STAT_SAMPLING_RATE;
431
426 dbs_tuners_ins.sampling_rate = def_sampling_rate; 432 dbs_tuners_ins.sampling_rate = def_sampling_rate;
427 dbs_tuners_ins.ignore_nice = 0; 433 dbs_tuners_ins.ignore_nice = 0;
428 434
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 3597f25d5efa..0bddb8e694d9 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -193,11 +193,15 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
193 unsigned int cpu = policy->cpu; 193 unsigned int cpu = policy->cpu;
194 if (cpufreq_stats_table[cpu]) 194 if (cpufreq_stats_table[cpu])
195 return -EBUSY; 195 return -EBUSY;
196 if ((stat = kmalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL) 196 if ((stat = kzalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL)
197 return -ENOMEM; 197 return -ENOMEM;
198 memset(stat, 0, sizeof (struct cpufreq_stats));
199 198
200 data = cpufreq_cpu_get(cpu); 199 data = cpufreq_cpu_get(cpu);
200 if (data == NULL) {
201 ret = -EINVAL;
202 goto error_get_fail;
203 }
204
201 if ((ret = sysfs_create_group(&data->kobj, &stats_attr_group))) 205 if ((ret = sysfs_create_group(&data->kobj, &stats_attr_group)))
202 goto error_out; 206 goto error_out;
203 207
@@ -217,12 +221,11 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
217 alloc_size += count * count * sizeof(int); 221 alloc_size += count * count * sizeof(int);
218#endif 222#endif
219 stat->max_state = count; 223 stat->max_state = count;
220 stat->time_in_state = kmalloc(alloc_size, GFP_KERNEL); 224 stat->time_in_state = kzalloc(alloc_size, GFP_KERNEL);
221 if (!stat->time_in_state) { 225 if (!stat->time_in_state) {
222 ret = -ENOMEM; 226 ret = -ENOMEM;
223 goto error_out; 227 goto error_out;
224 } 228 }
225 memset(stat->time_in_state, 0, alloc_size);
226 stat->freq_table = (unsigned int *)(stat->time_in_state + count); 229 stat->freq_table = (unsigned int *)(stat->time_in_state + count);
227 230
228#ifdef CONFIG_CPU_FREQ_STAT_DETAILS 231#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
@@ -245,6 +248,7 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
245 return 0; 248 return 0;
246error_out: 249error_out:
247 cpufreq_cpu_put(data); 250 cpufreq_cpu_put(data);
251error_get_fail:
248 kfree(stat); 252 kfree(stat);
249 cpufreq_stats_table[cpu] = NULL; 253 cpufreq_stats_table[cpu] = NULL;
250 return ret; 254 return ret;