CPUFREQ: PORT FROM R2: expose DOWN_DIFFERENTIAL via sysfs
authorFei Yang <fei.yang@intel.com>
Mon, 6 Feb 2012 22:04:10 +0000 (14:04 -0800)
committerbuildbot <buildbot@intel.com>
Thu, 9 Feb 2012 22:30:27 +0000 (14:30 -0800)
BZ: 22582

Expose down_differential through sysfs for experiment with CPU freq
using different workload.

Change-Id: Ic0f4cf55a6a641b42aeed77101d51bb7298c8b73
Signed-off-by: Winson Yung <winson.w.yung@intel.com>
Signed-off-by: Fei Yang <fei.yang@intel.com>
Reviewed-on: http://android.intel.com:8080/34161
Reviewed-by: Gross, Mark <mark.gross@intel.com>
Tested-by: Ng, Cheon-woei <cheon-woei.ng@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
drivers/cpufreq/cpufreq_ondemand.c

index 891360e..0c5a16a 100644 (file)
@@ -37,6 +37,8 @@
 #define MICRO_FREQUENCY_MIN_SAMPLE_RATE                (10000)
 #define MIN_FREQUENCY_UP_THRESHOLD             (11)
 #define MAX_FREQUENCY_UP_THRESHOLD             (100)
+#define MAX_FREQUENCY_DOWN_DIFFERENTIAL                (30)
+#define MIN_FREQUENCY_DOWN_DIFFERENTIAL        MICRO_FREQUENCY_DOWN_DIFFERENTIAL
 
 /*
  * The polling frequency of this governor depends on the capability of
@@ -255,6 +257,7 @@ show_one(up_threshold, up_threshold);
 show_one(sampling_down_factor, sampling_down_factor);
 show_one(ignore_nice_load, ignore_nice);
 show_one(powersave_bias, powersave_bias);
+show_one(down_differential, down_differential);
 
 static ssize_t store_sampling_rate(struct kobject *a, struct attribute *b,
                                   const char *buf, size_t count)
@@ -281,6 +284,25 @@ static ssize_t store_io_is_busy(struct kobject *a, struct attribute *b,
        return count;
 }
 
+static ssize_t store_down_differential(struct kobject *a, struct attribute *b,
+                                      const char *buf, size_t count)
+{
+       unsigned int input;
+       int ret = sscanf(buf, "%u", &input);
+
+       if (ret != 1 || input < MIN_FREQUENCY_DOWN_DIFFERENTIAL ||
+                       input > MAX_FREQUENCY_DOWN_DIFFERENTIAL ||
+                       input >= dbs_tuners_ins.up_threshold) {
+               return -EINVAL;
+       }
+
+       mutex_lock(&dbs_mutex);
+       dbs_tuners_ins.down_differential = input;
+       mutex_unlock(&dbs_mutex);
+
+       return count;
+}
+
 static ssize_t store_up_threshold(struct kobject *a, struct attribute *b,
                                  const char *buf, size_t count)
 {
@@ -373,12 +395,14 @@ define_one_global_rw(up_threshold);
 define_one_global_rw(sampling_down_factor);
 define_one_global_rw(ignore_nice_load);
 define_one_global_rw(powersave_bias);
+define_one_global_rw(down_differential);
 
 static struct attribute *dbs_attributes[] = {
        &sampling_rate_min.attr,
        &sampling_rate.attr,
        &up_threshold.attr,
        &sampling_down_factor.attr,
+       &down_differential.attr,
        &ignore_nice_load.attr,
        &powersave_bias.attr,
        &io_is_busy.attr,