diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-03-21 10:45:24 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-03-22 18:13:36 -0400 |
commit | 0a300767e5882ad5b687966c80f9620aa0871be5 (patch) | |
tree | 9ef2f2783313800279988d99b08129303dae3ee5 /drivers/cpufreq | |
parent | 1b0289848d5dcea74a6e5115d6c9892b0dbe9c8f (diff) |
cpufreq: Introduce cpufreq_start_governor()
Starting a governor in cpufreq always follows the same pattern
involving two calls to cpufreq_governor(), one with the event
argument set to CPUFREQ_GOV_START and one with that argument set to
CPUFREQ_GOV_LIMITS.
Introduce cpufreq_start_governor() that will carry out those two
operations and make all places where governors are started use it.
That slightly modifies the behavior of cpufreq_set_policy() which
now also will go back to the old governor if the second call to
cpufreq_governor() (the one with event equal to CPUFREQ_GOV_LIMITS)
fails, but that really is how it should work in the first place.
Also cpufreq_resume() will now pring an error message if the
CPUFREQ_GOV_LIMITS call to cpufreq_governor() fails, but that
makes it follow cpufreq_add_policy_cpu() and cpufreq_offline()
in that respect.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index f870399f00b1..43f3912a2ac8 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -76,6 +76,7 @@ static inline bool has_target(void) | |||
76 | /* internal prototypes */ | 76 | /* internal prototypes */ |
77 | static int cpufreq_governor(struct cpufreq_policy *policy, unsigned int event); | 77 | static int cpufreq_governor(struct cpufreq_policy *policy, unsigned int event); |
78 | static unsigned int __cpufreq_get(struct cpufreq_policy *policy); | 78 | static unsigned int __cpufreq_get(struct cpufreq_policy *policy); |
79 | static int cpufreq_start_governor(struct cpufreq_policy *policy); | ||
79 | 80 | ||
80 | /** | 81 | /** |
81 | * Two notifier lists: the "policy" list is involved in the | 82 | * Two notifier lists: the "policy" list is involved in the |
@@ -964,10 +965,7 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cp | |||
964 | cpumask_set_cpu(cpu, policy->cpus); | 965 | cpumask_set_cpu(cpu, policy->cpus); |
965 | 966 | ||
966 | if (has_target()) { | 967 | if (has_target()) { |
967 | ret = cpufreq_governor(policy, CPUFREQ_GOV_START); | 968 | ret = cpufreq_start_governor(policy); |
968 | if (!ret) | ||
969 | ret = cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); | ||
970 | |||
971 | if (ret) | 969 | if (ret) |
972 | pr_err("%s: Failed to start governor\n", __func__); | 970 | pr_err("%s: Failed to start governor\n", __func__); |
973 | } | 971 | } |
@@ -1308,10 +1306,7 @@ static void cpufreq_offline(unsigned int cpu) | |||
1308 | /* Start governor again for active policy */ | 1306 | /* Start governor again for active policy */ |
1309 | if (!policy_is_inactive(policy)) { | 1307 | if (!policy_is_inactive(policy)) { |
1310 | if (has_target()) { | 1308 | if (has_target()) { |
1311 | ret = cpufreq_governor(policy, CPUFREQ_GOV_START); | 1309 | ret = cpufreq_start_governor(policy); |
1312 | if (!ret) | ||
1313 | ret = cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); | ||
1314 | |||
1315 | if (ret) | 1310 | if (ret) |
1316 | pr_err("%s: Failed to start governor\n", __func__); | 1311 | pr_err("%s: Failed to start governor\n", __func__); |
1317 | } | 1312 | } |
@@ -1591,9 +1586,7 @@ void cpufreq_resume(void) | |||
1591 | policy); | 1586 | policy); |
1592 | } else { | 1587 | } else { |
1593 | down_write(&policy->rwsem); | 1588 | down_write(&policy->rwsem); |
1594 | ret = cpufreq_governor(policy, CPUFREQ_GOV_START); | 1589 | ret = cpufreq_start_governor(policy); |
1595 | if (!ret) | ||
1596 | cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); | ||
1597 | up_write(&policy->rwsem); | 1590 | up_write(&policy->rwsem); |
1598 | 1591 | ||
1599 | if (ret) | 1592 | if (ret) |
@@ -1935,6 +1928,14 @@ static int cpufreq_governor(struct cpufreq_policy *policy, unsigned int event) | |||
1935 | return ret; | 1928 | return ret; |
1936 | } | 1929 | } |
1937 | 1930 | ||
1931 | static int cpufreq_start_governor(struct cpufreq_policy *policy) | ||
1932 | { | ||
1933 | int ret; | ||
1934 | |||
1935 | ret = cpufreq_governor(policy, CPUFREQ_GOV_START); | ||
1936 | return ret ? ret : cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); | ||
1937 | } | ||
1938 | |||
1938 | int cpufreq_register_governor(struct cpufreq_governor *governor) | 1939 | int cpufreq_register_governor(struct cpufreq_governor *governor) |
1939 | { | 1940 | { |
1940 | int err; | 1941 | int err; |
@@ -2071,8 +2072,10 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, | |||
2071 | return cpufreq_driver->setpolicy(new_policy); | 2072 | return cpufreq_driver->setpolicy(new_policy); |
2072 | } | 2073 | } |
2073 | 2074 | ||
2074 | if (new_policy->governor == policy->governor) | 2075 | if (new_policy->governor == policy->governor) { |
2075 | goto out; | 2076 | pr_debug("cpufreq: governor limits update\n"); |
2077 | return cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); | ||
2078 | } | ||
2076 | 2079 | ||
2077 | pr_debug("governor switch\n"); | 2080 | pr_debug("governor switch\n"); |
2078 | 2081 | ||
@@ -2100,10 +2103,11 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, | |||
2100 | policy->governor = new_policy->governor; | 2103 | policy->governor = new_policy->governor; |
2101 | ret = cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT); | 2104 | ret = cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT); |
2102 | if (!ret) { | 2105 | if (!ret) { |
2103 | ret = cpufreq_governor(policy, CPUFREQ_GOV_START); | 2106 | ret = cpufreq_start_governor(policy); |
2104 | if (!ret) | 2107 | if (!ret) { |
2105 | goto out; | 2108 | pr_debug("cpufreq: governor change\n"); |
2106 | 2109 | return 0; | |
2110 | } | ||
2107 | cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); | 2111 | cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); |
2108 | } | 2112 | } |
2109 | 2113 | ||
@@ -2114,14 +2118,10 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, | |||
2114 | if (cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT)) | 2118 | if (cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT)) |
2115 | policy->governor = NULL; | 2119 | policy->governor = NULL; |
2116 | else | 2120 | else |
2117 | cpufreq_governor(policy, CPUFREQ_GOV_START); | 2121 | cpufreq_start_governor(policy); |
2118 | } | 2122 | } |
2119 | 2123 | ||
2120 | return ret; | 2124 | return ret; |
2121 | |||
2122 | out: | ||
2123 | pr_debug("governor: change or update limits\n"); | ||
2124 | return cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); | ||
2125 | } | 2125 | } |
2126 | 2126 | ||
2127 | /** | 2127 | /** |