]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/cpufreq/cpufreq_ondemand.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild
[linux-2.6-omap-h63xx.git] / drivers / cpufreq / cpufreq_ondemand.c
index c1fc9c62bb51d0c1d2620f522d7c6ebbb0f432bc..e69fd8dd1f1cb7bf6042a878b2545a714c7df133 100644 (file)
  * All times here are in uS.
  */
 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 DEF_SAMPLING_RATE_LATENCY_MULTIPLIER   (1000)
 #define DEF_SAMPLING_DOWN_FACTOR               (1)
@@ -86,7 +89,7 @@ static inline unsigned int get_cpu_idle_time(unsigned int cpu)
 {
        return  kstat_cpu(cpu).cpustat.idle +
                kstat_cpu(cpu).cpustat.iowait +
-               ( !dbs_tuners_ins.ignore_nice ? 
+               ( dbs_tuners_ins.ignore_nice ?
                  kstat_cpu(cpu).cpustat.nice :
                  0);
 }
@@ -119,7 +122,7 @@ static ssize_t show_##file_name                                             \
 show_one(sampling_rate, sampling_rate);
 show_one(sampling_down_factor, sampling_down_factor);
 show_one(up_threshold, up_threshold);
-show_one(ignore_nice, ignore_nice);
+show_one(ignore_nice_load, ignore_nice);
 
 static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, 
                const char *buf, size_t count)
@@ -179,7 +182,7 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused,
        return count;
 }
 
-static ssize_t store_ignore_nice(struct cpufreq_policy *policy,
+static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
                const char *buf, size_t count)
 {
        unsigned int input;
@@ -220,7 +223,7 @@ __ATTR(_name, 0644, show_##_name, store_##_name)
 define_one_rw(sampling_rate);
 define_one_rw(sampling_down_factor);
 define_one_rw(up_threshold);
-define_one_rw(ignore_nice);
+define_one_rw(ignore_nice_load);
 
 static struct attribute * dbs_attributes[] = {
        &sampling_rate_max.attr,
@@ -228,7 +231,7 @@ static struct attribute * dbs_attributes[] = {
        &sampling_rate.attr,
        &sampling_down_factor.attr,
        &up_threshold.attr,
-       &ignore_nice.attr,
+       &ignore_nice_load.attr,
        NULL
 };
 
@@ -416,13 +419,16 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
                if (dbs_enable == 1) {
                        unsigned int latency;
                        /* 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;
-                       if (latency < 1000)
-                               latency = 1000;
-
-                       def_sampling_rate = (latency / 1000) *
+                       def_sampling_rate = latency *
                                        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.ignore_nice = 0;