aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c7
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c28
2 files changed, 20 insertions, 15 deletions
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index c4c578defabf..5ef5ede5b884 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -59,7 +59,7 @@ static unsigned int def_sampling_rate;
59#define MAX_SAMPLING_DOWN_FACTOR (10) 59#define MAX_SAMPLING_DOWN_FACTOR (10)
60#define TRANSITION_LATENCY_LIMIT (10 * 1000) 60#define TRANSITION_LATENCY_LIMIT (10 * 1000)
61 61
62static void do_dbs_timer(void *data); 62static void do_dbs_timer(struct work_struct *work);
63 63
64struct cpu_dbs_info_s { 64struct cpu_dbs_info_s {
65 struct cpufreq_policy *cur_policy; 65 struct cpufreq_policy *cur_policy;
@@ -82,7 +82,7 @@ static unsigned int dbs_enable; /* number of CPUs using this policy */
82 * is recursive for the same process. -Venki 82 * is recursive for the same process. -Venki
83 */ 83 */
84static DEFINE_MUTEX (dbs_mutex); 84static DEFINE_MUTEX (dbs_mutex);
85static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); 85static DECLARE_DELAYED_WORK(dbs_work, do_dbs_timer);
86 86
87struct dbs_tuners { 87struct dbs_tuners {
88 unsigned int sampling_rate; 88 unsigned int sampling_rate;
@@ -420,7 +420,7 @@ static void dbs_check_cpu(int cpu)
420 } 420 }
421} 421}
422 422
423static void do_dbs_timer(void *data) 423static void do_dbs_timer(struct work_struct *work)
424{ 424{
425 int i; 425 int i;
426 lock_cpu_hotplug(); 426 lock_cpu_hotplug();
@@ -435,7 +435,6 @@ static void do_dbs_timer(void *data)
435 435
436static inline void dbs_timer_init(void) 436static inline void dbs_timer_init(void)
437{ 437{
438 INIT_WORK(&dbs_work, do_dbs_timer, NULL);
439 schedule_delayed_work(&dbs_work, 438 schedule_delayed_work(&dbs_work,
440 usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); 439 usecs_to_jiffies(dbs_tuners_ins.sampling_rate));
441 return; 440 return;
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index bf8aa45d4f01..e1cc5113c2ae 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -47,13 +47,17 @@ static unsigned int def_sampling_rate;
47#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) 47#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000)
48#define TRANSITION_LATENCY_LIMIT (10 * 1000) 48#define TRANSITION_LATENCY_LIMIT (10 * 1000)
49 49
50static void do_dbs_timer(void *data); 50static void do_dbs_timer(struct work_struct *work);
51
52/* Sampling types */
53enum dbs_sample {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE};
51 54
52struct cpu_dbs_info_s { 55struct cpu_dbs_info_s {
53 cputime64_t prev_cpu_idle; 56 cputime64_t prev_cpu_idle;
54 cputime64_t prev_cpu_wall; 57 cputime64_t prev_cpu_wall;
55 struct cpufreq_policy *cur_policy; 58 struct cpufreq_policy *cur_policy;
56 struct work_struct work; 59 struct delayed_work work;
60 enum dbs_sample sample_type;
57 unsigned int enable; 61 unsigned int enable;
58 struct cpufreq_frequency_table *freq_table; 62 struct cpufreq_frequency_table *freq_table;
59 unsigned int freq_lo; 63 unsigned int freq_lo;
@@ -407,30 +411,31 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
407 } 411 }
408} 412}
409 413
410/* Sampling types */ 414static void do_dbs_timer(struct work_struct *work)
411enum {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE};
412
413static void do_dbs_timer(void *data)
414{ 415{
415 unsigned int cpu = smp_processor_id(); 416 unsigned int cpu = smp_processor_id();
416 struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu); 417 struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu);
418 enum dbs_sample sample_type = dbs_info->sample_type;
417 /* We want all CPUs to do sampling nearly on same jiffy */ 419 /* We want all CPUs to do sampling nearly on same jiffy */
418 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate); 420 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate);
421
422 /* Permit rescheduling of this work item */
423 work_release(work);
424
419 delay -= jiffies % delay; 425 delay -= jiffies % delay;
420 426
421 if (!dbs_info->enable) 427 if (!dbs_info->enable)
422 return; 428 return;
423 /* Common NORMAL_SAMPLE setup */ 429 /* Common NORMAL_SAMPLE setup */
424 INIT_WORK(&dbs_info->work, do_dbs_timer, (void *)DBS_NORMAL_SAMPLE); 430 dbs_info->sample_type = DBS_NORMAL_SAMPLE;
425 if (!dbs_tuners_ins.powersave_bias || 431 if (!dbs_tuners_ins.powersave_bias ||
426 (unsigned long) data == DBS_NORMAL_SAMPLE) { 432 sample_type == DBS_NORMAL_SAMPLE) {
427 lock_cpu_hotplug(); 433 lock_cpu_hotplug();
428 dbs_check_cpu(dbs_info); 434 dbs_check_cpu(dbs_info);
429 unlock_cpu_hotplug(); 435 unlock_cpu_hotplug();
430 if (dbs_info->freq_lo) { 436 if (dbs_info->freq_lo) {
431 /* Setup timer for SUB_SAMPLE */ 437 /* Setup timer for SUB_SAMPLE */
432 INIT_WORK(&dbs_info->work, do_dbs_timer, 438 dbs_info->sample_type = DBS_SUB_SAMPLE;
433 (void *)DBS_SUB_SAMPLE);
434 delay = dbs_info->freq_hi_jiffies; 439 delay = dbs_info->freq_hi_jiffies;
435 } 440 }
436 } else { 441 } else {
@@ -449,7 +454,8 @@ static inline void dbs_timer_init(unsigned int cpu)
449 delay -= jiffies % delay; 454 delay -= jiffies % delay;
450 455
451 ondemand_powersave_bias_init(); 456 ondemand_powersave_bias_init();
452 INIT_WORK(&dbs_info->work, do_dbs_timer, NULL); 457 INIT_DELAYED_WORK_NAR(&dbs_info->work, do_dbs_timer);
458 dbs_info->sample_type = DBS_NORMAL_SAMPLE;
453 queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay); 459 queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay);
454} 460}
455 461