Skip to content

Commit

Permalink
cpufreq: governor: Check transition latecy at init time only
Browse files Browse the repository at this point in the history
It is not necessary to check the governor's max_transition_latency
attribute every time cpufreq_governor() runs, so check it only if
the event argument is CPUFREQ_GOV_POLICY_INIT.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
  • Loading branch information
Rafael J. Wysocki committed May 30, 2016
1 parent d6ff44d commit 9e8c0a8
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -2011,23 +2011,24 @@ static int cpufreq_governor(struct cpufreq_policy *policy, unsigned int event)
if (!policy->governor)
return -EINVAL;

if (policy->governor->max_transition_latency &&
policy->cpuinfo.transition_latency >
policy->governor->max_transition_latency) {
struct cpufreq_governor *gov = cpufreq_fallback_governor();

if (gov) {
pr_warn("%s governor failed, too long transition latency of HW, fallback to %s governor\n",
policy->governor->name, gov->name);
policy->governor = gov;
} else {
return -EINVAL;
if (event == CPUFREQ_GOV_POLICY_INIT) {
if (policy->governor->max_transition_latency &&
policy->cpuinfo.transition_latency >
policy->governor->max_transition_latency) {
struct cpufreq_governor *gov = cpufreq_fallback_governor();

if (gov) {
pr_warn("%s governor failed, too long transition latency of HW, fallback to %s governor\n",
policy->governor->name, gov->name);
policy->governor = gov;
} else {
return -EINVAL;
}
}
}

if (event == CPUFREQ_GOV_POLICY_INIT)
if (!try_module_get(policy->governor->owner))
return -EINVAL;
}

pr_debug("%s: for CPU %u, event %u\n", __func__, policy->cpu, event);

Expand Down

0 comments on commit 9e8c0a8

Please sign in to comment.