Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/kernel/topology.c |
| 3 | * |
| 4 | * Copyright (C) 2011 Linaro Limited. |
| 5 | * Written by: Vincent Guittot |
| 6 | * |
| 7 | * based on arch/sh/kernel/topology.c |
| 8 | * |
| 9 | * This file is subject to the terms and conditions of the GNU General Public |
| 10 | * License. See the file "COPYING" in the main directory of this archive |
| 11 | * for more details. |
| 12 | */ |
| 13 | |
Juri Lelli | 615ffd6 | 2017-05-31 17:59:30 +0100 | [diff] [blame] | 14 | #include <linux/arch_topology.h> |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 15 | #include <linux/cpu.h> |
Juri Lelli | 06073ee | 2016-11-06 01:34:15 +0100 | [diff] [blame] | 16 | #include <linux/cpufreq.h> |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 17 | #include <linux/cpumask.h> |
Arnd Bergmann | 92bdd3f | 2013-05-31 22:49:22 +0100 | [diff] [blame] | 18 | #include <linux/export.h> |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 19 | #include <linux/init.h> |
| 20 | #include <linux/percpu.h> |
| 21 | #include <linux/node.h> |
| 22 | #include <linux/nodemask.h> |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 23 | #include <linux/of.h> |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 24 | #include <linux/sched.h> |
Ingo Molnar | 105ab3d8 | 2017-02-01 16:36:40 +0100 | [diff] [blame] | 25 | #include <linux/sched/topology.h> |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 26 | #include <linux/slab.h> |
Juri Lelli | 7e5930a | 2016-11-06 01:34:31 +0100 | [diff] [blame] | 27 | #include <linux/string.h> |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 28 | |
Juri Lelli | 7e5930a | 2016-11-06 01:34:31 +0100 | [diff] [blame] | 29 | #include <asm/cpu.h> |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 30 | #include <asm/cputype.h> |
| 31 | #include <asm/topology.h> |
| 32 | |
Vincent Guittot | 130d9aa | 2012-07-10 14:08:40 +0100 | [diff] [blame] | 33 | /* |
Nicolas Pitre | ca8ce3d | 2014-05-26 18:19:39 -0400 | [diff] [blame] | 34 | * cpu capacity scale management |
Vincent Guittot | 130d9aa | 2012-07-10 14:08:40 +0100 | [diff] [blame] | 35 | */ |
| 36 | |
| 37 | /* |
Nicolas Pitre | ca8ce3d | 2014-05-26 18:19:39 -0400 | [diff] [blame] | 38 | * cpu capacity table |
Vincent Guittot | 130d9aa | 2012-07-10 14:08:40 +0100 | [diff] [blame] | 39 | * This per cpu data structure describes the relative capacity of each core. |
| 40 | * On a heteregenous system, cores don't have the same computation capacity |
Nicolas Pitre | ca8ce3d | 2014-05-26 18:19:39 -0400 | [diff] [blame] | 41 | * and we reflect that difference in the cpu_capacity field so the scheduler |
| 42 | * can take this difference into account during load balance. A per cpu |
| 43 | * structure is preferred because each CPU updates its own cpu_capacity field |
| 44 | * during the load balance except for idle cores. One idle core is selected |
| 45 | * to run the rebalance_domains for all idle cores and the cpu_capacity can be |
| 46 | * updated during this sequence. |
Vincent Guittot | 130d9aa | 2012-07-10 14:08:40 +0100 | [diff] [blame] | 47 | */ |
Vincent Guittot | 130d9aa | 2012-07-10 14:08:40 +0100 | [diff] [blame] | 48 | |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 49 | #ifdef CONFIG_OF |
| 50 | struct cpu_efficiency { |
| 51 | const char *compatible; |
| 52 | unsigned long efficiency; |
| 53 | }; |
| 54 | |
| 55 | /* |
| 56 | * Table of relative efficiency of each processors |
| 57 | * The efficiency value must fit in 20bit and the final |
| 58 | * cpu_scale value must be in the range |
Nicolas Pitre | ca8ce3d | 2014-05-26 18:19:39 -0400 | [diff] [blame] | 59 | * 0 < cpu_scale < 3*SCHED_CAPACITY_SCALE/2 |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 60 | * in order to return at most 1 when DIV_ROUND_CLOSEST |
| 61 | * is used to compute the capacity of a CPU. |
| 62 | * Processors that are not defined in the table, |
Nicolas Pitre | ca8ce3d | 2014-05-26 18:19:39 -0400 | [diff] [blame] | 63 | * use the default SCHED_CAPACITY_SCALE value for cpu_scale. |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 64 | */ |
Mark Brown | 145bc29 | 2013-12-10 12:10:17 +0100 | [diff] [blame] | 65 | static const struct cpu_efficiency table_efficiency[] = { |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 66 | {"arm,cortex-a15", 3891}, |
| 67 | {"arm,cortex-a7", 2048}, |
| 68 | {NULL, }, |
| 69 | }; |
| 70 | |
Mark Brown | 145bc29 | 2013-12-10 12:10:17 +0100 | [diff] [blame] | 71 | static unsigned long *__cpu_capacity; |
Sudeep KarkadaNagesha | 816a8de | 2013-06-17 14:20:00 +0100 | [diff] [blame] | 72 | #define cpu_capacity(cpu) __cpu_capacity[cpu] |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 73 | |
Mark Brown | 145bc29 | 2013-12-10 12:10:17 +0100 | [diff] [blame] | 74 | static unsigned long middle_capacity = 1; |
Juri Lelli | 06073ee | 2016-11-06 01:34:15 +0100 | [diff] [blame] | 75 | static bool cap_from_dt = true; |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 76 | |
| 77 | /* |
| 78 | * Iterate all CPUs' descriptor in DT and compute the efficiency |
| 79 | * (as per table_efficiency). Also calculate a middle efficiency |
| 80 | * as close as possible to (max{eff_i} - min{eff_i}) / 2 |
Nicolas Pitre | ca8ce3d | 2014-05-26 18:19:39 -0400 | [diff] [blame] | 81 | * This is later used to scale the cpu_capacity field such that an |
| 82 | * 'average' CPU is of middle capacity. Also see the comments near |
| 83 | * table_efficiency[] and update_cpu_capacity(). |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 84 | */ |
| 85 | static void __init parse_dt_topology(void) |
| 86 | { |
Mark Brown | 145bc29 | 2013-12-10 12:10:17 +0100 | [diff] [blame] | 87 | const struct cpu_efficiency *cpu_eff; |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 88 | struct device_node *cn = NULL; |
Mark Brown | 44ae903 | 2014-03-20 15:16:54 +0100 | [diff] [blame] | 89 | unsigned long min_capacity = ULONG_MAX; |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 90 | unsigned long max_capacity = 0; |
| 91 | unsigned long capacity = 0; |
Mark Brown | 44ae903 | 2014-03-20 15:16:54 +0100 | [diff] [blame] | 92 | int cpu = 0; |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 93 | |
Mark Brown | 44ae903 | 2014-03-20 15:16:54 +0100 | [diff] [blame] | 94 | __cpu_capacity = kcalloc(nr_cpu_ids, sizeof(*__cpu_capacity), |
| 95 | GFP_NOWAIT); |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 96 | |
Juri Lelli | 06073ee | 2016-11-06 01:34:15 +0100 | [diff] [blame] | 97 | cn = of_find_node_by_path("/cpus"); |
| 98 | if (!cn) { |
| 99 | pr_err("No CPU information found in DT\n"); |
| 100 | return; |
| 101 | } |
| 102 | |
Sudeep KarkadaNagesha | 816a8de | 2013-06-17 14:20:00 +0100 | [diff] [blame] | 103 | for_each_possible_cpu(cpu) { |
| 104 | const u32 *rate; |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 105 | int len; |
| 106 | |
Sudeep KarkadaNagesha | 816a8de | 2013-06-17 14:20:00 +0100 | [diff] [blame] | 107 | /* too early to use cpu->of_node */ |
| 108 | cn = of_get_cpu_node(cpu, NULL); |
| 109 | if (!cn) { |
| 110 | pr_err("missing device node for CPU %d\n", cpu); |
| 111 | continue; |
| 112 | } |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 113 | |
Juri Lelli | 4ca4f26 | 2017-05-31 17:59:31 +0100 | [diff] [blame] | 114 | if (topology_parse_cpu_capacity(cn, cpu)) { |
Juri Lelli | 06073ee | 2016-11-06 01:34:15 +0100 | [diff] [blame] | 115 | of_node_put(cn); |
| 116 | continue; |
| 117 | } |
| 118 | |
| 119 | cap_from_dt = false; |
| 120 | |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 121 | for (cpu_eff = table_efficiency; cpu_eff->compatible; cpu_eff++) |
| 122 | if (of_device_is_compatible(cn, cpu_eff->compatible)) |
| 123 | break; |
| 124 | |
| 125 | if (cpu_eff->compatible == NULL) |
| 126 | continue; |
| 127 | |
| 128 | rate = of_get_property(cn, "clock-frequency", &len); |
| 129 | if (!rate || len != 4) { |
Rob Herring | a8e65e0 | 2017-07-21 14:28:32 -0500 | [diff] [blame] | 130 | pr_err("%pOF missing clock-frequency property\n", cn); |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 131 | continue; |
| 132 | } |
| 133 | |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 134 | capacity = ((be32_to_cpup(rate)) >> 20) * cpu_eff->efficiency; |
| 135 | |
| 136 | /* Save min capacity of the system */ |
| 137 | if (capacity < min_capacity) |
| 138 | min_capacity = capacity; |
| 139 | |
| 140 | /* Save max capacity of the system */ |
| 141 | if (capacity > max_capacity) |
| 142 | max_capacity = capacity; |
| 143 | |
Sudeep KarkadaNagesha | 816a8de | 2013-06-17 14:20:00 +0100 | [diff] [blame] | 144 | cpu_capacity(cpu) = capacity; |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 145 | } |
| 146 | |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 147 | /* If min and max capacities are equals, we bypass the update of the |
| 148 | * cpu_scale because all CPUs have the same capacity. Otherwise, we |
| 149 | * compute a middle_capacity factor that will ensure that the capacity |
| 150 | * of an 'average' CPU of the system will be as close as possible to |
Nicolas Pitre | ca8ce3d | 2014-05-26 18:19:39 -0400 | [diff] [blame] | 151 | * SCHED_CAPACITY_SCALE, which is the default value, but with the |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 152 | * constraint explained near table_efficiency[]. |
| 153 | */ |
Sudeep KarkadaNagesha | 816a8de | 2013-06-17 14:20:00 +0100 | [diff] [blame] | 154 | if (4*max_capacity < (3*(max_capacity + min_capacity))) |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 155 | middle_capacity = (min_capacity + max_capacity) |
Nicolas Pitre | ca8ce3d | 2014-05-26 18:19:39 -0400 | [diff] [blame] | 156 | >> (SCHED_CAPACITY_SHIFT+1); |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 157 | else |
| 158 | middle_capacity = ((max_capacity / 3) |
Nicolas Pitre | ca8ce3d | 2014-05-26 18:19:39 -0400 | [diff] [blame] | 159 | >> (SCHED_CAPACITY_SHIFT-1)) + 1; |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 160 | |
Juri Lelli | c105aa3 | 2017-05-31 17:59:29 +0100 | [diff] [blame] | 161 | if (cap_from_dt) |
Juri Lelli | 4ca4f26 | 2017-05-31 17:59:31 +0100 | [diff] [blame] | 162 | topology_normalize_cpu_scale(); |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | /* |
| 166 | * Look for a customed capacity of a CPU in the cpu_capacity table during the |
| 167 | * boot. The update of all CPUs is in O(n^2) for heteregeneous system but the |
| 168 | * function returns directly for SMP system. |
| 169 | */ |
Nicolas Pitre | ca8ce3d | 2014-05-26 18:19:39 -0400 | [diff] [blame] | 170 | static void update_cpu_capacity(unsigned int cpu) |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 171 | { |
Juri Lelli | 06073ee | 2016-11-06 01:34:15 +0100 | [diff] [blame] | 172 | if (!cpu_capacity(cpu) || cap_from_dt) |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 173 | return; |
| 174 | |
Juri Lelli | 4ca4f26 | 2017-05-31 17:59:31 +0100 | [diff] [blame] | 175 | topology_set_cpu_scale(cpu, cpu_capacity(cpu) / middle_capacity); |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 176 | |
Russell King | 4ed89f2228 | 2014-10-28 11:26:42 +0000 | [diff] [blame] | 177 | pr_info("CPU%u: update cpu_capacity %lu\n", |
Juri Lelli | 4ca4f26 | 2017-05-31 17:59:31 +0100 | [diff] [blame] | 178 | cpu, topology_get_cpu_scale(NULL, cpu)); |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | #else |
| 182 | static inline void parse_dt_topology(void) {} |
Nicolas Pitre | ca8ce3d | 2014-05-26 18:19:39 -0400 | [diff] [blame] | 183 | static inline void update_cpu_capacity(unsigned int cpuid) {} |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 184 | #endif |
| 185 | |
Lorenzo Pieralisi | dca463da | 2012-11-15 17:30:32 +0000 | [diff] [blame] | 186 | /* |
Vincent Guittot | 130d9aa | 2012-07-10 14:08:40 +0100 | [diff] [blame] | 187 | * cpu topology table |
| 188 | */ |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 189 | struct cputopo_arm cpu_topology[NR_CPUS]; |
Arnd Bergmann | 92bdd3f | 2013-05-31 22:49:22 +0100 | [diff] [blame] | 190 | EXPORT_SYMBOL_GPL(cpu_topology); |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 191 | |
Vincent Guittot | 4cbd6b1 | 2011-11-29 15:50:20 +0100 | [diff] [blame] | 192 | const struct cpumask *cpu_coregroup_mask(int cpu) |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 193 | { |
| 194 | return &cpu_topology[cpu].core_sibling; |
| 195 | } |
| 196 | |
Vincent Guittot | fb2aa85 | 2014-04-11 11:44:41 +0200 | [diff] [blame] | 197 | /* |
| 198 | * The current assumption is that we can power gate each core independently. |
| 199 | * This will be superseded by DT binding once available. |
| 200 | */ |
| 201 | const struct cpumask *cpu_corepower_mask(int cpu) |
| 202 | { |
| 203 | return &cpu_topology[cpu].thread_sibling; |
| 204 | } |
| 205 | |
Mark Brown | 145bc29 | 2013-12-10 12:10:17 +0100 | [diff] [blame] | 206 | static void update_siblings_masks(unsigned int cpuid) |
Vincent Guittot | cb75dac | 2012-07-10 14:11:11 +0100 | [diff] [blame] | 207 | { |
| 208 | struct cputopo_arm *cpu_topo, *cpuid_topo = &cpu_topology[cpuid]; |
| 209 | int cpu; |
| 210 | |
| 211 | /* update core and thread sibling masks */ |
| 212 | for_each_possible_cpu(cpu) { |
| 213 | cpu_topo = &cpu_topology[cpu]; |
| 214 | |
| 215 | if (cpuid_topo->socket_id != cpu_topo->socket_id) |
| 216 | continue; |
| 217 | |
| 218 | cpumask_set_cpu(cpuid, &cpu_topo->core_sibling); |
| 219 | if (cpu != cpuid) |
| 220 | cpumask_set_cpu(cpu, &cpuid_topo->core_sibling); |
| 221 | |
| 222 | if (cpuid_topo->core_id != cpu_topo->core_id) |
| 223 | continue; |
| 224 | |
| 225 | cpumask_set_cpu(cpuid, &cpu_topo->thread_sibling); |
| 226 | if (cpu != cpuid) |
| 227 | cpumask_set_cpu(cpu, &cpuid_topo->thread_sibling); |
| 228 | } |
| 229 | smp_wmb(); |
| 230 | } |
| 231 | |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 232 | /* |
| 233 | * store_cpu_topology is called at boot when only one cpu is running |
| 234 | * and with the mutex cpu_hotplug.lock locked, when several cpus have booted, |
| 235 | * which prevents simultaneous write access to cpu_topology array |
| 236 | */ |
| 237 | void store_cpu_topology(unsigned int cpuid) |
| 238 | { |
| 239 | struct cputopo_arm *cpuid_topo = &cpu_topology[cpuid]; |
| 240 | unsigned int mpidr; |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 241 | |
| 242 | /* If the cpu topology has been already set, just return */ |
| 243 | if (cpuid_topo->core_id != -1) |
| 244 | return; |
| 245 | |
| 246 | mpidr = read_cpuid_mpidr(); |
| 247 | |
| 248 | /* create cpu topology mapping */ |
| 249 | if ((mpidr & MPIDR_SMP_BITMASK) == MPIDR_SMP_VALUE) { |
| 250 | /* |
| 251 | * This is a multiprocessor system |
| 252 | * multiprocessor format & multiprocessor mode field are set |
| 253 | */ |
| 254 | |
| 255 | if (mpidr & MPIDR_MT_BITMASK) { |
| 256 | /* core performance interdependency */ |
Lorenzo Pieralisi | 71db5bf | 2012-11-16 15:24:06 +0000 | [diff] [blame] | 257 | cpuid_topo->thread_id = MPIDR_AFFINITY_LEVEL(mpidr, 0); |
| 258 | cpuid_topo->core_id = MPIDR_AFFINITY_LEVEL(mpidr, 1); |
| 259 | cpuid_topo->socket_id = MPIDR_AFFINITY_LEVEL(mpidr, 2); |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 260 | } else { |
| 261 | /* largely independent cores */ |
| 262 | cpuid_topo->thread_id = -1; |
Lorenzo Pieralisi | 71db5bf | 2012-11-16 15:24:06 +0000 | [diff] [blame] | 263 | cpuid_topo->core_id = MPIDR_AFFINITY_LEVEL(mpidr, 0); |
| 264 | cpuid_topo->socket_id = MPIDR_AFFINITY_LEVEL(mpidr, 1); |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 265 | } |
| 266 | } else { |
| 267 | /* |
| 268 | * This is an uniprocessor system |
| 269 | * we are in multiprocessor format but uniprocessor system |
| 270 | * or in the old uniprocessor format |
| 271 | */ |
| 272 | cpuid_topo->thread_id = -1; |
| 273 | cpuid_topo->core_id = 0; |
| 274 | cpuid_topo->socket_id = -1; |
| 275 | } |
| 276 | |
Vincent Guittot | cb75dac | 2012-07-10 14:11:11 +0100 | [diff] [blame] | 277 | update_siblings_masks(cpuid); |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 278 | |
Nicolas Pitre | ca8ce3d | 2014-05-26 18:19:39 -0400 | [diff] [blame] | 279 | update_cpu_capacity(cpuid); |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 280 | |
Russell King | 4ed89f2228 | 2014-10-28 11:26:42 +0000 | [diff] [blame] | 281 | pr_info("CPU%u: thread %d, cpu %d, socket %d, mpidr %x\n", |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 282 | cpuid, cpu_topology[cpuid].thread_id, |
| 283 | cpu_topology[cpuid].core_id, |
| 284 | cpu_topology[cpuid].socket_id, mpidr); |
| 285 | } |
| 286 | |
Guenter Roeck | b6220ad | 2014-06-24 18:05:29 -0700 | [diff] [blame] | 287 | static inline int cpu_corepower_flags(void) |
Vincent Guittot | fb2aa85 | 2014-04-11 11:44:41 +0200 | [diff] [blame] | 288 | { |
| 289 | return SD_SHARE_PKG_RESOURCES | SD_SHARE_POWERDOMAIN; |
| 290 | } |
| 291 | |
| 292 | static struct sched_domain_topology_level arm_topology[] = { |
| 293 | #ifdef CONFIG_SCHED_MC |
| 294 | { cpu_corepower_mask, cpu_corepower_flags, SD_INIT_NAME(GMC) }, |
| 295 | { cpu_coregroup_mask, cpu_core_flags, SD_INIT_NAME(MC) }, |
| 296 | #endif |
| 297 | { cpu_cpu_mask, SD_INIT_NAME(DIE) }, |
| 298 | { NULL, }, |
| 299 | }; |
| 300 | |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 301 | /* |
| 302 | * init_cpu_topology is called at boot when only one cpu is running |
| 303 | * which prevent simultaneous write access to cpu_topology array |
| 304 | */ |
Venkatraman Sathiyamoorthy | f7e416e | 2012-08-03 07:58:33 +0100 | [diff] [blame] | 305 | void __init init_cpu_topology(void) |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 306 | { |
| 307 | unsigned int cpu; |
| 308 | |
Nicolas Pitre | ca8ce3d | 2014-05-26 18:19:39 -0400 | [diff] [blame] | 309 | /* init core mask and capacity */ |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 310 | for_each_possible_cpu(cpu) { |
| 311 | struct cputopo_arm *cpu_topo = &(cpu_topology[cpu]); |
| 312 | |
| 313 | cpu_topo->thread_id = -1; |
| 314 | cpu_topo->core_id = -1; |
| 315 | cpu_topo->socket_id = -1; |
| 316 | cpumask_clear(&cpu_topo->core_sibling); |
| 317 | cpumask_clear(&cpu_topo->thread_sibling); |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 318 | } |
| 319 | smp_wmb(); |
Vincent Guittot | 339ca09 | 2012-07-10 14:13:12 +0100 | [diff] [blame] | 320 | |
| 321 | parse_dt_topology(); |
Vincent Guittot | fb2aa85 | 2014-04-11 11:44:41 +0200 | [diff] [blame] | 322 | |
| 323 | /* Set scheduler topology descriptor */ |
| 324 | set_sched_topology(arm_topology); |
Vincent Guittot | c9018aa | 2011-08-08 13:21:59 +0100 | [diff] [blame] | 325 | } |