Commit 07aa4402 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

cpufreq: governor: Use microseconds in sample delay computations

Do not convert microseconds to jiffies and the other way around
in governor computations related to the sampling rate and sample
delay and drop delay_for_sampling_rate() which isn't of any use
then.
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
parent 6e96c5b3
...@@ -102,7 +102,7 @@ static unsigned int cs_dbs_timer(struct cpufreq_policy *policy) ...@@ -102,7 +102,7 @@ static unsigned int cs_dbs_timer(struct cpufreq_policy *policy)
} }
out: out:
return delay_for_sampling_rate(dbs_data->sampling_rate); return dbs_data->sampling_rate;
} }
static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val, static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
......
...@@ -282,7 +282,6 @@ static void dbs_work_handler(struct work_struct *work) ...@@ -282,7 +282,6 @@ static void dbs_work_handler(struct work_struct *work)
struct policy_dbs_info *policy_dbs; struct policy_dbs_info *policy_dbs;
struct cpufreq_policy *policy; struct cpufreq_policy *policy;
struct dbs_governor *gov; struct dbs_governor *gov;
unsigned int delay;
policy_dbs = container_of(work, struct policy_dbs_info, work); policy_dbs = container_of(work, struct policy_dbs_info, work);
policy = policy_dbs->policy; policy = policy_dbs->policy;
...@@ -293,8 +292,7 @@ static void dbs_work_handler(struct work_struct *work) ...@@ -293,8 +292,7 @@ static void dbs_work_handler(struct work_struct *work)
* ondemand governor isn't updating the sampling rate in parallel. * ondemand governor isn't updating the sampling rate in parallel.
*/ */
mutex_lock(&policy_dbs->timer_mutex); mutex_lock(&policy_dbs->timer_mutex);
delay = gov->gov_dbs_timer(policy); gov_update_sample_delay(policy_dbs, gov->gov_dbs_timer(policy));
policy_dbs->sample_delay_ns = jiffies_to_nsecs(delay);
mutex_unlock(&policy_dbs->timer_mutex); mutex_unlock(&policy_dbs->timer_mutex);
/* Allow the utilization update handler to queue up more work. */ /* Allow the utilization update handler to queue up more work. */
......
...@@ -163,8 +163,8 @@ struct od_cpu_dbs_info_s { ...@@ -163,8 +163,8 @@ struct od_cpu_dbs_info_s {
struct cpu_dbs_info cdbs; struct cpu_dbs_info cdbs;
struct cpufreq_frequency_table *freq_table; struct cpufreq_frequency_table *freq_table;
unsigned int freq_lo; unsigned int freq_lo;
unsigned int freq_lo_jiffies; unsigned int freq_lo_delay_us;
unsigned int freq_hi_jiffies; unsigned int freq_hi_delay_us;
unsigned int sample_type:1; unsigned int sample_type:1;
}; };
...@@ -223,17 +223,6 @@ struct od_ops { ...@@ -223,17 +223,6 @@ struct od_ops {
void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq); void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq);
}; };
static inline int delay_for_sampling_rate(unsigned int sampling_rate)
{
int delay = usecs_to_jiffies(sampling_rate);
/* We want all CPUs to do sampling nearly on same jiffy */
if (num_online_cpus() > 1)
delay -= jiffies % delay;
return delay;
}
extern struct mutex dbs_data_mutex; extern struct mutex dbs_data_mutex;
unsigned int dbs_update(struct cpufreq_policy *policy); unsigned int dbs_update(struct cpufreq_policy *policy);
int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event); int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event);
......
...@@ -66,8 +66,8 @@ static int should_io_be_busy(void) ...@@ -66,8 +66,8 @@ static int should_io_be_busy(void)
/* /*
* Find right freq to be set now with powersave_bias on. * Find right freq to be set now with powersave_bias on.
* Returns the freq_hi to be used right now and will set freq_hi_jiffies, * Returns the freq_hi to be used right now and will set freq_hi_delay_us,
* freq_lo, and freq_lo_jiffies in percpu area for averaging freqs. * freq_lo, and freq_lo_delay_us in percpu area for averaging freqs.
*/ */
static unsigned int generic_powersave_bias_target(struct cpufreq_policy *policy, static unsigned int generic_powersave_bias_target(struct cpufreq_policy *policy,
unsigned int freq_next, unsigned int relation) unsigned int freq_next, unsigned int relation)
...@@ -75,7 +75,7 @@ static unsigned int generic_powersave_bias_target(struct cpufreq_policy *policy, ...@@ -75,7 +75,7 @@ static unsigned int generic_powersave_bias_target(struct cpufreq_policy *policy,
unsigned int freq_req, freq_reduc, freq_avg; unsigned int freq_req, freq_reduc, freq_avg;
unsigned int freq_hi, freq_lo; unsigned int freq_hi, freq_lo;
unsigned int index = 0; unsigned int index = 0;
unsigned int jiffies_total, jiffies_hi, jiffies_lo; unsigned int delay_hi_us;
struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info,
policy->cpu); policy->cpu);
struct policy_dbs_info *policy_dbs = policy->governor_data; struct policy_dbs_info *policy_dbs = policy->governor_data;
...@@ -84,7 +84,7 @@ static unsigned int generic_powersave_bias_target(struct cpufreq_policy *policy, ...@@ -84,7 +84,7 @@ static unsigned int generic_powersave_bias_target(struct cpufreq_policy *policy,
if (!dbs_info->freq_table) { if (!dbs_info->freq_table) {
dbs_info->freq_lo = 0; dbs_info->freq_lo = 0;
dbs_info->freq_lo_jiffies = 0; dbs_info->freq_lo_delay_us = 0;
return freq_next; return freq_next;
} }
...@@ -107,17 +107,15 @@ static unsigned int generic_powersave_bias_target(struct cpufreq_policy *policy, ...@@ -107,17 +107,15 @@ static unsigned int generic_powersave_bias_target(struct cpufreq_policy *policy,
/* Find out how long we have to be in hi and lo freqs */ /* Find out how long we have to be in hi and lo freqs */
if (freq_hi == freq_lo) { if (freq_hi == freq_lo) {
dbs_info->freq_lo = 0; dbs_info->freq_lo = 0;
dbs_info->freq_lo_jiffies = 0; dbs_info->freq_lo_delay_us = 0;
return freq_lo; return freq_lo;
} }
jiffies_total = usecs_to_jiffies(dbs_data->sampling_rate); delay_hi_us = (freq_avg - freq_lo) * dbs_data->sampling_rate;
jiffies_hi = (freq_avg - freq_lo) * jiffies_total; delay_hi_us += (freq_hi - freq_lo) / 2;
jiffies_hi += ((freq_hi - freq_lo) / 2); delay_hi_us /= freq_hi - freq_lo;
jiffies_hi /= (freq_hi - freq_lo); dbs_info->freq_hi_delay_us = delay_hi_us;
jiffies_lo = jiffies_total - jiffies_hi;
dbs_info->freq_lo = freq_lo; dbs_info->freq_lo = freq_lo;
dbs_info->freq_lo_jiffies = jiffies_lo; dbs_info->freq_lo_delay_us = dbs_data->sampling_rate - delay_hi_us;
dbs_info->freq_hi_jiffies = jiffies_hi;
return freq_hi; return freq_hi;
} }
...@@ -205,7 +203,7 @@ static unsigned int od_dbs_timer(struct cpufreq_policy *policy) ...@@ -205,7 +203,7 @@ static unsigned int od_dbs_timer(struct cpufreq_policy *policy)
if (sample_type == OD_SUB_SAMPLE && policy_dbs->sample_delay_ns > 0) { if (sample_type == OD_SUB_SAMPLE && policy_dbs->sample_delay_ns > 0) {
__cpufreq_driver_target(policy, dbs_info->freq_lo, __cpufreq_driver_target(policy, dbs_info->freq_lo,
CPUFREQ_RELATION_H); CPUFREQ_RELATION_H);
return dbs_info->freq_lo_jiffies; return dbs_info->freq_lo_delay_us;
} }
od_update(policy); od_update(policy);
...@@ -213,10 +211,10 @@ static unsigned int od_dbs_timer(struct cpufreq_policy *policy) ...@@ -213,10 +211,10 @@ static unsigned int od_dbs_timer(struct cpufreq_policy *policy)
if (dbs_info->freq_lo) { if (dbs_info->freq_lo) {
/* Setup timer for SUB_SAMPLE */ /* Setup timer for SUB_SAMPLE */
dbs_info->sample_type = OD_SUB_SAMPLE; dbs_info->sample_type = OD_SUB_SAMPLE;
return dbs_info->freq_hi_jiffies; return dbs_info->freq_hi_delay_us;
} }
return delay_for_sampling_rate(dbs_data->sampling_rate * policy_dbs->rate_mult); return dbs_data->sampling_rate * policy_dbs->rate_mult;
} }
/************************** sysfs interface ************************/ /************************** sysfs interface ************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment