diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-07-04 07:21:43 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-07-04 07:21:43 -0400 |
commit | 5d1191ab6cd82b1347eb1b023a3b1eb36ae74ec9 (patch) | |
tree | 89a3effc70464c52829afed58bcb4b961df048c5 /drivers/cpufreq | |
parent | 742c87bf27d3b715820da6f8a81d6357adbf18f8 (diff) | |
parent | 4a7cb7a96aa32e34777b263fbf372543fb85ddea (diff) |
Merge back earlier cpufreq material for v4.8.
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r-- | drivers/cpufreq/Kconfig | 13 | ||||
-rw-r--r-- | drivers/cpufreq/amd_freq_sensitivity.c | 10 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 186 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_conservative.c | 88 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_governor.c | 73 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_governor.h | 24 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.c | 40 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.h | 1 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_performance.c | 19 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_powersave.c | 19 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_stats.c | 157 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_userspace.c | 104 | ||||
-rw-r--r-- | drivers/cpufreq/davinci-cpufreq.c | 22 | ||||
-rw-r--r-- | drivers/cpufreq/freq_table.c | 37 | ||||
-rw-r--r-- | drivers/cpufreq/intel_pstate.c | 88 | ||||
-rw-r--r-- | drivers/cpufreq/mvebu-cpufreq.c | 2 | ||||
-rw-r--r-- | drivers/cpufreq/powernv-cpufreq.c | 5 | ||||
-rw-r--r-- | drivers/cpufreq/ppc_cbe_cpufreq_pmi.c | 3 | ||||
-rw-r--r-- | drivers/cpufreq/s3c24xx-cpufreq.c | 33 | ||||
-rw-r--r-- | drivers/cpufreq/s5pv210-cpufreq.c | 8 |
20 files changed, 353 insertions, 579 deletions
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig index b7445b6ae5a4..c822d72629d5 100644 --- a/drivers/cpufreq/Kconfig +++ b/drivers/cpufreq/Kconfig | |||
@@ -31,23 +31,18 @@ config CPU_FREQ_BOOST_SW | |||
31 | depends on THERMAL | 31 | depends on THERMAL |
32 | 32 | ||
33 | config CPU_FREQ_STAT | 33 | config CPU_FREQ_STAT |
34 | tristate "CPU frequency translation statistics" | 34 | bool "CPU frequency transition statistics" |
35 | default y | 35 | default y |
36 | help | 36 | help |
37 | This driver exports CPU frequency statistics information through sysfs | 37 | Export CPU frequency statistics information through sysfs. |
38 | file system. | ||
39 | |||
40 | To compile this driver as a module, choose M here: the | ||
41 | module will be called cpufreq_stats. | ||
42 | 38 | ||
43 | If in doubt, say N. | 39 | If in doubt, say N. |
44 | 40 | ||
45 | config CPU_FREQ_STAT_DETAILS | 41 | config CPU_FREQ_STAT_DETAILS |
46 | bool "CPU frequency translation statistics details" | 42 | bool "CPU frequency transition statistics details" |
47 | depends on CPU_FREQ_STAT | 43 | depends on CPU_FREQ_STAT |
48 | help | 44 | help |
49 | This will show detail CPU frequency translation table in sysfs file | 45 | Show detailed CPU frequency transition table in sysfs. |
50 | system. | ||
51 | 46 | ||
52 | If in doubt, say N. | 47 | If in doubt, say N. |
53 | 48 | ||
diff --git a/drivers/cpufreq/amd_freq_sensitivity.c b/drivers/cpufreq/amd_freq_sensitivity.c index 404360cad25c..6d5dc04c3a37 100644 --- a/drivers/cpufreq/amd_freq_sensitivity.c +++ b/drivers/cpufreq/amd_freq_sensitivity.c | |||
@@ -48,9 +48,8 @@ static unsigned int amd_powersave_bias_target(struct cpufreq_policy *policy, | |||
48 | struct policy_dbs_info *policy_dbs = policy->governor_data; | 48 | struct policy_dbs_info *policy_dbs = policy->governor_data; |
49 | struct dbs_data *od_data = policy_dbs->dbs_data; | 49 | struct dbs_data *od_data = policy_dbs->dbs_data; |
50 | struct od_dbs_tuners *od_tuners = od_data->tuners; | 50 | struct od_dbs_tuners *od_tuners = od_data->tuners; |
51 | struct od_policy_dbs_info *od_info = to_dbs_info(policy_dbs); | ||
52 | 51 | ||
53 | if (!od_info->freq_table) | 52 | if (!policy->freq_table) |
54 | return freq_next; | 53 | return freq_next; |
55 | 54 | ||
56 | rdmsr_on_cpu(policy->cpu, MSR_AMD64_FREQ_SENSITIVITY_ACTUAL, | 55 | rdmsr_on_cpu(policy->cpu, MSR_AMD64_FREQ_SENSITIVITY_ACTUAL, |
@@ -92,10 +91,9 @@ static unsigned int amd_powersave_bias_target(struct cpufreq_policy *policy, | |||
92 | else { | 91 | else { |
93 | unsigned int index; | 92 | unsigned int index; |
94 | 93 | ||
95 | cpufreq_frequency_table_target(policy, | 94 | index = cpufreq_frequency_table_target(policy, |
96 | od_info->freq_table, policy->cur - 1, | 95 | policy->cur - 1, CPUFREQ_RELATION_H); |
97 | CPUFREQ_RELATION_H, &index); | 96 | freq_next = policy->freq_table[index].frequency; |
98 | freq_next = od_info->freq_table[index].frequency; | ||
99 | } | 97 | } |
100 | 98 | ||
101 | data->freq_prev = freq_next; | 99 | data->freq_prev = freq_next; |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 5617c7087d77..5918e954bb5d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -74,19 +74,12 @@ static inline bool has_target(void) | |||
74 | } | 74 | } |
75 | 75 | ||
76 | /* internal prototypes */ | 76 | /* internal prototypes */ |
77 | static int cpufreq_governor(struct cpufreq_policy *policy, unsigned int event); | ||
78 | static unsigned int __cpufreq_get(struct cpufreq_policy *policy); | 77 | static unsigned int __cpufreq_get(struct cpufreq_policy *policy); |
78 | static int cpufreq_init_governor(struct cpufreq_policy *policy); | ||
79 | static void cpufreq_exit_governor(struct cpufreq_policy *policy); | ||
79 | static int cpufreq_start_governor(struct cpufreq_policy *policy); | 80 | static int cpufreq_start_governor(struct cpufreq_policy *policy); |
80 | 81 | static void cpufreq_stop_governor(struct cpufreq_policy *policy); | |
81 | static inline void cpufreq_exit_governor(struct cpufreq_policy *policy) | 82 | static void cpufreq_governor_limits(struct cpufreq_policy *policy); |
82 | { | ||
83 | (void)cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); | ||
84 | } | ||
85 | |||
86 | static inline void cpufreq_stop_governor(struct cpufreq_policy *policy) | ||
87 | { | ||
88 | (void)cpufreq_governor(policy, CPUFREQ_GOV_STOP); | ||
89 | } | ||
90 | 83 | ||
91 | /** | 84 | /** |
92 | * Two notifier lists: the "policy" list is involved in the | 85 | * Two notifier lists: the "policy" list is involved in the |
@@ -133,15 +126,6 @@ struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy) | |||
133 | } | 126 | } |
134 | EXPORT_SYMBOL_GPL(get_governor_parent_kobj); | 127 | EXPORT_SYMBOL_GPL(get_governor_parent_kobj); |
135 | 128 | ||
136 | struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu) | ||
137 | { | ||
138 | struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); | ||
139 | |||
140 | return policy && !policy_is_inactive(policy) ? | ||
141 | policy->freq_table : NULL; | ||
142 | } | ||
143 | EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table); | ||
144 | |||
145 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) | 129 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) |
146 | { | 130 | { |
147 | u64 idle_time; | 131 | u64 idle_time; |
@@ -354,6 +338,7 @@ static void __cpufreq_notify_transition(struct cpufreq_policy *policy, | |||
354 | pr_debug("FREQ: %lu - CPU: %lu\n", | 338 | pr_debug("FREQ: %lu - CPU: %lu\n", |
355 | (unsigned long)freqs->new, (unsigned long)freqs->cpu); | 339 | (unsigned long)freqs->new, (unsigned long)freqs->cpu); |
356 | trace_cpu_frequency(freqs->new, freqs->cpu); | 340 | trace_cpu_frequency(freqs->new, freqs->cpu); |
341 | cpufreq_stats_record_transition(policy, freqs->new); | ||
357 | srcu_notifier_call_chain(&cpufreq_transition_notifier_list, | 342 | srcu_notifier_call_chain(&cpufreq_transition_notifier_list, |
358 | CPUFREQ_POSTCHANGE, freqs); | 343 | CPUFREQ_POSTCHANGE, freqs); |
359 | if (likely(policy) && likely(policy->cpu == freqs->cpu)) | 344 | if (likely(policy) && likely(policy->cpu == freqs->cpu)) |
@@ -1115,6 +1100,7 @@ static void cpufreq_policy_put_kobj(struct cpufreq_policy *policy, bool notify) | |||
1115 | CPUFREQ_REMOVE_POLICY, policy); | 1100 | CPUFREQ_REMOVE_POLICY, policy); |
1116 | 1101 | ||
1117 | down_write(&policy->rwsem); | 1102 | down_write(&policy->rwsem); |
1103 | cpufreq_stats_free_table(policy); | ||
1118 | cpufreq_remove_dev_symlink(policy); | 1104 | cpufreq_remove_dev_symlink(policy); |
1119 | kobj = &policy->kobj; | 1105 | kobj = &policy->kobj; |
1120 | cmp = &policy->kobj_unregister; | 1106 | cmp = &policy->kobj_unregister; |
@@ -1265,13 +1251,12 @@ static int cpufreq_online(unsigned int cpu) | |||
1265 | } | 1251 | } |
1266 | } | 1252 | } |
1267 | 1253 | ||
1268 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | ||
1269 | CPUFREQ_START, policy); | ||
1270 | |||
1271 | if (new_policy) { | 1254 | if (new_policy) { |
1272 | ret = cpufreq_add_dev_interface(policy); | 1255 | ret = cpufreq_add_dev_interface(policy); |
1273 | if (ret) | 1256 | if (ret) |
1274 | goto out_exit_policy; | 1257 | goto out_exit_policy; |
1258 | |||
1259 | cpufreq_stats_create_table(policy); | ||
1275 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | 1260 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
1276 | CPUFREQ_CREATE_POLICY, policy); | 1261 | CPUFREQ_CREATE_POLICY, policy); |
1277 | 1262 | ||
@@ -1280,6 +1265,9 @@ static int cpufreq_online(unsigned int cpu) | |||
1280 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1265 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
1281 | } | 1266 | } |
1282 | 1267 | ||
1268 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | ||
1269 | CPUFREQ_START, policy); | ||
1270 | |||
1283 | ret = cpufreq_init_policy(policy); | 1271 | ret = cpufreq_init_policy(policy); |
1284 | if (ret) { | 1272 | if (ret) { |
1285 | pr_err("%s: Failed to initialize policy for cpu: %d (%d)\n", | 1273 | pr_err("%s: Failed to initialize policy for cpu: %d (%d)\n", |
@@ -1864,14 +1852,17 @@ static int __target_intermediate(struct cpufreq_policy *policy, | |||
1864 | return ret; | 1852 | return ret; |
1865 | } | 1853 | } |
1866 | 1854 | ||
1867 | static int __target_index(struct cpufreq_policy *policy, | 1855 | static int __target_index(struct cpufreq_policy *policy, int index) |
1868 | struct cpufreq_frequency_table *freq_table, int index) | ||
1869 | { | 1856 | { |
1870 | struct cpufreq_freqs freqs = {.old = policy->cur, .flags = 0}; | 1857 | struct cpufreq_freqs freqs = {.old = policy->cur, .flags = 0}; |
1871 | unsigned int intermediate_freq = 0; | 1858 | unsigned int intermediate_freq = 0; |
1859 | unsigned int newfreq = policy->freq_table[index].frequency; | ||
1872 | int retval = -EINVAL; | 1860 | int retval = -EINVAL; |
1873 | bool notify; | 1861 | bool notify; |
1874 | 1862 | ||
1863 | if (newfreq == policy->cur) | ||
1864 | return 0; | ||
1865 | |||
1875 | notify = !(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION); | 1866 | notify = !(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION); |
1876 | if (notify) { | 1867 | if (notify) { |
1877 | /* Handle switching to intermediate frequency */ | 1868 | /* Handle switching to intermediate frequency */ |
@@ -1886,7 +1877,7 @@ static int __target_index(struct cpufreq_policy *policy, | |||
1886 | freqs.old = freqs.new; | 1877 | freqs.old = freqs.new; |
1887 | } | 1878 | } |
1888 | 1879 | ||
1889 | freqs.new = freq_table[index].frequency; | 1880 | freqs.new = newfreq; |
1890 | pr_debug("%s: cpu: %d, oldfreq: %u, new freq: %u\n", | 1881 | pr_debug("%s: cpu: %d, oldfreq: %u, new freq: %u\n", |
1891 | __func__, policy->cpu, freqs.old, freqs.new); | 1882 | __func__, policy->cpu, freqs.old, freqs.new); |
1892 | 1883 | ||
@@ -1923,17 +1914,13 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, | |||
1923 | unsigned int relation) | 1914 | unsigned int relation) |
1924 | { | 1915 | { |
1925 | unsigned int old_target_freq = target_freq; | 1916 | unsigned int old_target_freq = target_freq; |
1926 | struct cpufreq_frequency_table *freq_table; | 1917 | int index; |
1927 | int index, retval; | ||
1928 | 1918 | ||
1929 | if (cpufreq_disabled()) | 1919 | if (cpufreq_disabled()) |
1930 | return -ENODEV; | 1920 | return -ENODEV; |
1931 | 1921 | ||
1932 | /* Make sure that target_freq is within supported range */ | 1922 | /* Make sure that target_freq is within supported range */ |
1933 | if (target_freq > policy->max) | 1923 | target_freq = clamp_val(target_freq, policy->min, policy->max); |
1934 | target_freq = policy->max; | ||
1935 | if (target_freq < policy->min) | ||
1936 | target_freq = policy->min; | ||
1937 | 1924 | ||
1938 | pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n", | 1925 | pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n", |
1939 | policy->cpu, target_freq, relation, old_target_freq); | 1926 | policy->cpu, target_freq, relation, old_target_freq); |
@@ -1956,23 +1943,9 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, | |||
1956 | if (!cpufreq_driver->target_index) | 1943 | if (!cpufreq_driver->target_index) |
1957 | return -EINVAL; | 1944 | return -EINVAL; |
1958 | 1945 | ||
1959 | freq_table = cpufreq_frequency_get_table(policy->cpu); | 1946 | index = cpufreq_frequency_table_target(policy, target_freq, relation); |
1960 | if (unlikely(!freq_table)) { | ||
1961 | pr_err("%s: Unable to find freq_table\n", __func__); | ||
1962 | return -EINVAL; | ||
1963 | } | ||
1964 | |||
1965 | retval = cpufreq_frequency_table_target(policy, freq_table, target_freq, | ||
1966 | relation, &index); | ||
1967 | if (unlikely(retval)) { | ||
1968 | pr_err("%s: Unable to find matching freq\n", __func__); | ||
1969 | return retval; | ||
1970 | } | ||
1971 | |||
1972 | if (freq_table[index].frequency == policy->cur) | ||
1973 | return 0; | ||
1974 | 1947 | ||
1975 | return __target_index(policy, freq_table, index); | 1948 | return __target_index(policy, index); |
1976 | } | 1949 | } |
1977 | EXPORT_SYMBOL_GPL(__cpufreq_driver_target); | 1950 | EXPORT_SYMBOL_GPL(__cpufreq_driver_target); |
1978 | 1951 | ||
@@ -1997,7 +1970,7 @@ __weak struct cpufreq_governor *cpufreq_fallback_governor(void) | |||
1997 | return NULL; | 1970 | return NULL; |
1998 | } | 1971 | } |
1999 | 1972 | ||
2000 | static int cpufreq_governor(struct cpufreq_policy *policy, unsigned int event) | 1973 | static int cpufreq_init_governor(struct cpufreq_policy *policy) |
2001 | { | 1974 | { |
2002 | int ret; | 1975 | int ret; |
2003 | 1976 | ||
@@ -2025,36 +1998,82 @@ static int cpufreq_governor(struct cpufreq_policy *policy, unsigned int event) | |||
2025 | } | 1998 | } |
2026 | } | 1999 | } |
2027 | 2000 | ||
2028 | if (event == CPUFREQ_GOV_POLICY_INIT) | 2001 | if (!try_module_get(policy->governor->owner)) |
2029 | if (!try_module_get(policy->governor->owner)) | 2002 | return -EINVAL; |
2030 | return -EINVAL; | ||
2031 | |||
2032 | pr_debug("%s: for CPU %u, event %u\n", __func__, policy->cpu, event); | ||
2033 | 2003 | ||
2034 | ret = policy->governor->governor(policy, event); | 2004 | pr_debug("%s: for CPU %u\n", __func__, policy->cpu); |
2035 | 2005 | ||
2036 | if (event == CPUFREQ_GOV_POLICY_INIT) { | 2006 | if (policy->governor->init) { |
2037 | if (ret) | 2007 | ret = policy->governor->init(policy); |
2008 | if (ret) { | ||
2038 | module_put(policy->governor->owner); | 2009 | module_put(policy->governor->owner); |
2039 | else | 2010 | return ret; |
2040 | policy->governor->initialized++; | 2011 | } |
2041 | } else if (event == CPUFREQ_GOV_POLICY_EXIT) { | ||
2042 | policy->governor->initialized--; | ||
2043 | module_put(policy->governor->owner); | ||
2044 | } | 2012 | } |
2045 | 2013 | ||
2046 | return ret; | 2014 | return 0; |
2015 | } | ||
2016 | |||
2017 | static void cpufreq_exit_governor(struct cpufreq_policy *policy) | ||
2018 | { | ||
2019 | if (cpufreq_suspended || !policy->governor) | ||
2020 | return; | ||
2021 | |||
2022 | pr_debug("%s: for CPU %u\n", __func__, policy->cpu); | ||
2023 | |||
2024 | if (policy->governor->exit) | ||
2025 | policy->governor->exit(policy); | ||
2026 | |||
2027 | module_put(policy->governor->owner); | ||
2047 | } | 2028 | } |
2048 | 2029 | ||
2049 | static int cpufreq_start_governor(struct cpufreq_policy *policy) | 2030 | static int cpufreq_start_governor(struct cpufreq_policy *policy) |
2050 | { | 2031 | { |
2051 | int ret; | 2032 | int ret; |
2052 | 2033 | ||
2034 | if (cpufreq_suspended) | ||
2035 | return 0; | ||
2036 | |||
2037 | if (!policy->governor) | ||
2038 | return -EINVAL; | ||
2039 | |||
2040 | pr_debug("%s: for CPU %u\n", __func__, policy->cpu); | ||
2041 | |||
2053 | if (cpufreq_driver->get && !cpufreq_driver->setpolicy) | 2042 | if (cpufreq_driver->get && !cpufreq_driver->setpolicy) |
2054 | cpufreq_update_current_freq(policy); | 2043 | cpufreq_update_current_freq(policy); |
2055 | 2044 | ||
2056 | ret = cpufreq_governor(policy, CPUFREQ_GOV_START); | 2045 | if (policy->governor->start) { |
2057 | return ret ? ret : cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); | 2046 | ret = policy->governor->start(policy); |
2047 | if (ret) | ||
2048 | return ret; | ||
2049 | } | ||
2050 | |||
2051 | if (policy->governor->limits) | ||
2052 | policy->governor->limits(policy); | ||
2053 | |||
2054 | return 0; | ||
2055 | } | ||
2056 | |||
2057 | static void cpufreq_stop_governor(struct cpufreq_policy *policy) | ||
2058 | { | ||
2059 | if (cpufreq_suspended || !policy->governor) | ||
2060 | return; | ||
2061 | |||
2062 | pr_debug("%s: for CPU %u\n", __func__, policy->cpu); | ||
2063 | |||
2064 | if (policy->governor->stop) | ||
2065 | policy->governor->stop(policy); | ||
2066 | } | ||
2067 | |||
2068 | static void cpufreq_governor_limits(struct cpufreq_policy *policy) | ||
2069 | { | ||
2070 | if (cpufreq_suspended || !policy->governor) | ||
2071 | return; | ||
2072 | |||
2073 | pr_debug("%s: for CPU %u\n", __func__, policy->cpu); | ||
2074 | |||
2075 | if (policy->governor->limits) | ||
2076 | policy->governor->limits(policy); | ||
2058 | } | 2077 | } |
2059 | 2078 | ||
2060 | int cpufreq_register_governor(struct cpufreq_governor *governor) | 2079 | int cpufreq_register_governor(struct cpufreq_governor *governor) |
@@ -2069,7 +2088,6 @@ int cpufreq_register_governor(struct cpufreq_governor *governor) | |||
2069 | 2088 | ||
2070 | mutex_lock(&cpufreq_governor_mutex); | 2089 | mutex_lock(&cpufreq_governor_mutex); |
2071 | 2090 | ||
2072 | governor->initialized = 0; | ||
2073 | err = -EBUSY; | 2091 | err = -EBUSY; |
2074 | if (!find_governor(governor->name)) { | 2092 | if (!find_governor(governor->name)) { |
2075 | err = 0; | 2093 | err = 0; |
@@ -2195,7 +2213,8 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, | |||
2195 | 2213 | ||
2196 | if (new_policy->governor == policy->governor) { | 2214 | if (new_policy->governor == policy->governor) { |
2197 | pr_debug("cpufreq: governor limits update\n"); | 2215 | pr_debug("cpufreq: governor limits update\n"); |
2198 | return cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); | 2216 | cpufreq_governor_limits(policy); |
2217 | return 0; | ||
2199 | } | 2218 | } |
2200 | 2219 | ||
2201 | pr_debug("governor switch\n"); | 2220 | pr_debug("governor switch\n"); |
@@ -2210,7 +2229,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, | |||
2210 | 2229 | ||
2211 | /* start new governor */ | 2230 | /* start new governor */ |
2212 | policy->governor = new_policy->governor; | 2231 | policy->governor = new_policy->governor; |
2213 | ret = cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT); | 2232 | ret = cpufreq_init_governor(policy); |
2214 | if (!ret) { | 2233 | if (!ret) { |
2215 | ret = cpufreq_start_governor(policy); | 2234 | ret = cpufreq_start_governor(policy); |
2216 | if (!ret) { | 2235 | if (!ret) { |
@@ -2224,7 +2243,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, | |||
2224 | pr_debug("starting governor %s failed\n", policy->governor->name); | 2243 | pr_debug("starting governor %s failed\n", policy->governor->name); |
2225 | if (old_gov) { | 2244 | if (old_gov) { |
2226 | policy->governor = old_gov; | 2245 | policy->governor = old_gov; |
2227 | if (cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT)) | 2246 | if (cpufreq_init_governor(policy)) |
2228 | policy->governor = NULL; | 2247 | policy->governor = NULL; |
2229 | else | 2248 | else |
2230 | cpufreq_start_governor(policy); | 2249 | cpufreq_start_governor(policy); |
@@ -2309,26 +2328,25 @@ static struct notifier_block __refdata cpufreq_cpu_notifier = { | |||
2309 | *********************************************************************/ | 2328 | *********************************************************************/ |
2310 | static int cpufreq_boost_set_sw(int state) | 2329 | static int cpufreq_boost_set_sw(int state) |
2311 | { | 2330 | { |
2312 | struct cpufreq_frequency_table *freq_table; | ||
2313 | struct cpufreq_policy *policy; | 2331 | struct cpufreq_policy *policy; |
2314 | int ret = -EINVAL; | 2332 | int ret = -EINVAL; |
2315 | 2333 | ||
2316 | for_each_active_policy(policy) { | 2334 | for_each_active_policy(policy) { |
2317 | freq_table = cpufreq_frequency_get_table(policy->cpu); | 2335 | if (!policy->freq_table) |
2318 | if (freq_table) { | 2336 | continue; |
2319 | ret = cpufreq_frequency_table_cpuinfo(policy, | 2337 | |
2320 | freq_table); | 2338 | ret = cpufreq_frequency_table_cpuinfo(policy, |
2321 | if (ret) { | 2339 | policy->freq_table); |
2322 | pr_err("%s: Policy frequency update failed\n", | 2340 | if (ret) { |
2323 | __func__); | 2341 | pr_err("%s: Policy frequency update failed\n", |
2324 | break; | 2342 | __func__); |
2325 | } | 2343 | break; |
2326 | |||
2327 | down_write(&policy->rwsem); | ||
2328 | policy->user_policy.max = policy->max; | ||
2329 | cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); | ||
2330 | up_write(&policy->rwsem); | ||
2331 | } | 2344 | } |
2345 | |||
2346 | down_write(&policy->rwsem); | ||
2347 | policy->user_policy.max = policy->max; | ||
2348 | cpufreq_governor_limits(policy); | ||
2349 | up_write(&policy->rwsem); | ||
2332 | } | 2350 | } |
2333 | 2351 | ||
2334 | return ret; | 2352 | return ret; |
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index 316df247e00d..18da4f8051d3 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -17,7 +17,6 @@ | |||
17 | struct cs_policy_dbs_info { | 17 | struct cs_policy_dbs_info { |
18 | struct policy_dbs_info policy_dbs; | 18 | struct policy_dbs_info policy_dbs; |
19 | unsigned int down_skip; | 19 | unsigned int down_skip; |
20 | unsigned int requested_freq; | ||
21 | }; | 20 | }; |
22 | 21 | ||
23 | static inline struct cs_policy_dbs_info *to_dbs_info(struct policy_dbs_info *policy_dbs) | 22 | static inline struct cs_policy_dbs_info *to_dbs_info(struct policy_dbs_info *policy_dbs) |
@@ -75,19 +74,17 @@ static unsigned int cs_dbs_timer(struct cpufreq_policy *policy) | |||
75 | 74 | ||
76 | /* Check for frequency increase */ | 75 | /* Check for frequency increase */ |
77 | if (load > dbs_data->up_threshold) { | 76 | if (load > dbs_data->up_threshold) { |
77 | unsigned int requested_freq = policy->cur; | ||
78 | |||
78 | dbs_info->down_skip = 0; | 79 | dbs_info->down_skip = 0; |
79 | 80 | ||
80 | /* if we are already at full speed then break out early */ | 81 | /* if we are already at full speed then break out early */ |
81 | if (dbs_info->requested_freq == policy->max) | 82 | if (requested_freq == policy->max) |
82 | goto out; | 83 | goto out; |
83 | 84 | ||
84 | dbs_info->requested_freq += get_freq_target(cs_tuners, policy); | 85 | requested_freq += get_freq_target(cs_tuners, policy); |
85 | |||
86 | if (dbs_info->requested_freq > policy->max) | ||
87 | dbs_info->requested_freq = policy->max; | ||
88 | 86 | ||
89 | __cpufreq_driver_target(policy, dbs_info->requested_freq, | 87 | __cpufreq_driver_target(policy, requested_freq, CPUFREQ_RELATION_H); |
90 | CPUFREQ_RELATION_H); | ||
91 | goto out; | 88 | goto out; |
92 | } | 89 | } |
93 | 90 | ||
@@ -98,36 +95,27 @@ static unsigned int cs_dbs_timer(struct cpufreq_policy *policy) | |||
98 | 95 | ||
99 | /* Check for frequency decrease */ | 96 | /* Check for frequency decrease */ |
100 | if (load < cs_tuners->down_threshold) { | 97 | if (load < cs_tuners->down_threshold) { |
101 | unsigned int freq_target; | 98 | unsigned int freq_target, requested_freq = policy->cur; |
102 | /* | 99 | /* |
103 | * if we cannot reduce the frequency anymore, break out early | 100 | * if we cannot reduce the frequency anymore, break out early |
104 | */ | 101 | */ |
105 | if (policy->cur == policy->min) | 102 | if (requested_freq == policy->min) |
106 | goto out; | 103 | goto out; |
107 | 104 | ||
108 | freq_target = get_freq_target(cs_tuners, policy); | 105 | freq_target = get_freq_target(cs_tuners, policy); |
109 | if (dbs_info->requested_freq > freq_target) | 106 | if (requested_freq > freq_target) |
110 | dbs_info->requested_freq -= freq_target; | 107 | requested_freq -= freq_target; |
111 | else | 108 | else |
112 | dbs_info->requested_freq = policy->min; | 109 | requested_freq = policy->min; |
113 | 110 | ||
114 | __cpufreq_driver_target(policy, dbs_info->requested_freq, | 111 | __cpufreq_driver_target(policy, requested_freq, CPUFREQ_RELATION_L); |
115 | CPUFREQ_RELATION_L); | ||
116 | } | 112 | } |
117 | 113 | ||
118 | out: | 114 | out: |
119 | return dbs_data->sampling_rate; | 115 | return dbs_data->sampling_rate; |
120 | } | 116 | } |
121 | 117 | ||
122 | static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val, | ||
123 | void *data); | ||
124 | |||
125 | static struct notifier_block cs_cpufreq_notifier_block = { | ||
126 | .notifier_call = dbs_cpufreq_notifier, | ||
127 | }; | ||
128 | |||
129 | /************************** sysfs interface ************************/ | 118 | /************************** sysfs interface ************************/ |
130 | static struct dbs_governor cs_dbs_gov; | ||
131 | 119 | ||
132 | static ssize_t store_sampling_down_factor(struct gov_attr_set *attr_set, | 120 | static ssize_t store_sampling_down_factor(struct gov_attr_set *attr_set, |
133 | const char *buf, size_t count) | 121 | const char *buf, size_t count) |
@@ -268,15 +256,13 @@ static void cs_free(struct policy_dbs_info *policy_dbs) | |||
268 | kfree(to_dbs_info(policy_dbs)); | 256 | kfree(to_dbs_info(policy_dbs)); |
269 | } | 257 | } |
270 | 258 | ||
271 | static int cs_init(struct dbs_data *dbs_data, bool notify) | 259 | static int cs_init(struct dbs_data *dbs_data) |
272 | { | 260 | { |
273 | struct cs_dbs_tuners *tuners; | 261 | struct cs_dbs_tuners *tuners; |
274 | 262 | ||
275 | tuners = kzalloc(sizeof(*tuners), GFP_KERNEL); | 263 | tuners = kzalloc(sizeof(*tuners), GFP_KERNEL); |
276 | if (!tuners) { | 264 | if (!tuners) |
277 | pr_err("%s: kzalloc failed\n", __func__); | ||
278 | return -ENOMEM; | 265 | return -ENOMEM; |
279 | } | ||
280 | 266 | ||
281 | tuners->down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD; | 267 | tuners->down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD; |
282 | tuners->freq_step = DEF_FREQUENCY_STEP; | 268 | tuners->freq_step = DEF_FREQUENCY_STEP; |
@@ -288,19 +274,11 @@ static int cs_init(struct dbs_data *dbs_data, bool notify) | |||
288 | dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO * | 274 | dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO * |
289 | jiffies_to_usecs(10); | 275 | jiffies_to_usecs(10); |
290 | 276 | ||
291 | if (notify) | ||
292 | cpufreq_register_notifier(&cs_cpufreq_notifier_block, | ||
293 | CPUFREQ_TRANSITION_NOTIFIER); | ||
294 | |||
295 | return 0; | 277 | return 0; |
296 | } | 278 | } |
297 | 279 | ||
298 | static void cs_exit(struct dbs_data *dbs_data, bool notify) | 280 | static void cs_exit(struct dbs_data *dbs_data) |
299 | { | 281 | { |
300 | if (notify) | ||
301 | cpufreq_unregister_notifier(&cs_cpufreq_notifier_block, | ||
302 | CPUFREQ_TRANSITION_NOTIFIER); | ||
303 | |||
304 | kfree(dbs_data->tuners); | 282 | kfree(dbs_data->tuners); |
305 | } | 283 | } |
306 | 284 | ||
@@ -309,16 +287,10 @@ static void cs_start(struct cpufreq_policy *policy) | |||
309 | struct cs_policy_dbs_info *dbs_info = to_dbs_info(policy->governor_data); | 287 | struct cs_policy_dbs_info *dbs_info = to_dbs_info(policy->governor_data); |
310 | 288 | ||
311 | dbs_info->down_skip = 0; | 289 | dbs_info->down_skip = 0; |
312 | dbs_info->requested_freq = policy->cur; | ||
313 | } | 290 | } |
314 | 291 | ||
315 | static struct dbs_governor cs_dbs_gov = { | 292 | static struct dbs_governor cs_governor = { |
316 | .gov = { | 293 | .gov = CPUFREQ_DBS_GOVERNOR_INITIALIZER("conservative"), |
317 | .name = "conservative", | ||
318 | .governor = cpufreq_governor_dbs, | ||
319 | .max_transition_latency = TRANSITION_LATENCY_LIMIT, | ||
320 | .owner = THIS_MODULE, | ||
321 | }, | ||
322 | .kobj_type = { .default_attrs = cs_attributes }, | 294 | .kobj_type = { .default_attrs = cs_attributes }, |
323 | .gov_dbs_timer = cs_dbs_timer, | 295 | .gov_dbs_timer = cs_dbs_timer, |
324 | .alloc = cs_alloc, | 296 | .alloc = cs_alloc, |
@@ -328,33 +300,7 @@ static struct dbs_governor cs_dbs_gov = { | |||
328 | .start = cs_start, | 300 | .start = cs_start, |
329 | }; | 301 | }; |
330 | 302 | ||
331 | #define CPU_FREQ_GOV_CONSERVATIVE (&cs_dbs_gov.gov) | 303 | #define CPU_FREQ_GOV_CONSERVATIVE (&cs_governor.gov) |
332 | |||
333 | static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val, | ||
334 | void *data) | ||
335 | { | ||
336 | struct cpufreq_freqs *freq = data; | ||
337 | struct cpufreq_policy *policy = cpufreq_cpu_get_raw(freq->cpu); | ||
338 | struct cs_policy_dbs_info *dbs_info; | ||
339 | |||
340 | if (!policy) | ||
341 | return 0; | ||
342 | |||
343 | /* policy isn't governed by conservative governor */ | ||
344 | if (policy->governor != CPU_FREQ_GOV_CONSERVATIVE) | ||
345 | return 0; | ||
346 | |||
347 | dbs_info = to_dbs_info(policy->governor_data); | ||
348 | /* | ||
349 | * we only care if our internally tracked freq moves outside the 'valid' | ||
350 | * ranges of frequency available to us otherwise we do not change it | ||
351 | */ | ||
352 | if (dbs_info->requested_freq > policy->max | ||
353 | || dbs_info->requested_freq < policy->min) | ||
354 | dbs_info->requested_freq = freq->new; | ||
355 | |||
356 | return 0; | ||
357 | } | ||
358 | 304 | ||
359 | static int __init cpufreq_gov_dbs_init(void) | 305 | static int __init cpufreq_gov_dbs_init(void) |
360 | { | 306 | { |
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index be498d56dd69..e415349ab31b 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c | |||
@@ -336,17 +336,6 @@ static inline void gov_clear_update_util(struct cpufreq_policy *policy) | |||
336 | synchronize_sched(); | 336 | synchronize_sched(); |
337 | } | 337 | } |
338 | 338 | ||
339 | static void gov_cancel_work(struct cpufreq_policy *policy) | ||
340 | { | ||
341 | struct policy_dbs_info *policy_dbs = policy->governor_data; | ||
342 | |||
343 | gov_clear_update_util(policy_dbs->policy); | ||
344 | irq_work_sync(&policy_dbs->irq_work); | ||
345 | cancel_work_sync(&policy_dbs->work); | ||
346 | atomic_set(&policy_dbs->work_count, 0); | ||
347 | policy_dbs->work_in_progress = false; | ||
348 | } | ||
349 | |||
350 | static struct policy_dbs_info *alloc_policy_dbs_info(struct cpufreq_policy *policy, | 339 | static struct policy_dbs_info *alloc_policy_dbs_info(struct cpufreq_policy *policy, |
351 | struct dbs_governor *gov) | 340 | struct dbs_governor *gov) |
352 | { | 341 | { |
@@ -389,7 +378,7 @@ static void free_policy_dbs_info(struct policy_dbs_info *policy_dbs, | |||
389 | gov->free(policy_dbs); | 378 | gov->free(policy_dbs); |
390 | } | 379 | } |
391 | 380 | ||
392 | static int cpufreq_governor_init(struct cpufreq_policy *policy) | 381 | int cpufreq_dbs_governor_init(struct cpufreq_policy *policy) |
393 | { | 382 | { |
394 | struct dbs_governor *gov = dbs_governor_of(policy); | 383 | struct dbs_governor *gov = dbs_governor_of(policy); |
395 | struct dbs_data *dbs_data; | 384 | struct dbs_data *dbs_data; |
@@ -429,7 +418,7 @@ static int cpufreq_governor_init(struct cpufreq_policy *policy) | |||
429 | 418 | ||
430 | gov_attr_set_init(&dbs_data->attr_set, &policy_dbs->list); | 419 | gov_attr_set_init(&dbs_data->attr_set, &policy_dbs->list); |
431 | 420 | ||
432 | ret = gov->init(dbs_data, !policy->governor->initialized); | 421 | ret = gov->init(dbs_data); |
433 | if (ret) | 422 | if (ret) |
434 | goto free_policy_dbs_info; | 423 | goto free_policy_dbs_info; |
435 | 424 | ||
@@ -458,13 +447,13 @@ static int cpufreq_governor_init(struct cpufreq_policy *policy) | |||
458 | goto out; | 447 | goto out; |
459 | 448 | ||
460 | /* Failure, so roll back. */ | 449 | /* Failure, so roll back. */ |
461 | pr_err("cpufreq: Governor initialization failed (dbs_data kobject init error %d)\n", ret); | 450 | pr_err("initialization failed (dbs_data kobject init error %d)\n", ret); |
462 | 451 | ||
463 | policy->governor_data = NULL; | 452 | policy->governor_data = NULL; |
464 | 453 | ||
465 | if (!have_governor_per_policy()) | 454 | if (!have_governor_per_policy()) |
466 | gov->gdbs_data = NULL; | 455 | gov->gdbs_data = NULL; |
467 | gov->exit(dbs_data, !policy->governor->initialized); | 456 | gov->exit(dbs_data); |
468 | kfree(dbs_data); | 457 | kfree(dbs_data); |
469 | 458 | ||
470 | free_policy_dbs_info: | 459 | free_policy_dbs_info: |
@@ -474,8 +463,9 @@ out: | |||
474 | mutex_unlock(&gov_dbs_data_mutex); | 463 | mutex_unlock(&gov_dbs_data_mutex); |
475 | return ret; | 464 | return ret; |
476 | } | 465 | } |
466 | EXPORT_SYMBOL_GPL(cpufreq_dbs_governor_init); | ||
477 | 467 | ||
478 | static int cpufreq_governor_exit(struct cpufreq_policy *policy) | 468 | void cpufreq_dbs_governor_exit(struct cpufreq_policy *policy) |
479 | { | 469 | { |
480 | struct dbs_governor *gov = dbs_governor_of(policy); | 470 | struct dbs_governor *gov = dbs_governor_of(policy); |
481 | struct policy_dbs_info *policy_dbs = policy->governor_data; | 471 | struct policy_dbs_info *policy_dbs = policy->governor_data; |
@@ -493,17 +483,17 @@ static int cpufreq_governor_exit(struct cpufreq_policy *policy) | |||
493 | if (!have_governor_per_policy()) | 483 | if (!have_governor_per_policy()) |
494 | gov->gdbs_data = NULL; | 484 | gov->gdbs_data = NULL; |
495 | 485 | ||
496 | gov->exit(dbs_data, policy->governor->initialized == 1); | 486 | gov->exit(dbs_data); |
497 | kfree(dbs_data); | 487 | kfree(dbs_data); |
498 | } | 488 | } |
499 | 489 | ||
500 | free_policy_dbs_info(policy_dbs, gov); | 490 | free_policy_dbs_info(policy_dbs, gov); |
501 | 491 | ||
502 | mutex_unlock(&gov_dbs_data_mutex); | 492 | mutex_unlock(&gov_dbs_data_mutex); |
503 | return 0; | ||
504 | } | 493 | } |
494 | EXPORT_SYMBOL_GPL(cpufreq_dbs_governor_exit); | ||
505 | 495 | ||
506 | static int cpufreq_governor_start(struct cpufreq_policy *policy) | 496 | int cpufreq_dbs_governor_start(struct cpufreq_policy *policy) |
507 | { | 497 | { |
508 | struct dbs_governor *gov = dbs_governor_of(policy); | 498 | struct dbs_governor *gov = dbs_governor_of(policy); |
509 | struct policy_dbs_info *policy_dbs = policy->governor_data; | 499 | struct policy_dbs_info *policy_dbs = policy->governor_data; |
@@ -539,47 +529,28 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy) | |||
539 | gov_set_update_util(policy_dbs, sampling_rate); | 529 | gov_set_update_util(policy_dbs, sampling_rate); |
540 | return 0; | 530 | return 0; |
541 | } | 531 | } |
532 | EXPORT_SYMBOL_GPL(cpufreq_dbs_governor_start); | ||
542 | 533 | ||
543 | static int cpufreq_governor_stop(struct cpufreq_policy *policy) | 534 | void cpufreq_dbs_governor_stop(struct cpufreq_policy *policy) |
544 | { | 535 | { |
545 | gov_cancel_work(policy); | 536 | struct policy_dbs_info *policy_dbs = policy->governor_data; |
546 | return 0; | 537 | |
538 | gov_clear_update_util(policy_dbs->policy); | ||
539 | irq_work_sync(&policy_dbs->irq_work); | ||
540 | cancel_work_sync(&policy_dbs->work); | ||
541 | atomic_set(&policy_dbs->work_count, 0); | ||
542 | policy_dbs->work_in_progress = false; | ||
547 | } | 543 | } |
544 | EXPORT_SYMBOL_GPL(cpufreq_dbs_governor_stop); | ||
548 | 545 | ||
549 | static int cpufreq_governor_limits(struct cpufreq_policy *policy) | 546 | void cpufreq_dbs_governor_limits(struct cpufreq_policy *policy) |
550 | { | 547 | { |
551 | struct policy_dbs_info *policy_dbs = policy->governor_data; | 548 | struct policy_dbs_info *policy_dbs = policy->governor_data; |
552 | 549 | ||
553 | mutex_lock(&policy_dbs->timer_mutex); | 550 | mutex_lock(&policy_dbs->timer_mutex); |
554 | 551 | cpufreq_policy_apply_limits(policy); | |
555 | if (policy->max < policy->cur) | ||
556 | __cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H); | ||
557 | else if (policy->min > policy->cur) | ||
558 | __cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L); | ||
559 | |||
560 | gov_update_sample_delay(policy_dbs, 0); | 552 | gov_update_sample_delay(policy_dbs, 0); |
561 | 553 | ||
562 | mutex_unlock(&policy_dbs->timer_mutex); | 554 | mutex_unlock(&policy_dbs->timer_mutex); |
563 | |||
564 | return 0; | ||
565 | } | ||
566 | |||
567 | int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event) | ||
568 | { | ||
569 | if (event == CPUFREQ_GOV_POLICY_INIT) { | ||
570 | return cpufreq_governor_init(policy); | ||
571 | } else if (policy->governor_data) { | ||
572 | switch (event) { | ||
573 | case CPUFREQ_GOV_POLICY_EXIT: | ||
574 | return cpufreq_governor_exit(policy); | ||
575 | case CPUFREQ_GOV_START: | ||
576 | return cpufreq_governor_start(policy); | ||
577 | case CPUFREQ_GOV_STOP: | ||
578 | return cpufreq_governor_stop(policy); | ||
579 | case CPUFREQ_GOV_LIMITS: | ||
580 | return cpufreq_governor_limits(policy); | ||
581 | } | ||
582 | } | ||
583 | return -EINVAL; | ||
584 | } | 555 | } |
585 | EXPORT_SYMBOL_GPL(cpufreq_governor_dbs); | 556 | EXPORT_SYMBOL_GPL(cpufreq_dbs_governor_limits); |
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index 34eb214b6d57..ef1037e9c92b 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h | |||
@@ -138,8 +138,8 @@ struct dbs_governor { | |||
138 | unsigned int (*gov_dbs_timer)(struct cpufreq_policy *policy); | 138 | unsigned int (*gov_dbs_timer)(struct cpufreq_policy *policy); |
139 | struct policy_dbs_info *(*alloc)(void); | 139 | struct policy_dbs_info *(*alloc)(void); |
140 | void (*free)(struct policy_dbs_info *policy_dbs); | 140 | void (*free)(struct policy_dbs_info *policy_dbs); |
141 | int (*init)(struct dbs_data *dbs_data, bool notify); | 141 | int (*init)(struct dbs_data *dbs_data); |
142 | void (*exit)(struct dbs_data *dbs_data, bool notify); | 142 | void (*exit)(struct dbs_data *dbs_data); |
143 | void (*start)(struct cpufreq_policy *policy); | 143 | void (*start)(struct cpufreq_policy *policy); |
144 | }; | 144 | }; |
145 | 145 | ||
@@ -148,6 +148,25 @@ static inline struct dbs_governor *dbs_governor_of(struct cpufreq_policy *policy | |||
148 | return container_of(policy->governor, struct dbs_governor, gov); | 148 | return container_of(policy->governor, struct dbs_governor, gov); |
149 | } | 149 | } |
150 | 150 | ||
151 | /* Governor callback routines */ | ||
152 | int cpufreq_dbs_governor_init(struct cpufreq_policy *policy); | ||
153 | void cpufreq_dbs_governor_exit(struct cpufreq_policy *policy); | ||
154 | int cpufreq_dbs_governor_start(struct cpufreq_policy *policy); | ||
155 | void cpufreq_dbs_governor_stop(struct cpufreq_policy *policy); | ||
156 | void cpufreq_dbs_governor_limits(struct cpufreq_policy *policy); | ||
157 | |||
158 | #define CPUFREQ_DBS_GOVERNOR_INITIALIZER(_name_) \ | ||
159 | { \ | ||
160 | .name = _name_, \ | ||
161 | .max_transition_latency = TRANSITION_LATENCY_LIMIT, \ | ||
162 | .owner = THIS_MODULE, \ | ||
163 | .init = cpufreq_dbs_governor_init, \ | ||
164 | .exit = cpufreq_dbs_governor_exit, \ | ||
165 | .start = cpufreq_dbs_governor_start, \ | ||
166 | .stop = cpufreq_dbs_governor_stop, \ | ||
167 | .limits = cpufreq_dbs_governor_limits, \ | ||
168 | } | ||
169 | |||
151 | /* Governor specific operations */ | 170 | /* Governor specific operations */ |
152 | struct od_ops { | 171 | struct od_ops { |
153 | unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy, | 172 | unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy, |
@@ -155,7 +174,6 @@ struct od_ops { | |||
155 | }; | 174 | }; |
156 | 175 | ||
157 | unsigned int dbs_update(struct cpufreq_policy *policy); | 176 | unsigned int dbs_update(struct cpufreq_policy *policy); |
158 | int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event); | ||
159 | void od_register_powersave_bias_handler(unsigned int (*f) | 177 | void od_register_powersave_bias_handler(unsigned int (*f) |
160 | (struct cpufreq_policy *, unsigned int, unsigned int), | 178 | (struct cpufreq_policy *, unsigned int, unsigned int), |
161 | unsigned int powersave_bias); | 179 | unsigned int powersave_bias); |
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 300163430516..0c93cd9dee99 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -65,34 +65,32 @@ static unsigned int generic_powersave_bias_target(struct cpufreq_policy *policy, | |||
65 | { | 65 | { |
66 | unsigned int freq_req, freq_reduc, freq_avg; | 66 | unsigned int freq_req, freq_reduc, freq_avg; |
67 | unsigned int freq_hi, freq_lo; | 67 | unsigned int freq_hi, freq_lo; |
68 | unsigned int index = 0; | 68 | unsigned int index; |
69 | unsigned int delay_hi_us; | 69 | unsigned int delay_hi_us; |
70 | struct policy_dbs_info *policy_dbs = policy->governor_data; | 70 | struct policy_dbs_info *policy_dbs = policy->governor_data; |
71 | struct od_policy_dbs_info *dbs_info = to_dbs_info(policy_dbs); | 71 | struct od_policy_dbs_info *dbs_info = to_dbs_info(policy_dbs); |
72 | struct dbs_data *dbs_data = policy_dbs->dbs_data; | 72 | struct dbs_data *dbs_data = policy_dbs->dbs_data; |
73 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; | 73 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; |
74 | struct cpufreq_frequency_table *freq_table = policy->freq_table; | ||
74 | 75 | ||
75 | if (!dbs_info->freq_table) { | 76 | if (!freq_table) { |
76 | dbs_info->freq_lo = 0; | 77 | dbs_info->freq_lo = 0; |
77 | dbs_info->freq_lo_delay_us = 0; | 78 | dbs_info->freq_lo_delay_us = 0; |
78 | return freq_next; | 79 | return freq_next; |
79 | } | 80 | } |
80 | 81 | ||
81 | cpufreq_frequency_table_target(policy, dbs_info->freq_table, freq_next, | 82 | index = cpufreq_frequency_table_target(policy, freq_next, relation); |
82 | relation, &index); | 83 | freq_req = freq_table[index].frequency; |
83 | freq_req = dbs_info->freq_table[index].frequency; | ||
84 | freq_reduc = freq_req * od_tuners->powersave_bias / 1000; | 84 | freq_reduc = freq_req * od_tuners->powersave_bias / 1000; |
85 | freq_avg = freq_req - freq_reduc; | 85 | freq_avg = freq_req - freq_reduc; |
86 | 86 | ||
87 | /* Find freq bounds for freq_avg in freq_table */ | 87 | /* Find freq bounds for freq_avg in freq_table */ |
88 | index = 0; | 88 | index = cpufreq_frequency_table_target(policy, freq_avg, |
89 | cpufreq_frequency_table_target(policy, dbs_info->freq_table, freq_avg, | 89 | CPUFREQ_RELATION_H); |
90 | CPUFREQ_RELATION_H, &index); | 90 | freq_lo = freq_table[index].frequency; |
91 | freq_lo = dbs_info->freq_table[index].frequency; | 91 | index = cpufreq_frequency_table_target(policy, freq_avg, |
92 | index = 0; | 92 | CPUFREQ_RELATION_L); |
93 | cpufreq_frequency_table_target(policy, dbs_info->freq_table, freq_avg, | 93 | freq_hi = freq_table[index].frequency; |
94 | CPUFREQ_RELATION_L, &index); | ||
95 | freq_hi = dbs_info->freq_table[index].frequency; | ||
96 | 94 | ||
97 | /* Find out how long we have to be in hi and lo freqs */ | 95 | /* Find out how long we have to be in hi and lo freqs */ |
98 | if (freq_hi == freq_lo) { | 96 | if (freq_hi == freq_lo) { |
@@ -113,7 +111,6 @@ static void ondemand_powersave_bias_init(struct cpufreq_policy *policy) | |||
113 | { | 111 | { |
114 | struct od_policy_dbs_info *dbs_info = to_dbs_info(policy->governor_data); | 112 | struct od_policy_dbs_info *dbs_info = to_dbs_info(policy->governor_data); |
115 | 113 | ||
116 | dbs_info->freq_table = cpufreq_frequency_get_table(policy->cpu); | ||
117 | dbs_info->freq_lo = 0; | 114 | dbs_info->freq_lo = 0; |
118 | } | 115 | } |
119 | 116 | ||
@@ -361,17 +358,15 @@ static void od_free(struct policy_dbs_info *policy_dbs) | |||
361 | kfree(to_dbs_info(policy_dbs)); | 358 | kfree(to_dbs_info(policy_dbs)); |
362 | } | 359 | } |
363 | 360 | ||
364 | static int od_init(struct dbs_data *dbs_data, bool notify) | 361 | static int od_init(struct dbs_data *dbs_data) |
365 | { | 362 | { |
366 | struct od_dbs_tuners *tuners; | 363 | struct od_dbs_tuners *tuners; |
367 | u64 idle_time; | 364 | u64 idle_time; |
368 | int cpu; | 365 | int cpu; |
369 | 366 | ||
370 | tuners = kzalloc(sizeof(*tuners), GFP_KERNEL); | 367 | tuners = kzalloc(sizeof(*tuners), GFP_KERNEL); |
371 | if (!tuners) { | 368 | if (!tuners) |
372 | pr_err("%s: kzalloc failed\n", __func__); | ||
373 | return -ENOMEM; | 369 | return -ENOMEM; |
374 | } | ||
375 | 370 | ||
376 | cpu = get_cpu(); | 371 | cpu = get_cpu(); |
377 | idle_time = get_cpu_idle_time_us(cpu, NULL); | 372 | idle_time = get_cpu_idle_time_us(cpu, NULL); |
@@ -402,7 +397,7 @@ static int od_init(struct dbs_data *dbs_data, bool notify) | |||
402 | return 0; | 397 | return 0; |
403 | } | 398 | } |
404 | 399 | ||
405 | static void od_exit(struct dbs_data *dbs_data, bool notify) | 400 | static void od_exit(struct dbs_data *dbs_data) |
406 | { | 401 | { |
407 | kfree(dbs_data->tuners); | 402 | kfree(dbs_data->tuners); |
408 | } | 403 | } |
@@ -420,12 +415,7 @@ static struct od_ops od_ops = { | |||
420 | }; | 415 | }; |
421 | 416 | ||
422 | static struct dbs_governor od_dbs_gov = { | 417 | static struct dbs_governor od_dbs_gov = { |
423 | .gov = { | 418 | .gov = CPUFREQ_DBS_GOVERNOR_INITIALIZER("ondemand"), |
424 | .name = "ondemand", | ||
425 | .governor = cpufreq_governor_dbs, | ||
426 | .max_transition_latency = TRANSITION_LATENCY_LIMIT, | ||
427 | .owner = THIS_MODULE, | ||
428 | }, | ||
429 | .kobj_type = { .default_attrs = od_attributes }, | 419 | .kobj_type = { .default_attrs = od_attributes }, |
430 | .gov_dbs_timer = od_dbs_timer, | 420 | .gov_dbs_timer = od_dbs_timer, |
431 | .alloc = od_alloc, | 421 | .alloc = od_alloc, |
diff --git a/drivers/cpufreq/cpufreq_ondemand.h b/drivers/cpufreq/cpufreq_ondemand.h index f0121db3cd9e..640ea4e97106 100644 --- a/drivers/cpufreq/cpufreq_ondemand.h +++ b/drivers/cpufreq/cpufreq_ondemand.h | |||
@@ -13,7 +13,6 @@ | |||
13 | 13 | ||
14 | struct od_policy_dbs_info { | 14 | struct od_policy_dbs_info { |
15 | struct policy_dbs_info policy_dbs; | 15 | struct policy_dbs_info policy_dbs; |
16 | struct cpufreq_frequency_table *freq_table; | ||
17 | unsigned int freq_lo; | 16 | unsigned int freq_lo; |
18 | unsigned int freq_lo_delay_us; | 17 | unsigned int freq_lo_delay_us; |
19 | unsigned int freq_hi_delay_us; | 18 | unsigned int freq_hi_delay_us; |
diff --git a/drivers/cpufreq/cpufreq_performance.c b/drivers/cpufreq/cpufreq_performance.c index af9f4b96f5a8..dafb679adc58 100644 --- a/drivers/cpufreq/cpufreq_performance.c +++ b/drivers/cpufreq/cpufreq_performance.c | |||
@@ -16,27 +16,16 @@ | |||
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | 18 | ||
19 | static int cpufreq_governor_performance(struct cpufreq_policy *policy, | 19 | static void cpufreq_gov_performance_limits(struct cpufreq_policy *policy) |
20 | unsigned int event) | ||
21 | { | 20 | { |
22 | switch (event) { | 21 | pr_debug("setting to %u kHz\n", policy->max); |
23 | case CPUFREQ_GOV_START: | 22 | __cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H); |
24 | case CPUFREQ_GOV_LIMITS: | ||
25 | pr_debug("setting to %u kHz because of event %u\n", | ||
26 | policy->max, event); | ||
27 | __cpufreq_driver_target(policy, policy->max, | ||
28 | CPUFREQ_RELATION_H); | ||
29 | break; | ||
30 | default: | ||
31 | break; | ||
32 | } | ||
33 | return 0; | ||
34 | } | 23 | } |
35 | 24 | ||
36 | static struct cpufreq_governor cpufreq_gov_performance = { | 25 | static struct cpufreq_governor cpufreq_gov_performance = { |
37 | .name = "performance", | 26 | .name = "performance", |
38 | .governor = cpufreq_governor_performance, | ||
39 | .owner = THIS_MODULE, | 27 | .owner = THIS_MODULE, |
28 | .limits = cpufreq_gov_performance_limits, | ||
40 | }; | 29 | }; |
41 | 30 | ||
42 | static int __init cpufreq_gov_performance_init(void) | 31 | static int __init cpufreq_gov_performance_init(void) |
diff --git a/drivers/cpufreq/cpufreq_powersave.c b/drivers/cpufreq/cpufreq_powersave.c index b8b400232a74..78a651038faf 100644 --- a/drivers/cpufreq/cpufreq_powersave.c +++ b/drivers/cpufreq/cpufreq_powersave.c | |||
@@ -16,26 +16,15 @@ | |||
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | 18 | ||
19 | static int cpufreq_governor_powersave(struct cpufreq_policy *policy, | 19 | static void cpufreq_gov_powersave_limits(struct cpufreq_policy *policy) |
20 | unsigned int event) | ||
21 | { | 20 | { |
22 | switch (event) { | 21 | pr_debug("setting to %u kHz\n", policy->min); |
23 | case CPUFREQ_GOV_START: | 22 | __cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L); |
24 | case CPUFREQ_GOV_LIMITS: | ||
25 | pr_debug("setting to %u kHz because of event %u\n", | ||
26 | policy->min, event); | ||
27 | __cpufreq_driver_target(policy, policy->min, | ||
28 | CPUFREQ_RELATION_L); | ||
29 | break; | ||
30 | default: | ||
31 | break; | ||
32 | } | ||
33 | return 0; | ||
34 | } | 23 | } |
35 | 24 | ||
36 | static struct cpufreq_governor cpufreq_gov_powersave = { | 25 | static struct cpufreq_governor cpufreq_gov_powersave = { |
37 | .name = "powersave", | 26 | .name = "powersave", |
38 | .governor = cpufreq_governor_powersave, | 27 | .limits = cpufreq_gov_powersave_limits, |
39 | .owner = THIS_MODULE, | 28 | .owner = THIS_MODULE, |
40 | }; | 29 | }; |
41 | 30 | ||
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 5e370a30a964..06d3abdffd3a 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <linux/cputime.h> | 16 | #include <linux/cputime.h> |
17 | 17 | ||
18 | static spinlock_t cpufreq_stats_lock; | 18 | static DEFINE_SPINLOCK(cpufreq_stats_lock); |
19 | 19 | ||
20 | struct cpufreq_stats { | 20 | struct cpufreq_stats { |
21 | unsigned int total_trans; | 21 | unsigned int total_trans; |
@@ -52,6 +52,9 @@ static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf) | |||
52 | ssize_t len = 0; | 52 | ssize_t len = 0; |
53 | int i; | 53 | int i; |
54 | 54 | ||
55 | if (policy->fast_switch_enabled) | ||
56 | return 0; | ||
57 | |||
55 | cpufreq_stats_update(stats); | 58 | cpufreq_stats_update(stats); |
56 | for (i = 0; i < stats->state_num; i++) { | 59 | for (i = 0; i < stats->state_num; i++) { |
57 | len += sprintf(buf + len, "%u %llu\n", stats->freq_table[i], | 60 | len += sprintf(buf + len, "%u %llu\n", stats->freq_table[i], |
@@ -68,6 +71,9 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) | |||
68 | ssize_t len = 0; | 71 | ssize_t len = 0; |
69 | int i, j; | 72 | int i, j; |
70 | 73 | ||
74 | if (policy->fast_switch_enabled) | ||
75 | return 0; | ||
76 | |||
71 | len += snprintf(buf + len, PAGE_SIZE - len, " From : To\n"); | 77 | len += snprintf(buf + len, PAGE_SIZE - len, " From : To\n"); |
72 | len += snprintf(buf + len, PAGE_SIZE - len, " : "); | 78 | len += snprintf(buf + len, PAGE_SIZE - len, " : "); |
73 | for (i = 0; i < stats->state_num; i++) { | 79 | for (i = 0; i < stats->state_num; i++) { |
@@ -130,7 +136,7 @@ static int freq_table_get_index(struct cpufreq_stats *stats, unsigned int freq) | |||
130 | return -1; | 136 | return -1; |
131 | } | 137 | } |
132 | 138 | ||
133 | static void __cpufreq_stats_free_table(struct cpufreq_policy *policy) | 139 | void cpufreq_stats_free_table(struct cpufreq_policy *policy) |
134 | { | 140 | { |
135 | struct cpufreq_stats *stats = policy->stats; | 141 | struct cpufreq_stats *stats = policy->stats; |
136 | 142 | ||
@@ -146,39 +152,25 @@ static void __cpufreq_stats_free_table(struct cpufreq_policy *policy) | |||
146 | policy->stats = NULL; | 152 | policy->stats = NULL; |
147 | } | 153 | } |
148 | 154 | ||
149 | static void cpufreq_stats_free_table(unsigned int cpu) | 155 | void cpufreq_stats_create_table(struct cpufreq_policy *policy) |
150 | { | ||
151 | struct cpufreq_policy *policy; | ||
152 | |||
153 | policy = cpufreq_cpu_get(cpu); | ||
154 | if (!policy) | ||
155 | return; | ||
156 | |||
157 | __cpufreq_stats_free_table(policy); | ||
158 | |||
159 | cpufreq_cpu_put(policy); | ||
160 | } | ||
161 | |||
162 | static int __cpufreq_stats_create_table(struct cpufreq_policy *policy) | ||
163 | { | 156 | { |
164 | unsigned int i = 0, count = 0, ret = -ENOMEM; | 157 | unsigned int i = 0, count = 0, ret = -ENOMEM; |
165 | struct cpufreq_stats *stats; | 158 | struct cpufreq_stats *stats; |
166 | unsigned int alloc_size; | 159 | unsigned int alloc_size; |
167 | unsigned int cpu = policy->cpu; | ||
168 | struct cpufreq_frequency_table *pos, *table; | 160 | struct cpufreq_frequency_table *pos, *table; |
169 | 161 | ||
170 | /* We need cpufreq table for creating stats table */ | 162 | /* We need cpufreq table for creating stats table */ |
171 | table = cpufreq_frequency_get_table(cpu); | 163 | table = policy->freq_table; |
172 | if (unlikely(!table)) | 164 | if (unlikely(!table)) |
173 | return 0; | 165 | return; |
174 | 166 | ||
175 | /* stats already initialized */ | 167 | /* stats already initialized */ |
176 | if (policy->stats) | 168 | if (policy->stats) |
177 | return -EEXIST; | 169 | return; |
178 | 170 | ||
179 | stats = kzalloc(sizeof(*stats), GFP_KERNEL); | 171 | stats = kzalloc(sizeof(*stats), GFP_KERNEL); |
180 | if (!stats) | 172 | if (!stats) |
181 | return -ENOMEM; | 173 | return; |
182 | 174 | ||
183 | /* Find total allocation size */ | 175 | /* Find total allocation size */ |
184 | cpufreq_for_each_valid_entry(pos, table) | 176 | cpufreq_for_each_valid_entry(pos, table) |
@@ -215,80 +207,32 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy) | |||
215 | policy->stats = stats; | 207 | policy->stats = stats; |
216 | ret = sysfs_create_group(&policy->kobj, &stats_attr_group); | 208 | ret = sysfs_create_group(&policy->kobj, &stats_attr_group); |
217 | if (!ret) | 209 | if (!ret) |
218 | return 0; | 210 | return; |
219 | 211 | ||
220 | /* We failed, release resources */ | 212 | /* We failed, release resources */ |
221 | policy->stats = NULL; | 213 | policy->stats = NULL; |
222 | kfree(stats->time_in_state); | 214 | kfree(stats->time_in_state); |
223 | free_stat: | 215 | free_stat: |
224 | kfree(stats); | 216 | kfree(stats); |
225 | |||
226 | return ret; | ||
227 | } | ||
228 | |||
229 | static void cpufreq_stats_create_table(unsigned int cpu) | ||
230 | { | ||
231 | struct cpufreq_policy *policy; | ||
232 | |||
233 | /* | ||
234 | * "likely(!policy)" because normally cpufreq_stats will be registered | ||
235 | * before cpufreq driver | ||
236 | */ | ||
237 | policy = cpufreq_cpu_get(cpu); | ||
238 | if (likely(!policy)) | ||
239 | return; | ||
240 | |||
241 | __cpufreq_stats_create_table(policy); | ||
242 | |||
243 | cpufreq_cpu_put(policy); | ||
244 | } | 217 | } |
245 | 218 | ||
246 | static int cpufreq_stat_notifier_policy(struct notifier_block *nb, | 219 | void cpufreq_stats_record_transition(struct cpufreq_policy *policy, |
247 | unsigned long val, void *data) | 220 | unsigned int new_freq) |
248 | { | 221 | { |
249 | int ret = 0; | 222 | struct cpufreq_stats *stats = policy->stats; |
250 | struct cpufreq_policy *policy = data; | ||
251 | |||
252 | if (val == CPUFREQ_CREATE_POLICY) | ||
253 | ret = __cpufreq_stats_create_table(policy); | ||
254 | else if (val == CPUFREQ_REMOVE_POLICY) | ||
255 | __cpufreq_stats_free_table(policy); | ||
256 | |||
257 | return ret; | ||
258 | } | ||
259 | |||
260 | static int cpufreq_stat_notifier_trans(struct notifier_block *nb, | ||
261 | unsigned long val, void *data) | ||
262 | { | ||
263 | struct cpufreq_freqs *freq = data; | ||
264 | struct cpufreq_policy *policy = cpufreq_cpu_get(freq->cpu); | ||
265 | struct cpufreq_stats *stats; | ||
266 | int old_index, new_index; | 223 | int old_index, new_index; |
267 | 224 | ||
268 | if (!policy) { | 225 | if (!stats) { |
269 | pr_err("%s: No policy found\n", __func__); | ||
270 | return 0; | ||
271 | } | ||
272 | |||
273 | if (val != CPUFREQ_POSTCHANGE) | ||
274 | goto put_policy; | ||
275 | |||
276 | if (!policy->stats) { | ||
277 | pr_debug("%s: No stats found\n", __func__); | 226 | pr_debug("%s: No stats found\n", __func__); |
278 | goto put_policy; | 227 | return; |
279 | } | 228 | } |
280 | 229 | ||
281 | stats = policy->stats; | ||
282 | |||
283 | old_index = stats->last_index; | 230 | old_index = stats->last_index; |
284 | new_index = freq_table_get_index(stats, freq->new); | 231 | new_index = freq_table_get_index(stats, new_freq); |
285 | 232 | ||
286 | /* We can't do stats->time_in_state[-1]= .. */ | 233 | /* We can't do stats->time_in_state[-1]= .. */ |
287 | if (old_index == -1 || new_index == -1) | 234 | if (old_index == -1 || new_index == -1 || old_index == new_index) |
288 | goto put_policy; | 235 | return; |
289 | |||
290 | if (old_index == new_index) | ||
291 | goto put_policy; | ||
292 | 236 | ||
293 | cpufreq_stats_update(stats); | 237 | cpufreq_stats_update(stats); |
294 | 238 | ||
@@ -297,61 +241,4 @@ static int cpufreq_stat_notifier_trans(struct notifier_block *nb, | |||
297 | stats->trans_table[old_index * stats->max_state + new_index]++; | 241 | stats->trans_table[old_index * stats->max_state + new_index]++; |
298 | #endif | 242 | #endif |
299 | stats->total_trans++; | 243 | stats->total_trans++; |
300 | |||
301 | put_policy: | ||
302 | cpufreq_cpu_put(policy); | ||
303 | return 0; | ||
304 | } | 244 | } |
305 | |||
306 | static struct notifier_block notifier_policy_block = { | ||
307 | .notifier_call = cpufreq_stat_notifier_policy | ||
308 | }; | ||
309 | |||
310 | static struct notifier_block notifier_trans_block = { | ||
311 | .notifier_call = cpufreq_stat_notifier_trans | ||
312 | }; | ||
313 | |||
314 | static int __init cpufreq_stats_init(void) | ||
315 | { | ||
316 | int ret; | ||
317 | unsigned int cpu; | ||
318 | |||
319 | spin_lock_init(&cpufreq_stats_lock); | ||
320 | ret = cpufreq_register_notifier(¬ifier_policy_block, | ||
321 | CPUFREQ_POLICY_NOTIFIER); | ||
322 | if (ret) | ||
323 | return ret; | ||
324 | |||
325 | for_each_online_cpu(cpu) | ||
326 | cpufreq_stats_create_table(cpu); | ||
327 | |||
328 | ret = cpufreq_register_notifier(¬ifier_trans_block, | ||
329 | CPUFREQ_TRANSITION_NOTIFIER); | ||
330 | if (ret) { | ||
331 | cpufreq_unregister_notifier(¬ifier_policy_block, | ||
332 | CPUFREQ_POLICY_NOTIFIER); | ||
333 | for_each_online_cpu(cpu) | ||
334 | cpufreq_stats_free_table(cpu); | ||
335 | return ret; | ||
336 | } | ||
337 | |||
338 | return 0; | ||
339 | } | ||
340 | static void __exit cpufreq_stats_exit(void) | ||
341 | { | ||
342 | unsigned int cpu; | ||
343 | |||
344 | cpufreq_unregister_notifier(¬ifier_policy_block, | ||
345 | CPUFREQ_POLICY_NOTIFIER); | ||
346 | cpufreq_unregister_notifier(¬ifier_trans_block, | ||
347 | CPUFREQ_TRANSITION_NOTIFIER); | ||
348 | for_each_online_cpu(cpu) | ||
349 | cpufreq_stats_free_table(cpu); | ||
350 | } | ||
351 | |||
352 | MODULE_AUTHOR("Zou Nan hai <nanhai.zou@intel.com>"); | ||
353 | MODULE_DESCRIPTION("Export cpufreq stats via sysfs"); | ||
354 | MODULE_LICENSE("GPL"); | ||
355 | |||
356 | module_init(cpufreq_stats_init); | ||
357 | module_exit(cpufreq_stats_exit); | ||
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c index 9f3dec9a3f36..bd897e3e134d 100644 --- a/drivers/cpufreq/cpufreq_userspace.c +++ b/drivers/cpufreq/cpufreq_userspace.c | |||
@@ -65,66 +65,66 @@ static int cpufreq_userspace_policy_init(struct cpufreq_policy *policy) | |||
65 | return 0; | 65 | return 0; |
66 | } | 66 | } |
67 | 67 | ||
68 | static int cpufreq_governor_userspace(struct cpufreq_policy *policy, | 68 | static void cpufreq_userspace_policy_exit(struct cpufreq_policy *policy) |
69 | unsigned int event) | 69 | { |
70 | mutex_lock(&userspace_mutex); | ||
71 | kfree(policy->governor_data); | ||
72 | policy->governor_data = NULL; | ||
73 | mutex_unlock(&userspace_mutex); | ||
74 | } | ||
75 | |||
76 | static int cpufreq_userspace_policy_start(struct cpufreq_policy *policy) | ||
70 | { | 77 | { |
71 | unsigned int *setspeed = policy->governor_data; | 78 | unsigned int *setspeed = policy->governor_data; |
72 | unsigned int cpu = policy->cpu; | ||
73 | int rc = 0; | ||
74 | 79 | ||
75 | if (event == CPUFREQ_GOV_POLICY_INIT) | 80 | BUG_ON(!policy->cur); |
76 | return cpufreq_userspace_policy_init(policy); | 81 | pr_debug("started managing cpu %u\n", policy->cpu); |
77 | 82 | ||
78 | if (!setspeed) | 83 | mutex_lock(&userspace_mutex); |
79 | return -EINVAL; | 84 | per_cpu(cpu_is_managed, policy->cpu) = 1; |
80 | 85 | *setspeed = policy->cur; | |
81 | switch (event) { | 86 | mutex_unlock(&userspace_mutex); |
82 | case CPUFREQ_GOV_POLICY_EXIT: | 87 | return 0; |
83 | mutex_lock(&userspace_mutex); | 88 | } |
84 | policy->governor_data = NULL; | 89 | |
85 | kfree(setspeed); | 90 | static void cpufreq_userspace_policy_stop(struct cpufreq_policy *policy) |
86 | mutex_unlock(&userspace_mutex); | 91 | { |
87 | break; | 92 | unsigned int *setspeed = policy->governor_data; |
88 | case CPUFREQ_GOV_START: | 93 | |
89 | BUG_ON(!policy->cur); | 94 | pr_debug("managing cpu %u stopped\n", policy->cpu); |
90 | pr_debug("started managing cpu %u\n", cpu); | 95 | |
91 | 96 | mutex_lock(&userspace_mutex); | |
92 | mutex_lock(&userspace_mutex); | 97 | per_cpu(cpu_is_managed, policy->cpu) = 0; |
93 | per_cpu(cpu_is_managed, cpu) = 1; | 98 | *setspeed = 0; |
94 | *setspeed = policy->cur; | 99 | mutex_unlock(&userspace_mutex); |
95 | mutex_unlock(&userspace_mutex); | 100 | } |
96 | break; | 101 | |
97 | case CPUFREQ_GOV_STOP: | 102 | static void cpufreq_userspace_policy_limits(struct cpufreq_policy *policy) |
98 | pr_debug("managing cpu %u stopped\n", cpu); | 103 | { |
99 | 104 | unsigned int *setspeed = policy->governor_data; | |
100 | mutex_lock(&userspace_mutex); | 105 | |
101 | per_cpu(cpu_is_managed, cpu) = 0; | 106 | mutex_lock(&userspace_mutex); |
102 | *setspeed = 0; | 107 | |
103 | mutex_unlock(&userspace_mutex); | 108 | pr_debug("limit event for cpu %u: %u - %u kHz, currently %u kHz, last set to %u kHz\n", |
104 | break; | 109 | policy->cpu, policy->min, policy->max, policy->cur, *setspeed); |
105 | case CPUFREQ_GOV_LIMITS: | 110 | |
106 | mutex_lock(&userspace_mutex); | 111 | if (policy->max < *setspeed) |
107 | pr_debug("limit event for cpu %u: %u - %u kHz, currently %u kHz, last set to %u kHz\n", | 112 | __cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H); |
108 | cpu, policy->min, policy->max, policy->cur, *setspeed); | 113 | else if (policy->min > *setspeed) |
109 | 114 | __cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L); | |
110 | if (policy->max < *setspeed) | 115 | else |
111 | __cpufreq_driver_target(policy, policy->max, | 116 | __cpufreq_driver_target(policy, *setspeed, CPUFREQ_RELATION_L); |
112 | CPUFREQ_RELATION_H); | 117 | |
113 | else if (policy->min > *setspeed) | 118 | mutex_unlock(&userspace_mutex); |
114 | __cpufreq_driver_target(policy, policy->min, | ||
115 | CPUFREQ_RELATION_L); | ||
116 | else | ||
117 | __cpufreq_driver_target(policy, *setspeed, | ||
118 | CPUFREQ_RELATION_L); | ||
119 | mutex_unlock(&userspace_mutex); | ||
120 | break; | ||
121 | } | ||
122 | return rc; | ||
123 | } | 119 | } |
124 | 120 | ||
125 | static struct cpufreq_governor cpufreq_gov_userspace = { | 121 | static struct cpufreq_governor cpufreq_gov_userspace = { |
126 | .name = "userspace", | 122 | .name = "userspace", |
127 | .governor = cpufreq_governor_userspace, | 123 | .init = cpufreq_userspace_policy_init, |
124 | .exit = cpufreq_userspace_policy_exit, | ||
125 | .start = cpufreq_userspace_policy_start, | ||
126 | .stop = cpufreq_userspace_policy_stop, | ||
127 | .limits = cpufreq_userspace_policy_limits, | ||
128 | .store_setspeed = cpufreq_set, | 128 | .store_setspeed = cpufreq_set, |
129 | .show_setspeed = show_speed, | 129 | .show_setspeed = show_speed, |
130 | .owner = THIS_MODULE, | 130 | .owner = THIS_MODULE, |
diff --git a/drivers/cpufreq/davinci-cpufreq.c b/drivers/cpufreq/davinci-cpufreq.c index 7e336d20c184..b95a872800ec 100644 --- a/drivers/cpufreq/davinci-cpufreq.c +++ b/drivers/cpufreq/davinci-cpufreq.c | |||
@@ -38,26 +38,6 @@ struct davinci_cpufreq { | |||
38 | }; | 38 | }; |
39 | static struct davinci_cpufreq cpufreq; | 39 | static struct davinci_cpufreq cpufreq; |
40 | 40 | ||
41 | static int davinci_verify_speed(struct cpufreq_policy *policy) | ||
42 | { | ||
43 | struct davinci_cpufreq_config *pdata = cpufreq.dev->platform_data; | ||
44 | struct cpufreq_frequency_table *freq_table = pdata->freq_table; | ||
45 | struct clk *armclk = cpufreq.armclk; | ||
46 | |||
47 | if (freq_table) | ||
48 | return cpufreq_frequency_table_verify(policy, freq_table); | ||
49 | |||
50 | if (policy->cpu) | ||
51 | return -EINVAL; | ||
52 | |||
53 | cpufreq_verify_within_cpu_limits(policy); | ||
54 | policy->min = clk_round_rate(armclk, policy->min * 1000) / 1000; | ||
55 | policy->max = clk_round_rate(armclk, policy->max * 1000) / 1000; | ||
56 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | ||
57 | policy->cpuinfo.max_freq); | ||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | static int davinci_target(struct cpufreq_policy *policy, unsigned int idx) | 41 | static int davinci_target(struct cpufreq_policy *policy, unsigned int idx) |
62 | { | 42 | { |
63 | struct davinci_cpufreq_config *pdata = cpufreq.dev->platform_data; | 43 | struct davinci_cpufreq_config *pdata = cpufreq.dev->platform_data; |
@@ -121,7 +101,7 @@ static int davinci_cpu_init(struct cpufreq_policy *policy) | |||
121 | 101 | ||
122 | static struct cpufreq_driver davinci_driver = { | 102 | static struct cpufreq_driver davinci_driver = { |
123 | .flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK, | 103 | .flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK, |
124 | .verify = davinci_verify_speed, | 104 | .verify = cpufreq_generic_frequency_table_verify, |
125 | .target_index = davinci_target, | 105 | .target_index = davinci_target, |
126 | .get = cpufreq_generic_get, | 106 | .get = cpufreq_generic_get, |
127 | .init = davinci_cpu_init, | 107 | .init = davinci_cpu_init, |
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index a8f1daffc9bc..eac8bcbdaad1 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c | |||
@@ -63,8 +63,6 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, | |||
63 | else | 63 | else |
64 | return 0; | 64 | return 0; |
65 | } | 65 | } |
66 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_cpuinfo); | ||
67 | |||
68 | 66 | ||
69 | int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, | 67 | int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, |
70 | struct cpufreq_frequency_table *table) | 68 | struct cpufreq_frequency_table *table) |
@@ -108,20 +106,16 @@ EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify); | |||
108 | */ | 106 | */ |
109 | int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy) | 107 | int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy) |
110 | { | 108 | { |
111 | struct cpufreq_frequency_table *table = | 109 | if (!policy->freq_table) |
112 | cpufreq_frequency_get_table(policy->cpu); | ||
113 | if (!table) | ||
114 | return -ENODEV; | 110 | return -ENODEV; |
115 | 111 | ||
116 | return cpufreq_frequency_table_verify(policy, table); | 112 | return cpufreq_frequency_table_verify(policy, policy->freq_table); |
117 | } | 113 | } |
118 | EXPORT_SYMBOL_GPL(cpufreq_generic_frequency_table_verify); | 114 | EXPORT_SYMBOL_GPL(cpufreq_generic_frequency_table_verify); |
119 | 115 | ||
120 | int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | 116 | int cpufreq_frequency_table_target(struct cpufreq_policy *policy, |
121 | struct cpufreq_frequency_table *table, | 117 | unsigned int target_freq, |
122 | unsigned int target_freq, | 118 | unsigned int relation) |
123 | unsigned int relation, | ||
124 | unsigned int *index) | ||
125 | { | 119 | { |
126 | struct cpufreq_frequency_table optimal = { | 120 | struct cpufreq_frequency_table optimal = { |
127 | .driver_data = ~0, | 121 | .driver_data = ~0, |
@@ -132,7 +126,9 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | |||
132 | .frequency = 0, | 126 | .frequency = 0, |
133 | }; | 127 | }; |
134 | struct cpufreq_frequency_table *pos; | 128 | struct cpufreq_frequency_table *pos; |
129 | struct cpufreq_frequency_table *table = policy->freq_table; | ||
135 | unsigned int freq, diff, i = 0; | 130 | unsigned int freq, diff, i = 0; |
131 | int index; | ||
136 | 132 | ||
137 | pr_debug("request for target %u kHz (relation: %u) for cpu %u\n", | 133 | pr_debug("request for target %u kHz (relation: %u) for cpu %u\n", |
138 | target_freq, relation, policy->cpu); | 134 | target_freq, relation, policy->cpu); |
@@ -196,25 +192,26 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | |||
196 | } | 192 | } |
197 | } | 193 | } |
198 | if (optimal.driver_data > i) { | 194 | if (optimal.driver_data > i) { |
199 | if (suboptimal.driver_data > i) | 195 | if (suboptimal.driver_data > i) { |
200 | return -EINVAL; | 196 | WARN(1, "Invalid frequency table: %d\n", policy->cpu); |
201 | *index = suboptimal.driver_data; | 197 | return 0; |
202 | } else | 198 | } |
203 | *index = optimal.driver_data; | ||
204 | 199 | ||
205 | pr_debug("target index is %u, freq is:%u kHz\n", *index, | 200 | index = suboptimal.driver_data; |
206 | table[*index].frequency); | 201 | } else |
202 | index = optimal.driver_data; | ||
207 | 203 | ||
208 | return 0; | 204 | pr_debug("target index is %u, freq is:%u kHz\n", index, |
205 | table[index].frequency); | ||
206 | return index; | ||
209 | } | 207 | } |
210 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target); | 208 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target); |
211 | 209 | ||
212 | int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy, | 210 | int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy, |
213 | unsigned int freq) | 211 | unsigned int freq) |
214 | { | 212 | { |
215 | struct cpufreq_frequency_table *pos, *table; | 213 | struct cpufreq_frequency_table *pos, *table = policy->freq_table; |
216 | 214 | ||
217 | table = cpufreq_frequency_get_table(policy->cpu); | ||
218 | if (unlikely(!table)) { | 215 | if (unlikely(!table)) { |
219 | pr_debug("%s: Unable to find frequency table\n", __func__); | 216 | pr_debug("%s: Unable to find frequency table\n", __func__); |
220 | return -ENOENT; | 217 | return -ENOENT; |
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 1fa1a32928d7..f6dd07275862 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <asm/msr.h> | 35 | #include <asm/msr.h> |
36 | #include <asm/cpu_device_id.h> | 36 | #include <asm/cpu_device_id.h> |
37 | #include <asm/cpufeature.h> | 37 | #include <asm/cpufeature.h> |
38 | #include <asm/intel-family.h> | ||
38 | 39 | ||
39 | #define ATOM_RATIOS 0x66a | 40 | #define ATOM_RATIOS 0x66a |
40 | #define ATOM_VIDS 0x66b | 41 | #define ATOM_VIDS 0x66b |
@@ -281,9 +282,9 @@ struct cpu_defaults { | |||
281 | static inline int32_t get_target_pstate_use_performance(struct cpudata *cpu); | 282 | static inline int32_t get_target_pstate_use_performance(struct cpudata *cpu); |
282 | static inline int32_t get_target_pstate_use_cpu_load(struct cpudata *cpu); | 283 | static inline int32_t get_target_pstate_use_cpu_load(struct cpudata *cpu); |
283 | 284 | ||
284 | static struct pstate_adjust_policy pid_params; | 285 | static struct pstate_adjust_policy pid_params __read_mostly; |
285 | static struct pstate_funcs pstate_funcs; | 286 | static struct pstate_funcs pstate_funcs __read_mostly; |
286 | static int hwp_active; | 287 | static int hwp_active __read_mostly; |
287 | 288 | ||
288 | #ifdef CONFIG_ACPI | 289 | #ifdef CONFIG_ACPI |
289 | static bool acpi_ppc; | 290 | static bool acpi_ppc; |
@@ -1091,6 +1092,26 @@ static struct cpu_defaults knl_params = { | |||
1091 | }, | 1092 | }, |
1092 | }; | 1093 | }; |
1093 | 1094 | ||
1095 | static struct cpu_defaults bxt_params = { | ||
1096 | .pid_policy = { | ||
1097 | .sample_rate_ms = 10, | ||
1098 | .deadband = 0, | ||
1099 | .setpoint = 60, | ||
1100 | .p_gain_pct = 14, | ||
1101 | .d_gain_pct = 0, | ||
1102 | .i_gain_pct = 4, | ||
1103 | }, | ||
1104 | .funcs = { | ||
1105 | .get_max = core_get_max_pstate, | ||
1106 | .get_max_physical = core_get_max_pstate_physical, | ||
1107 | .get_min = core_get_min_pstate, | ||
1108 | .get_turbo = core_get_turbo_pstate, | ||
1109 | .get_scaling = core_get_scaling, | ||
1110 | .get_val = core_get_val, | ||
1111 | .get_target_pstate = get_target_pstate_use_cpu_load, | ||
1112 | }, | ||
1113 | }; | ||
1114 | |||
1094 | static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max) | 1115 | static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max) |
1095 | { | 1116 | { |
1096 | int max_perf = cpu->pstate.turbo_pstate; | 1117 | int max_perf = cpu->pstate.turbo_pstate; |
@@ -1334,29 +1355,30 @@ static void intel_pstate_update_util(struct update_util_data *data, u64 time, | |||
1334 | (unsigned long)&policy } | 1355 | (unsigned long)&policy } |
1335 | 1356 | ||
1336 | static const struct x86_cpu_id intel_pstate_cpu_ids[] = { | 1357 | static const struct x86_cpu_id intel_pstate_cpu_ids[] = { |
1337 | ICPU(0x2a, core_params), | 1358 | ICPU(INTEL_FAM6_SANDYBRIDGE, core_params), |
1338 | ICPU(0x2d, core_params), | 1359 | ICPU(INTEL_FAM6_SANDYBRIDGE_X, core_params), |
1339 | ICPU(0x37, silvermont_params), | 1360 | ICPU(INTEL_FAM6_ATOM_SILVERMONT1, silvermont_params), |
1340 | ICPU(0x3a, core_params), | 1361 | ICPU(INTEL_FAM6_IVYBRIDGE, core_params), |
1341 | ICPU(0x3c, core_params), | 1362 | ICPU(INTEL_FAM6_HASWELL_CORE, core_params), |
1342 | ICPU(0x3d, core_params), | 1363 | ICPU(INTEL_FAM6_BROADWELL_CORE, core_params), |
1343 | ICPU(0x3e, core_params), | 1364 | ICPU(INTEL_FAM6_IVYBRIDGE_X, core_params), |
1344 | ICPU(0x3f, core_params), | 1365 | ICPU(INTEL_FAM6_HASWELL_X, core_params), |
1345 | ICPU(0x45, core_params), | 1366 | ICPU(INTEL_FAM6_HASWELL_ULT, core_params), |
1346 | ICPU(0x46, core_params), | 1367 | ICPU(INTEL_FAM6_HASWELL_GT3E, core_params), |
1347 | ICPU(0x47, core_params), | 1368 | ICPU(INTEL_FAM6_BROADWELL_GT3E, core_params), |
1348 | ICPU(0x4c, airmont_params), | 1369 | ICPU(INTEL_FAM6_ATOM_AIRMONT, airmont_params), |
1349 | ICPU(0x4e, core_params), | 1370 | ICPU(INTEL_FAM6_SKYLAKE_MOBILE, core_params), |
1350 | ICPU(0x4f, core_params), | 1371 | ICPU(INTEL_FAM6_BROADWELL_X, core_params), |
1351 | ICPU(0x5e, core_params), | 1372 | ICPU(INTEL_FAM6_SKYLAKE_DESKTOP, core_params), |
1352 | ICPU(0x56, core_params), | 1373 | ICPU(INTEL_FAM6_BROADWELL_XEON_D, core_params), |
1353 | ICPU(0x57, knl_params), | 1374 | ICPU(INTEL_FAM6_XEON_PHI_KNL, knl_params), |
1375 | ICPU(INTEL_FAM6_ATOM_GOLDMONT, bxt_params), | ||
1354 | {} | 1376 | {} |
1355 | }; | 1377 | }; |
1356 | MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids); | 1378 | MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids); |
1357 | 1379 | ||
1358 | static const struct x86_cpu_id intel_pstate_cpu_oob_ids[] = { | 1380 | static const struct x86_cpu_id intel_pstate_cpu_oob_ids[] __initconst = { |
1359 | ICPU(0x56, core_params), | 1381 | ICPU(INTEL_FAM6_BROADWELL_XEON_D, core_params), |
1360 | {} | 1382 | {} |
1361 | }; | 1383 | }; |
1362 | 1384 | ||
@@ -1575,12 +1597,12 @@ static struct cpufreq_driver intel_pstate_driver = { | |||
1575 | .name = "intel_pstate", | 1597 | .name = "intel_pstate", |
1576 | }; | 1598 | }; |
1577 | 1599 | ||
1578 | static int __initdata no_load; | 1600 | static int no_load __initdata; |
1579 | static int __initdata no_hwp; | 1601 | static int no_hwp __initdata; |
1580 | static int __initdata hwp_only; | 1602 | static int hwp_only __initdata; |
1581 | static unsigned int force_load; | 1603 | static unsigned int force_load __initdata; |
1582 | 1604 | ||
1583 | static int intel_pstate_msrs_not_valid(void) | 1605 | static int __init intel_pstate_msrs_not_valid(void) |
1584 | { | 1606 | { |
1585 | if (!pstate_funcs.get_max() || | 1607 | if (!pstate_funcs.get_max() || |
1586 | !pstate_funcs.get_min() || | 1608 | !pstate_funcs.get_min() || |
@@ -1590,7 +1612,7 @@ static int intel_pstate_msrs_not_valid(void) | |||
1590 | return 0; | 1612 | return 0; |
1591 | } | 1613 | } |
1592 | 1614 | ||
1593 | static void copy_pid_params(struct pstate_adjust_policy *policy) | 1615 | static void __init copy_pid_params(struct pstate_adjust_policy *policy) |
1594 | { | 1616 | { |
1595 | pid_params.sample_rate_ms = policy->sample_rate_ms; | 1617 | pid_params.sample_rate_ms = policy->sample_rate_ms; |
1596 | pid_params.sample_rate_ns = pid_params.sample_rate_ms * NSEC_PER_MSEC; | 1618 | pid_params.sample_rate_ns = pid_params.sample_rate_ms * NSEC_PER_MSEC; |
@@ -1601,7 +1623,7 @@ static void copy_pid_params(struct pstate_adjust_policy *policy) | |||
1601 | pid_params.setpoint = policy->setpoint; | 1623 | pid_params.setpoint = policy->setpoint; |
1602 | } | 1624 | } |
1603 | 1625 | ||
1604 | static void copy_cpu_funcs(struct pstate_funcs *funcs) | 1626 | static void __init copy_cpu_funcs(struct pstate_funcs *funcs) |
1605 | { | 1627 | { |
1606 | pstate_funcs.get_max = funcs->get_max; | 1628 | pstate_funcs.get_max = funcs->get_max; |
1607 | pstate_funcs.get_max_physical = funcs->get_max_physical; | 1629 | pstate_funcs.get_max_physical = funcs->get_max_physical; |
@@ -1616,7 +1638,7 @@ static void copy_cpu_funcs(struct pstate_funcs *funcs) | |||
1616 | 1638 | ||
1617 | #ifdef CONFIG_ACPI | 1639 | #ifdef CONFIG_ACPI |
1618 | 1640 | ||
1619 | static bool intel_pstate_no_acpi_pss(void) | 1641 | static bool __init intel_pstate_no_acpi_pss(void) |
1620 | { | 1642 | { |
1621 | int i; | 1643 | int i; |
1622 | 1644 | ||
@@ -1645,7 +1667,7 @@ static bool intel_pstate_no_acpi_pss(void) | |||
1645 | return true; | 1667 | return true; |
1646 | } | 1668 | } |
1647 | 1669 | ||
1648 | static bool intel_pstate_has_acpi_ppc(void) | 1670 | static bool __init intel_pstate_has_acpi_ppc(void) |
1649 | { | 1671 | { |
1650 | int i; | 1672 | int i; |
1651 | 1673 | ||
@@ -1673,7 +1695,7 @@ struct hw_vendor_info { | |||
1673 | }; | 1695 | }; |
1674 | 1696 | ||
1675 | /* Hardware vendor-specific info that has its own power management modes */ | 1697 | /* Hardware vendor-specific info that has its own power management modes */ |
1676 | static struct hw_vendor_info vendor_info[] = { | 1698 | static struct hw_vendor_info vendor_info[] __initdata = { |
1677 | {1, "HP ", "ProLiant", PSS}, | 1699 | {1, "HP ", "ProLiant", PSS}, |
1678 | {1, "ORACLE", "X4-2 ", PPC}, | 1700 | {1, "ORACLE", "X4-2 ", PPC}, |
1679 | {1, "ORACLE", "X4-2L ", PPC}, | 1701 | {1, "ORACLE", "X4-2L ", PPC}, |
@@ -1692,7 +1714,7 @@ static struct hw_vendor_info vendor_info[] = { | |||
1692 | {0, "", ""}, | 1714 | {0, "", ""}, |
1693 | }; | 1715 | }; |
1694 | 1716 | ||
1695 | static bool intel_pstate_platform_pwr_mgmt_exists(void) | 1717 | static bool __init intel_pstate_platform_pwr_mgmt_exists(void) |
1696 | { | 1718 | { |
1697 | struct acpi_table_header hdr; | 1719 | struct acpi_table_header hdr; |
1698 | struct hw_vendor_info *v_info; | 1720 | struct hw_vendor_info *v_info; |
diff --git a/drivers/cpufreq/mvebu-cpufreq.c b/drivers/cpufreq/mvebu-cpufreq.c index e920889b9ac2..ed915ee85dd9 100644 --- a/drivers/cpufreq/mvebu-cpufreq.c +++ b/drivers/cpufreq/mvebu-cpufreq.c | |||
@@ -70,7 +70,7 @@ static int __init armada_xp_pmsu_cpufreq_init(void) | |||
70 | continue; | 70 | continue; |
71 | } | 71 | } |
72 | 72 | ||
73 | clk = clk_get(cpu_dev, 0); | 73 | clk = clk_get(cpu_dev, NULL); |
74 | if (IS_ERR(clk)) { | 74 | if (IS_ERR(clk)) { |
75 | pr_err("Cannot get clock for CPU %d\n", cpu); | 75 | pr_err("Cannot get clock for CPU %d\n", cpu); |
76 | return PTR_ERR(clk); | 76 | return PTR_ERR(clk); |
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c index 54c45368e3f1..b29c5c20c3a1 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c | |||
@@ -760,9 +760,8 @@ void powernv_cpufreq_work_fn(struct work_struct *work) | |||
760 | struct cpufreq_policy policy; | 760 | struct cpufreq_policy policy; |
761 | 761 | ||
762 | cpufreq_get_policy(&policy, cpu); | 762 | cpufreq_get_policy(&policy, cpu); |
763 | cpufreq_frequency_table_target(&policy, policy.freq_table, | 763 | index = cpufreq_frequency_table_target(&policy, policy.cur, |
764 | policy.cur, | 764 | CPUFREQ_RELATION_C); |
765 | CPUFREQ_RELATION_C, &index); | ||
766 | powernv_cpufreq_target_index(&policy, index); | 765 | powernv_cpufreq_target_index(&policy, index); |
767 | cpumask_andnot(&mask, &mask, policy.cpus); | 766 | cpumask_andnot(&mask, &mask, policy.cpus); |
768 | } | 767 | } |
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c b/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c index 7c4cd5c634f2..dc112481a408 100644 --- a/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c +++ b/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c | |||
@@ -94,7 +94,7 @@ static int pmi_notifier(struct notifier_block *nb, | |||
94 | unsigned long event, void *data) | 94 | unsigned long event, void *data) |
95 | { | 95 | { |
96 | struct cpufreq_policy *policy = data; | 96 | struct cpufreq_policy *policy = data; |
97 | struct cpufreq_frequency_table *cbe_freqs; | 97 | struct cpufreq_frequency_table *cbe_freqs = policy->freq_table; |
98 | u8 node; | 98 | u8 node; |
99 | 99 | ||
100 | /* Should this really be called for CPUFREQ_ADJUST and CPUFREQ_NOTIFY | 100 | /* Should this really be called for CPUFREQ_ADJUST and CPUFREQ_NOTIFY |
@@ -103,7 +103,6 @@ static int pmi_notifier(struct notifier_block *nb, | |||
103 | if (event == CPUFREQ_START) | 103 | if (event == CPUFREQ_START) |
104 | return 0; | 104 | return 0; |
105 | 105 | ||
106 | cbe_freqs = cpufreq_frequency_get_table(policy->cpu); | ||
107 | node = cbe_cpu_to_node(policy->cpu); | 106 | node = cbe_cpu_to_node(policy->cpu); |
108 | 107 | ||
109 | pr_debug("got notified, event=%lu, node=%u\n", event, node); | 108 | pr_debug("got notified, event=%lu, node=%u\n", event, node); |
diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c index ae8eaed77b70..7b596fa38ad2 100644 --- a/drivers/cpufreq/s3c24xx-cpufreq.c +++ b/drivers/cpufreq/s3c24xx-cpufreq.c | |||
@@ -293,12 +293,8 @@ static int s3c_cpufreq_target(struct cpufreq_policy *policy, | |||
293 | __func__, policy, target_freq, relation); | 293 | __func__, policy, target_freq, relation); |
294 | 294 | ||
295 | if (ftab) { | 295 | if (ftab) { |
296 | if (cpufreq_frequency_table_target(policy, ftab, | 296 | index = cpufreq_frequency_table_target(policy, target_freq, |
297 | target_freq, relation, | 297 | relation); |
298 | &index)) { | ||
299 | s3c_freq_dbg("%s: table failed\n", __func__); | ||
300 | return -EINVAL; | ||
301 | } | ||
302 | 298 | ||
303 | s3c_freq_dbg("%s: adjust %d to entry %d (%u)\n", __func__, | 299 | s3c_freq_dbg("%s: adjust %d to entry %d (%u)\n", __func__, |
304 | target_freq, index, ftab[index].frequency); | 300 | target_freq, index, ftab[index].frequency); |
@@ -315,7 +311,6 @@ static int s3c_cpufreq_target(struct cpufreq_policy *policy, | |||
315 | pll = NULL; | 311 | pll = NULL; |
316 | } else { | 312 | } else { |
317 | struct cpufreq_policy tmp_policy; | 313 | struct cpufreq_policy tmp_policy; |
318 | int ret; | ||
319 | 314 | ||
320 | /* we keep the cpu pll table in Hz, to ensure we get an | 315 | /* we keep the cpu pll table in Hz, to ensure we get an |
321 | * accurate value for the PLL output. */ | 316 | * accurate value for the PLL output. */ |
@@ -323,20 +318,14 @@ static int s3c_cpufreq_target(struct cpufreq_policy *policy, | |||
323 | tmp_policy.min = policy->min * 1000; | 318 | tmp_policy.min = policy->min * 1000; |
324 | tmp_policy.max = policy->max * 1000; | 319 | tmp_policy.max = policy->max * 1000; |
325 | tmp_policy.cpu = policy->cpu; | 320 | tmp_policy.cpu = policy->cpu; |
321 | tmp_policy.freq_table = pll_reg; | ||
326 | 322 | ||
327 | /* cpufreq_frequency_table_target uses a pointer to 'index' | 323 | /* cpufreq_frequency_table_target returns the index |
328 | * which is the number of the table entry, not the value of | 324 | * of the table entry, not the value of |
329 | * the table entry's index field. */ | 325 | * the table entry's index field. */ |
330 | 326 | ||
331 | ret = cpufreq_frequency_table_target(&tmp_policy, pll_reg, | 327 | index = cpufreq_frequency_table_target(&tmp_policy, target_freq, |
332 | target_freq, relation, | 328 | relation); |
333 | &index); | ||
334 | |||
335 | if (ret < 0) { | ||
336 | pr_err("%s: no PLL available\n", __func__); | ||
337 | goto err_notpossible; | ||
338 | } | ||
339 | |||
340 | pll = pll_reg + index; | 329 | pll = pll_reg + index; |
341 | 330 | ||
342 | s3c_freq_dbg("%s: target %u => %u\n", | 331 | s3c_freq_dbg("%s: target %u => %u\n", |
@@ -346,10 +335,6 @@ static int s3c_cpufreq_target(struct cpufreq_policy *policy, | |||
346 | } | 335 | } |
347 | 336 | ||
348 | return s3c_cpufreq_settarget(policy, target_freq, pll); | 337 | return s3c_cpufreq_settarget(policy, target_freq, pll); |
349 | |||
350 | err_notpossible: | ||
351 | pr_err("no compatible settings for %d\n", target_freq); | ||
352 | return -EINVAL; | ||
353 | } | 338 | } |
354 | 339 | ||
355 | struct clk *s3c_cpufreq_clk_get(struct device *dev, const char *name) | 340 | struct clk *s3c_cpufreq_clk_get(struct device *dev, const char *name) |
@@ -571,11 +556,7 @@ static int s3c_cpufreq_build_freq(void) | |||
571 | { | 556 | { |
572 | int size, ret; | 557 | int size, ret; |
573 | 558 | ||
574 | if (!cpu_cur.info->calc_freqtable) | ||
575 | return -EINVAL; | ||
576 | |||
577 | kfree(ftab); | 559 | kfree(ftab); |
578 | ftab = NULL; | ||
579 | 560 | ||
580 | size = cpu_cur.info->calc_freqtable(&cpu_cur, NULL, 0); | 561 | size = cpu_cur.info->calc_freqtable(&cpu_cur, NULL, 0); |
581 | size++; | 562 | size++; |
diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c index 06d85917b6d5..4f4e9df9b7fc 100644 --- a/drivers/cpufreq/s5pv210-cpufreq.c +++ b/drivers/cpufreq/s5pv210-cpufreq.c | |||
@@ -246,12 +246,8 @@ static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index) | |||
246 | new_freq = s5pv210_freq_table[index].frequency; | 246 | new_freq = s5pv210_freq_table[index].frequency; |
247 | 247 | ||
248 | /* Finding current running level index */ | 248 | /* Finding current running level index */ |
249 | if (cpufreq_frequency_table_target(policy, s5pv210_freq_table, | 249 | priv_index = cpufreq_frequency_table_target(policy, old_freq, |
250 | old_freq, CPUFREQ_RELATION_H, | 250 | CPUFREQ_RELATION_H); |
251 | &priv_index)) { | ||
252 | ret = -EINVAL; | ||
253 | goto exit; | ||
254 | } | ||
255 | 251 | ||
256 | arm_volt = dvs_conf[index].arm_volt; | 252 | arm_volt = dvs_conf[index].arm_volt; |
257 | int_volt = dvs_conf[index].int_volt; | 253 | int_volt = dvs_conf[index].int_volt; |