]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/cpufreq/cpufreq_conservative.c
Pull novell-bugzilla-156426 into release branch
[linux-2.6-omap-h63xx.git] / drivers / cpufreq / cpufreq_conservative.c
index 7498f2506adeaa2cffe379509786a24fd8049714..e07a35487bde7cf5b713c0c203a4819a537ae901 100644 (file)
@@ -65,6 +65,8 @@ struct cpu_dbs_info_s {
        unsigned int            prev_cpu_idle_up;
        unsigned int            prev_cpu_idle_down;
        unsigned int            enable;
+       unsigned int            down_skip;
+       unsigned int            requested_freq;
 };
 static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info);
 
@@ -86,6 +88,8 @@ static struct dbs_tuners dbs_tuners_ins = {
        .up_threshold           = DEF_FREQUENCY_UP_THRESHOLD,
        .down_threshold         = DEF_FREQUENCY_DOWN_THRESHOLD,
        .sampling_down_factor   = DEF_SAMPLING_DOWN_FACTOR,
+       .ignore_nice            = 0,
+       .freq_step              = 5,
 };
 
 static inline unsigned int get_cpu_idle_time(unsigned int cpu)
@@ -172,8 +176,7 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused,
        ret = sscanf (buf, "%u", &input);
 
        mutex_lock(&dbs_mutex);
-       if (ret != 1 || input > 100 || input < 0 ||
-                       input <= dbs_tuners_ins.down_threshold) {
+       if (ret != 1 || input > 100 || input <= dbs_tuners_ins.down_threshold) {
                mutex_unlock(&dbs_mutex);
                return -EINVAL;
        }
@@ -192,8 +195,7 @@ static ssize_t store_down_threshold(struct cpufreq_policy *unused,
        ret = sscanf (buf, "%u", &input);
 
        mutex_lock(&dbs_mutex);
-       if (ret != 1 || input > 100 || input < 0 ||
-                       input >= dbs_tuners_ins.up_threshold) {
+       if (ret != 1 || input > 100 || input >= dbs_tuners_ins.up_threshold) {
                mutex_unlock(&dbs_mutex);
                return -EINVAL;
        }
@@ -297,35 +299,12 @@ static void dbs_check_cpu(int cpu)
        unsigned int tmp_idle_ticks, total_idle_ticks;
        unsigned int freq_step;
        unsigned int freq_down_sampling_rate;
-       static unsigned short down_skip[NR_CPUS];
-       static unsigned int requested_freq[NR_CPUS];
-       static unsigned int init_flag = NR_CPUS;
        struct cpu_dbs_info_s *this_dbs_info = &per_cpu(cpu_dbs_info, cpu);
        struct cpufreq_policy *policy;
 
        if (!this_dbs_info->enable)
                return;
 
-       if ( init_flag != 0 ) {
-               for_each_cpu(init_flag) {
-                       down_skip[init_flag] = 0;
-                       /* I doubt a CPU exists with a freq of 0hz :) */
-                       requested_freq[init_flag] = 0;
-               }
-               init_flag = 0;
-       }
-       
-       /*
-        * If its a freshly initialised cpu we setup requested_freq.  This
-        * check could be avoided if we did not care about a first time
-        * stunted increase in CPU speed when there is a load.  I feel we
-        * should be initialising this to something.  The removal of a CPU
-        * is not a problem, after a short time the CPU should settle down
-        * to a 'natural' frequency.
-        */
-       if (requested_freq[cpu] == 0)
-               requested_freq[cpu] = this_dbs_info->cur_policy->cur;
-
        policy = this_dbs_info->cur_policy;
 
        /* 
@@ -360,12 +339,12 @@ static void dbs_check_cpu(int cpu)
                        usecs_to_jiffies(dbs_tuners_ins.sampling_rate);
 
        if (idle_ticks < up_idle_ticks) {
-               down_skip[cpu] = 0;
+               this_dbs_info->down_skip = 0;
                this_dbs_info->prev_cpu_idle_down =
                        this_dbs_info->prev_cpu_idle_up;
 
                /* if we are already at full speed then break out early */
-               if (requested_freq[cpu] == policy->max)
+               if (this_dbs_info->requested_freq == policy->max)
                        return;
                
                freq_step = (dbs_tuners_ins.freq_step * policy->max) / 100;
@@ -374,18 +353,18 @@ static void dbs_check_cpu(int cpu)
                if (unlikely(freq_step == 0))
                        freq_step = 5;
                
-               requested_freq[cpu] += freq_step;
-               if (requested_freq[cpu] > policy->max)
-                       requested_freq[cpu] = policy->max;
+               this_dbs_info->requested_freq += freq_step;
+               if (this_dbs_info->requested_freq > policy->max)
+                       this_dbs_info->requested_freq = policy->max;
 
-               __cpufreq_driver_target(policy, requested_freq[cpu], 
+               __cpufreq_driver_target(policy, this_dbs_info->requested_freq,
                        CPUFREQ_RELATION_H);
                return;
        }
 
        /* Check for frequency decrease */
-       down_skip[cpu]++;
-       if (down_skip[cpu] < dbs_tuners_ins.sampling_down_factor)
+       this_dbs_info->down_skip++;
+       if (this_dbs_info->down_skip < dbs_tuners_ins.sampling_down_factor)
                return;
 
        /* Check for frequency decrease */
@@ -399,7 +378,7 @@ static void dbs_check_cpu(int cpu)
 
        /* Scale idle ticks by 100 and compare with up and down ticks */
        idle_ticks *= 100;
-       down_skip[cpu] = 0;
+       this_dbs_info->down_skip = 0;
 
        freq_down_sampling_rate = dbs_tuners_ins.sampling_rate *
                dbs_tuners_ins.sampling_down_factor;
@@ -412,7 +391,7 @@ static void dbs_check_cpu(int cpu)
                 * or if we 'cannot' reduce the speed as the user might want
                 * freq_step to be zero
                 */
-               if (requested_freq[cpu] == policy->min
+               if (this_dbs_info->requested_freq == policy->min
                                || dbs_tuners_ins.freq_step == 0)
                        return;
 
@@ -422,11 +401,11 @@ static void dbs_check_cpu(int cpu)
                if (unlikely(freq_step == 0))
                        freq_step = 5;
 
-               requested_freq[cpu] -= freq_step;
-               if (requested_freq[cpu] < policy->min)
-                       requested_freq[cpu] = policy->min;
+               this_dbs_info->requested_freq -= freq_step;
+               if (this_dbs_info->requested_freq < policy->min)
+                       this_dbs_info->requested_freq = policy->min;
 
-               __cpufreq_driver_target(policy, requested_freq[cpu],
+               __cpufreq_driver_target(policy, this_dbs_info->requested_freq,
                                CPUFREQ_RELATION_H);
                return;
        }
@@ -489,6 +468,8 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
                                = j_dbs_info->prev_cpu_idle_up;
                }
                this_dbs_info->enable = 1;
+               this_dbs_info->down_skip = 0;
+               this_dbs_info->requested_freq = policy->cur;
                sysfs_create_group(&policy->kobj, &dbs_attr_group);
                dbs_enable++;
                /*
@@ -509,8 +490,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
                                def_sampling_rate = MIN_STAT_SAMPLING_RATE;
 
                        dbs_tuners_ins.sampling_rate = def_sampling_rate;
-                       dbs_tuners_ins.ignore_nice = 0;
-                       dbs_tuners_ins.freq_step = 5;
 
                        dbs_timer_init();
                }