diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2013-10-30 15:44:40 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-10-30 19:10:53 -0400 |
commit | e79a23c5b9870b7f80425793abeb10e57f7486d4 (patch) | |
tree | c957d3a1c803ba71fc030b016e902f2bee6d81af | |
parent | 9e941b6f42cc2b0d53011d62d639140c84116f59 (diff) |
cpufreq: arm_big_little: add in-kernel switching (IKS) support
This patch adds IKS (In Kernel Switcher) support to cpufreq driver.
This creates a combined freq table for A7-A15 CPU pairs. A7 frequencies
are virtualized and scaled down to half the actual frequencies to
approximate a linear scale across the combined A7+A15 range. When the
requested frequency change crosses the A7-A15 boundary a cluster switch
is invoked.
Based on earlier work from Sudeep KarkadaNagesha.
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/cpufreq/arm_big_little.c | 363 | ||||
-rw-r--r-- | drivers/cpufreq/arm_big_little.h | 5 |
2 files changed, 337 insertions, 31 deletions
diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c index 163e3378fe17..9986f7912328 100644 --- a/drivers/cpufreq/arm_big_little.c +++ b/drivers/cpufreq/arm_big_little.c | |||
@@ -24,27 +24,165 @@ | |||
24 | #include <linux/cpufreq.h> | 24 | #include <linux/cpufreq.h> |
25 | #include <linux/cpumask.h> | 25 | #include <linux/cpumask.h> |
26 | #include <linux/export.h> | 26 | #include <linux/export.h> |
27 | #include <linux/mutex.h> | ||
27 | #include <linux/of_platform.h> | 28 | #include <linux/of_platform.h> |
28 | #include <linux/pm_opp.h> | 29 | #include <linux/pm_opp.h> |
29 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
30 | #include <linux/topology.h> | 31 | #include <linux/topology.h> |
31 | #include <linux/types.h> | 32 | #include <linux/types.h> |
33 | #include <asm/bL_switcher.h> | ||
32 | 34 | ||
33 | #include "arm_big_little.h" | 35 | #include "arm_big_little.h" |
34 | 36 | ||
35 | /* Currently we support only two clusters */ | 37 | /* Currently we support only two clusters */ |
38 | #define A15_CLUSTER 0 | ||
39 | #define A7_CLUSTER 1 | ||
36 | #define MAX_CLUSTERS 2 | 40 | #define MAX_CLUSTERS 2 |
37 | 41 | ||
42 | #ifdef CONFIG_BL_SWITCHER | ||
43 | #define is_bL_switching_enabled() true | ||
44 | #else | ||
45 | #define is_bL_switching_enabled() false | ||
46 | #endif | ||
47 | |||
48 | #define ACTUAL_FREQ(cluster, freq) ((cluster == A7_CLUSTER) ? freq << 1 : freq) | ||
49 | #define VIRT_FREQ(cluster, freq) ((cluster == A7_CLUSTER) ? freq >> 1 : freq) | ||
50 | |||
38 | static struct cpufreq_arm_bL_ops *arm_bL_ops; | 51 | static struct cpufreq_arm_bL_ops *arm_bL_ops; |
39 | static struct clk *clk[MAX_CLUSTERS]; | 52 | static struct clk *clk[MAX_CLUSTERS]; |
40 | static struct cpufreq_frequency_table *freq_table[MAX_CLUSTERS]; | 53 | static struct cpufreq_frequency_table *freq_table[MAX_CLUSTERS + 1]; |
41 | static atomic_t cluster_usage[MAX_CLUSTERS] = {ATOMIC_INIT(0), ATOMIC_INIT(0)}; | 54 | static atomic_t cluster_usage[MAX_CLUSTERS + 1]; |
55 | |||
56 | static unsigned int clk_big_min; /* (Big) clock frequencies */ | ||
57 | static unsigned int clk_little_max; /* Maximum clock frequency (Little) */ | ||
58 | |||
59 | static DEFINE_PER_CPU(unsigned int, physical_cluster); | ||
60 | static DEFINE_PER_CPU(unsigned int, cpu_last_req_freq); | ||
61 | |||
62 | static struct mutex cluster_lock[MAX_CLUSTERS]; | ||
63 | |||
64 | static inline int raw_cpu_to_cluster(int cpu) | ||
65 | { | ||
66 | return topology_physical_package_id(cpu); | ||
67 | } | ||
68 | |||
69 | static inline int cpu_to_cluster(int cpu) | ||
70 | { | ||
71 | return is_bL_switching_enabled() ? | ||
72 | MAX_CLUSTERS : raw_cpu_to_cluster(cpu); | ||
73 | } | ||
74 | |||
75 | static unsigned int find_cluster_maxfreq(int cluster) | ||
76 | { | ||
77 | int j; | ||
78 | u32 max_freq = 0, cpu_freq; | ||
79 | |||
80 | for_each_online_cpu(j) { | ||
81 | cpu_freq = per_cpu(cpu_last_req_freq, j); | ||
82 | |||
83 | if ((cluster == per_cpu(physical_cluster, j)) && | ||
84 | (max_freq < cpu_freq)) | ||
85 | max_freq = cpu_freq; | ||
86 | } | ||
87 | |||
88 | pr_debug("%s: cluster: %d, max freq: %d\n", __func__, cluster, | ||
89 | max_freq); | ||
90 | |||
91 | return max_freq; | ||
92 | } | ||
93 | |||
94 | static unsigned int clk_get_cpu_rate(unsigned int cpu) | ||
95 | { | ||
96 | u32 cur_cluster = per_cpu(physical_cluster, cpu); | ||
97 | u32 rate = clk_get_rate(clk[cur_cluster]) / 1000; | ||
98 | |||
99 | /* For switcher we use virtual A7 clock rates */ | ||
100 | if (is_bL_switching_enabled()) | ||
101 | rate = VIRT_FREQ(cur_cluster, rate); | ||
102 | |||
103 | pr_debug("%s: cpu: %d, cluster: %d, freq: %u\n", __func__, cpu, | ||
104 | cur_cluster, rate); | ||
105 | |||
106 | return rate; | ||
107 | } | ||
108 | |||
109 | static unsigned int bL_cpufreq_get_rate(unsigned int cpu) | ||
110 | { | ||
111 | if (is_bL_switching_enabled()) { | ||
112 | pr_debug("%s: freq: %d\n", __func__, per_cpu(cpu_last_req_freq, | ||
113 | cpu)); | ||
114 | |||
115 | return per_cpu(cpu_last_req_freq, cpu); | ||
116 | } else { | ||
117 | return clk_get_cpu_rate(cpu); | ||
118 | } | ||
119 | } | ||
42 | 120 | ||
43 | static unsigned int bL_cpufreq_get(unsigned int cpu) | 121 | static unsigned int |
122 | bL_cpufreq_set_rate(u32 cpu, u32 old_cluster, u32 new_cluster, u32 rate) | ||
44 | { | 123 | { |
45 | u32 cur_cluster = cpu_to_cluster(cpu); | 124 | u32 new_rate, prev_rate; |
125 | int ret; | ||
126 | bool bLs = is_bL_switching_enabled(); | ||
127 | |||
128 | mutex_lock(&cluster_lock[new_cluster]); | ||
129 | |||
130 | if (bLs) { | ||
131 | prev_rate = per_cpu(cpu_last_req_freq, cpu); | ||
132 | per_cpu(cpu_last_req_freq, cpu) = rate; | ||
133 | per_cpu(physical_cluster, cpu) = new_cluster; | ||
134 | |||
135 | new_rate = find_cluster_maxfreq(new_cluster); | ||
136 | new_rate = ACTUAL_FREQ(new_cluster, new_rate); | ||
137 | } else { | ||
138 | new_rate = rate; | ||
139 | } | ||
140 | |||
141 | pr_debug("%s: cpu: %d, old cluster: %d, new cluster: %d, freq: %d\n", | ||
142 | __func__, cpu, old_cluster, new_cluster, new_rate); | ||
143 | |||
144 | ret = clk_set_rate(clk[new_cluster], new_rate * 1000); | ||
145 | if (WARN_ON(ret)) { | ||
146 | pr_err("clk_set_rate failed: %d, new cluster: %d\n", ret, | ||
147 | new_cluster); | ||
148 | if (bLs) { | ||
149 | per_cpu(cpu_last_req_freq, cpu) = prev_rate; | ||
150 | per_cpu(physical_cluster, cpu) = old_cluster; | ||
151 | } | ||
152 | |||
153 | mutex_unlock(&cluster_lock[new_cluster]); | ||
154 | |||
155 | return ret; | ||
156 | } | ||
157 | |||
158 | mutex_unlock(&cluster_lock[new_cluster]); | ||
159 | |||
160 | /* Recalc freq for old cluster when switching clusters */ | ||
161 | if (old_cluster != new_cluster) { | ||
162 | pr_debug("%s: cpu: %d, old cluster: %d, new cluster: %d\n", | ||
163 | __func__, cpu, old_cluster, new_cluster); | ||
164 | |||
165 | /* Switch cluster */ | ||
166 | bL_switch_request(cpu, new_cluster); | ||
167 | |||
168 | mutex_lock(&cluster_lock[old_cluster]); | ||
46 | 169 | ||
47 | return clk_get_rate(clk[cur_cluster]) / 1000; | 170 | /* Set freq of old cluster if there are cpus left on it */ |
171 | new_rate = find_cluster_maxfreq(old_cluster); | ||
172 | new_rate = ACTUAL_FREQ(old_cluster, new_rate); | ||
173 | |||
174 | if (new_rate) { | ||
175 | pr_debug("%s: Updating rate of old cluster: %d, to freq: %d\n", | ||
176 | __func__, old_cluster, new_rate); | ||
177 | |||
178 | if (clk_set_rate(clk[old_cluster], new_rate * 1000)) | ||
179 | pr_err("%s: clk_set_rate failed: %d, old cluster: %d\n", | ||
180 | __func__, ret, old_cluster); | ||
181 | } | ||
182 | mutex_unlock(&cluster_lock[old_cluster]); | ||
183 | } | ||
184 | |||
185 | return 0; | ||
48 | } | 186 | } |
49 | 187 | ||
50 | /* Set clock frequency */ | 188 | /* Set clock frequency */ |
@@ -52,63 +190,164 @@ static int bL_cpufreq_set_target(struct cpufreq_policy *policy, | |||
52 | unsigned int index) | 190 | unsigned int index) |
53 | { | 191 | { |
54 | struct cpufreq_freqs freqs; | 192 | struct cpufreq_freqs freqs; |
55 | u32 cpu = policy->cpu, cur_cluster; | 193 | u32 cpu = policy->cpu, cur_cluster, new_cluster, actual_cluster; |
56 | int ret = 0; | 194 | int ret = 0; |
57 | 195 | ||
58 | cur_cluster = cpu_to_cluster(policy->cpu); | 196 | cur_cluster = cpu_to_cluster(cpu); |
197 | new_cluster = actual_cluster = per_cpu(physical_cluster, cpu); | ||
59 | 198 | ||
60 | freqs.old = bL_cpufreq_get(policy->cpu); | 199 | freqs.old = bL_cpufreq_get_rate(cpu); |
61 | freqs.new = freq_table[cur_cluster][index].frequency; | 200 | freqs.new = freq_table[cur_cluster][index].frequency; |
62 | 201 | ||
63 | pr_debug("%s: cpu: %d, cluster: %d, oldfreq: %d, target freq: %d, new freq: %d\n", | 202 | pr_debug("%s: cpu: %d, cluster: %d, oldfreq: %d, target freq: %d, new freq: %d\n", |
64 | __func__, cpu, cur_cluster, freqs.old, freqs.new, | 203 | __func__, cpu, cur_cluster, freqs.old, freqs.new, |
65 | freqs.new); | 204 | freqs.new); |
66 | 205 | ||
206 | if (is_bL_switching_enabled()) { | ||
207 | if ((actual_cluster == A15_CLUSTER) && | ||
208 | (freqs.new < clk_big_min)) { | ||
209 | new_cluster = A7_CLUSTER; | ||
210 | } else if ((actual_cluster == A7_CLUSTER) && | ||
211 | (freqs.new > clk_little_max)) { | ||
212 | new_cluster = A15_CLUSTER; | ||
213 | } | ||
214 | } | ||
215 | |||
67 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | 216 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
68 | 217 | ||
69 | ret = clk_set_rate(clk[cur_cluster], freqs.new * 1000); | 218 | ret = bL_cpufreq_set_rate(cpu, actual_cluster, new_cluster, freqs.new); |
70 | if (ret) { | 219 | if (ret) |
71 | pr_err("clk_set_rate failed: %d\n", ret); | ||
72 | freqs.new = freqs.old; | 220 | freqs.new = freqs.old; |
73 | } | ||
74 | 221 | ||
75 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 222 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
76 | 223 | ||
77 | return ret; | 224 | return ret; |
78 | } | 225 | } |
79 | 226 | ||
227 | static inline u32 get_table_count(struct cpufreq_frequency_table *table) | ||
228 | { | ||
229 | int count; | ||
230 | |||
231 | for (count = 0; table[count].frequency != CPUFREQ_TABLE_END; count++) | ||
232 | ; | ||
233 | |||
234 | return count; | ||
235 | } | ||
236 | |||
237 | /* get the minimum frequency in the cpufreq_frequency_table */ | ||
238 | static inline u32 get_table_min(struct cpufreq_frequency_table *table) | ||
239 | { | ||
240 | int i; | ||
241 | uint32_t min_freq = ~0; | ||
242 | for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) | ||
243 | if (table[i].frequency < min_freq) | ||
244 | min_freq = table[i].frequency; | ||
245 | return min_freq; | ||
246 | } | ||
247 | |||
248 | /* get the maximum frequency in the cpufreq_frequency_table */ | ||
249 | static inline u32 get_table_max(struct cpufreq_frequency_table *table) | ||
250 | { | ||
251 | int i; | ||
252 | uint32_t max_freq = 0; | ||
253 | for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) | ||
254 | if (table[i].frequency > max_freq) | ||
255 | max_freq = table[i].frequency; | ||
256 | return max_freq; | ||
257 | } | ||
258 | |||
259 | static int merge_cluster_tables(void) | ||
260 | { | ||
261 | int i, j, k = 0, count = 1; | ||
262 | struct cpufreq_frequency_table *table; | ||
263 | |||
264 | for (i = 0; i < MAX_CLUSTERS; i++) | ||
265 | count += get_table_count(freq_table[i]); | ||
266 | |||
267 | table = kzalloc(sizeof(*table) * count, GFP_KERNEL); | ||
268 | if (!table) | ||
269 | return -ENOMEM; | ||
270 | |||
271 | freq_table[MAX_CLUSTERS] = table; | ||
272 | |||
273 | /* Add in reverse order to get freqs in increasing order */ | ||
274 | for (i = MAX_CLUSTERS - 1; i >= 0; i--) { | ||
275 | for (j = 0; freq_table[i][j].frequency != CPUFREQ_TABLE_END; | ||
276 | j++) { | ||
277 | table[k].frequency = VIRT_FREQ(i, | ||
278 | freq_table[i][j].frequency); | ||
279 | pr_debug("%s: index: %d, freq: %d\n", __func__, k, | ||
280 | table[k].frequency); | ||
281 | k++; | ||
282 | } | ||
283 | } | ||
284 | |||
285 | table[k].driver_data = k; | ||
286 | table[k].frequency = CPUFREQ_TABLE_END; | ||
287 | |||
288 | pr_debug("%s: End, table: %p, count: %d\n", __func__, table, k); | ||
289 | |||
290 | return 0; | ||
291 | } | ||
292 | |||
293 | static void _put_cluster_clk_and_freq_table(struct device *cpu_dev) | ||
294 | { | ||
295 | u32 cluster = raw_cpu_to_cluster(cpu_dev->id); | ||
296 | |||
297 | if (!freq_table[cluster]) | ||
298 | return; | ||
299 | |||
300 | clk_put(clk[cluster]); | ||
301 | dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table[cluster]); | ||
302 | dev_dbg(cpu_dev, "%s: cluster: %d\n", __func__, cluster); | ||
303 | } | ||
304 | |||
80 | static void put_cluster_clk_and_freq_table(struct device *cpu_dev) | 305 | static void put_cluster_clk_and_freq_table(struct device *cpu_dev) |
81 | { | 306 | { |
82 | u32 cluster = cpu_to_cluster(cpu_dev->id); | 307 | u32 cluster = cpu_to_cluster(cpu_dev->id); |
308 | int i; | ||
309 | |||
310 | if (atomic_dec_return(&cluster_usage[cluster])) | ||
311 | return; | ||
312 | |||
313 | if (cluster < MAX_CLUSTERS) | ||
314 | return _put_cluster_clk_and_freq_table(cpu_dev); | ||
83 | 315 | ||
84 | if (!atomic_dec_return(&cluster_usage[cluster])) { | 316 | for_each_present_cpu(i) { |
85 | clk_put(clk[cluster]); | 317 | struct device *cdev = get_cpu_device(i); |
86 | dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table[cluster]); | 318 | if (!cdev) { |
87 | dev_dbg(cpu_dev, "%s: cluster: %d\n", __func__, cluster); | 319 | pr_err("%s: failed to get cpu%d device\n", __func__, i); |
320 | return; | ||
321 | } | ||
322 | |||
323 | _put_cluster_clk_and_freq_table(cdev); | ||
88 | } | 324 | } |
325 | |||
326 | /* free virtual table */ | ||
327 | kfree(freq_table[cluster]); | ||
89 | } | 328 | } |
90 | 329 | ||
91 | static int get_cluster_clk_and_freq_table(struct device *cpu_dev) | 330 | static int _get_cluster_clk_and_freq_table(struct device *cpu_dev) |
92 | { | 331 | { |
93 | u32 cluster = cpu_to_cluster(cpu_dev->id); | 332 | u32 cluster = raw_cpu_to_cluster(cpu_dev->id); |
94 | char name[14] = "cpu-cluster."; | 333 | char name[14] = "cpu-cluster."; |
95 | int ret; | 334 | int ret; |
96 | 335 | ||
97 | if (atomic_inc_return(&cluster_usage[cluster]) != 1) | 336 | if (freq_table[cluster]) |
98 | return 0; | 337 | return 0; |
99 | 338 | ||
100 | ret = arm_bL_ops->init_opp_table(cpu_dev); | 339 | ret = arm_bL_ops->init_opp_table(cpu_dev); |
101 | if (ret) { | 340 | if (ret) { |
102 | dev_err(cpu_dev, "%s: init_opp_table failed, cpu: %d, err: %d\n", | 341 | dev_err(cpu_dev, "%s: init_opp_table failed, cpu: %d, err: %d\n", |
103 | __func__, cpu_dev->id, ret); | 342 | __func__, cpu_dev->id, ret); |
104 | goto atomic_dec; | 343 | goto out; |
105 | } | 344 | } |
106 | 345 | ||
107 | ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table[cluster]); | 346 | ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table[cluster]); |
108 | if (ret) { | 347 | if (ret) { |
109 | dev_err(cpu_dev, "%s: failed to init cpufreq table, cpu: %d, err: %d\n", | 348 | dev_err(cpu_dev, "%s: failed to init cpufreq table, cpu: %d, err: %d\n", |
110 | __func__, cpu_dev->id, ret); | 349 | __func__, cpu_dev->id, ret); |
111 | goto atomic_dec; | 350 | goto out; |
112 | } | 351 | } |
113 | 352 | ||
114 | name[12] = cluster + '0'; | 353 | name[12] = cluster + '0'; |
@@ -125,13 +364,72 @@ static int get_cluster_clk_and_freq_table(struct device *cpu_dev) | |||
125 | ret = PTR_ERR(clk[cluster]); | 364 | ret = PTR_ERR(clk[cluster]); |
126 | dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table[cluster]); | 365 | dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table[cluster]); |
127 | 366 | ||
128 | atomic_dec: | 367 | out: |
129 | atomic_dec(&cluster_usage[cluster]); | ||
130 | dev_err(cpu_dev, "%s: Failed to get data for cluster: %d\n", __func__, | 368 | dev_err(cpu_dev, "%s: Failed to get data for cluster: %d\n", __func__, |
131 | cluster); | 369 | cluster); |
132 | return ret; | 370 | return ret; |
133 | } | 371 | } |
134 | 372 | ||
373 | static int get_cluster_clk_and_freq_table(struct device *cpu_dev) | ||
374 | { | ||
375 | u32 cluster = cpu_to_cluster(cpu_dev->id); | ||
376 | int i, ret; | ||
377 | |||
378 | if (atomic_inc_return(&cluster_usage[cluster]) != 1) | ||
379 | return 0; | ||
380 | |||
381 | if (cluster < MAX_CLUSTERS) { | ||
382 | ret = _get_cluster_clk_and_freq_table(cpu_dev); | ||
383 | if (ret) | ||
384 | atomic_dec(&cluster_usage[cluster]); | ||
385 | return ret; | ||
386 | } | ||
387 | |||
388 | /* | ||
389 | * Get data for all clusters and fill virtual cluster with a merge of | ||
390 | * both | ||
391 | */ | ||
392 | for_each_present_cpu(i) { | ||
393 | struct device *cdev = get_cpu_device(i); | ||
394 | if (!cdev) { | ||
395 | pr_err("%s: failed to get cpu%d device\n", __func__, i); | ||
396 | return -ENODEV; | ||
397 | } | ||
398 | |||
399 | ret = _get_cluster_clk_and_freq_table(cdev); | ||
400 | if (ret) | ||
401 | goto put_clusters; | ||
402 | } | ||
403 | |||
404 | ret = merge_cluster_tables(); | ||
405 | if (ret) | ||
406 | goto put_clusters; | ||
407 | |||
408 | /* Assuming 2 cluster, set clk_big_min and clk_little_max */ | ||
409 | clk_big_min = get_table_min(freq_table[0]); | ||
410 | clk_little_max = VIRT_FREQ(1, get_table_max(freq_table[1])); | ||
411 | |||
412 | pr_debug("%s: cluster: %d, clk_big_min: %d, clk_little_max: %d\n", | ||
413 | __func__, cluster, clk_big_min, clk_little_max); | ||
414 | |||
415 | return 0; | ||
416 | |||
417 | put_clusters: | ||
418 | for_each_present_cpu(i) { | ||
419 | struct device *cdev = get_cpu_device(i); | ||
420 | if (!cdev) { | ||
421 | pr_err("%s: failed to get cpu%d device\n", __func__, i); | ||
422 | return -ENODEV; | ||
423 | } | ||
424 | |||
425 | _put_cluster_clk_and_freq_table(cdev); | ||
426 | } | ||
427 | |||
428 | atomic_dec(&cluster_usage[cluster]); | ||
429 | |||
430 | return ret; | ||
431 | } | ||
432 | |||
135 | /* Per-CPU initialization */ | 433 | /* Per-CPU initialization */ |
136 | static int bL_cpufreq_init(struct cpufreq_policy *policy) | 434 | static int bL_cpufreq_init(struct cpufreq_policy *policy) |
137 | { | 435 | { |
@@ -158,13 +456,23 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy) | |||
158 | return ret; | 456 | return ret; |
159 | } | 457 | } |
160 | 458 | ||
459 | if (cur_cluster < MAX_CLUSTERS) { | ||
460 | cpumask_copy(policy->cpus, topology_core_cpumask(policy->cpu)); | ||
461 | |||
462 | per_cpu(physical_cluster, policy->cpu) = cur_cluster; | ||
463 | } else { | ||
464 | /* Assumption: during init, we are always running on A15 */ | ||
465 | per_cpu(physical_cluster, policy->cpu) = A15_CLUSTER; | ||
466 | } | ||
467 | |||
161 | if (arm_bL_ops->get_transition_latency) | 468 | if (arm_bL_ops->get_transition_latency) |
162 | policy->cpuinfo.transition_latency = | 469 | policy->cpuinfo.transition_latency = |
163 | arm_bL_ops->get_transition_latency(cpu_dev); | 470 | arm_bL_ops->get_transition_latency(cpu_dev); |
164 | else | 471 | else |
165 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | 472 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; |
166 | 473 | ||
167 | cpumask_copy(policy->cpus, topology_core_cpumask(policy->cpu)); | 474 | if (is_bL_switching_enabled()) |
475 | per_cpu(cpu_last_req_freq, policy->cpu) = clk_get_cpu_rate(policy->cpu); | ||
168 | 476 | ||
169 | dev_info(cpu_dev, "%s: CPU %d initialized\n", __func__, policy->cpu); | 477 | dev_info(cpu_dev, "%s: CPU %d initialized\n", __func__, policy->cpu); |
170 | return 0; | 478 | return 0; |
@@ -194,7 +502,7 @@ static struct cpufreq_driver bL_cpufreq_driver = { | |||
194 | CPUFREQ_HAVE_GOVERNOR_PER_POLICY, | 502 | CPUFREQ_HAVE_GOVERNOR_PER_POLICY, |
195 | .verify = cpufreq_generic_frequency_table_verify, | 503 | .verify = cpufreq_generic_frequency_table_verify, |
196 | .target_index = bL_cpufreq_set_target, | 504 | .target_index = bL_cpufreq_set_target, |
197 | .get = bL_cpufreq_get, | 505 | .get = bL_cpufreq_get_rate, |
198 | .init = bL_cpufreq_init, | 506 | .init = bL_cpufreq_init, |
199 | .exit = bL_cpufreq_exit, | 507 | .exit = bL_cpufreq_exit, |
200 | .attr = cpufreq_generic_attr, | 508 | .attr = cpufreq_generic_attr, |
@@ -202,7 +510,7 @@ static struct cpufreq_driver bL_cpufreq_driver = { | |||
202 | 510 | ||
203 | int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops) | 511 | int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops) |
204 | { | 512 | { |
205 | int ret; | 513 | int ret, i; |
206 | 514 | ||
207 | if (arm_bL_ops) { | 515 | if (arm_bL_ops) { |
208 | pr_debug("%s: Already registered: %s, exiting\n", __func__, | 516 | pr_debug("%s: Already registered: %s, exiting\n", __func__, |
@@ -217,6 +525,9 @@ int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops) | |||
217 | 525 | ||
218 | arm_bL_ops = ops; | 526 | arm_bL_ops = ops; |
219 | 527 | ||
528 | for (i = 0; i < MAX_CLUSTERS; i++) | ||
529 | mutex_init(&cluster_lock[i]); | ||
530 | |||
220 | ret = cpufreq_register_driver(&bL_cpufreq_driver); | 531 | ret = cpufreq_register_driver(&bL_cpufreq_driver); |
221 | if (ret) { | 532 | if (ret) { |
222 | pr_info("%s: Failed registering platform driver: %s, err: %d\n", | 533 | pr_info("%s: Failed registering platform driver: %s, err: %d\n", |
diff --git a/drivers/cpufreq/arm_big_little.h b/drivers/cpufreq/arm_big_little.h index 79b2ce17884d..70f18fc12d4a 100644 --- a/drivers/cpufreq/arm_big_little.h +++ b/drivers/cpufreq/arm_big_little.h | |||
@@ -34,11 +34,6 @@ struct cpufreq_arm_bL_ops { | |||
34 | int (*init_opp_table)(struct device *cpu_dev); | 34 | int (*init_opp_table)(struct device *cpu_dev); |
35 | }; | 35 | }; |
36 | 36 | ||
37 | static inline int cpu_to_cluster(int cpu) | ||
38 | { | ||
39 | return topology_physical_package_id(cpu); | ||
40 | } | ||
41 | |||
42 | int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops); | 37 | int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops); |
43 | void bL_cpufreq_unregister(struct cpufreq_arm_bL_ops *ops); | 38 | void bL_cpufreq_unregister(struct cpufreq_arm_bL_ops *ops); |
44 | 39 | ||