smp.c (e3c55d406bd8df1a878546002c93db90c42be10c) smp.c (cd1aebf5277a3a154a9e4c0ea4b3acabb62e5cab)
1/*
2 * SMP initialisation and IPI support
3 * Based on arch/arm/kernel/smp.c
4 *
5 * Copyright (C) 2012 ARM Ltd.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 25 unchanged lines hidden (view full) ---

34#include <linux/percpu.h>
35#include <linux/clockchips.h>
36#include <linux/completion.h>
37#include <linux/of.h>
38
39#include <asm/atomic.h>
40#include <asm/cacheflush.h>
41#include <asm/cputype.h>
1/*
2 * SMP initialisation and IPI support
3 * Based on arch/arm/kernel/smp.c
4 *
5 * Copyright (C) 2012 ARM Ltd.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 25 unchanged lines hidden (view full) ---

34#include <linux/percpu.h>
35#include <linux/clockchips.h>
36#include <linux/completion.h>
37#include <linux/of.h>
38
39#include <asm/atomic.h>
40#include <asm/cacheflush.h>
41#include <asm/cputype.h>
42#include <asm/cpu_ops.h>
42#include <asm/mmu_context.h>
43#include <asm/pgtable.h>
44#include <asm/pgalloc.h>
45#include <asm/processor.h>
46#include <asm/smp_plat.h>
47#include <asm/sections.h>
48#include <asm/tlbflush.h>
49#include <asm/ptrace.h>

--- 177 unchanged lines hidden (view full) ---

227}
228
229void __init smp_prepare_boot_cpu(void)
230{
231}
232
233static void (*smp_cross_call)(const struct cpumask *, unsigned int);
234
43#include <asm/mmu_context.h>
44#include <asm/pgtable.h>
45#include <asm/pgalloc.h>
46#include <asm/processor.h>
47#include <asm/smp_plat.h>
48#include <asm/sections.h>
49#include <asm/tlbflush.h>
50#include <asm/ptrace.h>

--- 177 unchanged lines hidden (view full) ---

228}
229
230void __init smp_prepare_boot_cpu(void)
231{
232}
233
234static void (*smp_cross_call)(const struct cpumask *, unsigned int);
235
235static const struct smp_enable_ops *enable_ops[] __initconst = {
236 &smp_spin_table_ops,
237 &smp_psci_ops,
238 NULL,
239};
240
241static const struct smp_enable_ops *smp_enable_ops[NR_CPUS];
242
243static const struct smp_enable_ops * __init smp_get_enable_ops(const char *name)
244{
245 const struct smp_enable_ops **ops = enable_ops;
246
247 while (*ops) {
248 if (!strcmp(name, (*ops)->name))
249 return *ops;
250
251 ops++;
252 }
253
254 return NULL;
255}
256
257/*
258 * Enumerate the possible CPU set from the device tree and build the
259 * cpu logical map array containing MPIDR values related to logical
260 * cpus. Assumes that cpu_logical_map(0) has already been initialized.
261 */
262void __init smp_init_cpus(void)
263{
264 const char *enable_method;
265 struct device_node *dn = NULL;
236/*
237 * Enumerate the possible CPU set from the device tree and build the
238 * cpu logical map array containing MPIDR values related to logical
239 * cpus. Assumes that cpu_logical_map(0) has already been initialized.
240 */
241void __init smp_init_cpus(void)
242{
243 const char *enable_method;
244 struct device_node *dn = NULL;
266 int i, cpu = 1;
245 unsigned int i, cpu = 1;
267 bool bootcpu_valid = false;
268
269 while ((dn = of_find_node_by_type(dn, "cpu"))) {
270 const u32 *cell;
271 u64 hwid;
272
273 /*
274 * A cpu node with missing "reg" property is

--- 62 unchanged lines hidden (view full) ---

337 */
338 enable_method = of_get_property(dn, "enable-method", NULL);
339 if (!enable_method) {
340 pr_err("%s: missing enable-method property\n",
341 dn->full_name);
342 goto next;
343 }
344
246 bool bootcpu_valid = false;
247
248 while ((dn = of_find_node_by_type(dn, "cpu"))) {
249 const u32 *cell;
250 u64 hwid;
251
252 /*
253 * A cpu node with missing "reg" property is

--- 62 unchanged lines hidden (view full) ---

316 */
317 enable_method = of_get_property(dn, "enable-method", NULL);
318 if (!enable_method) {
319 pr_err("%s: missing enable-method property\n",
320 dn->full_name);
321 goto next;
322 }
323
345 smp_enable_ops[cpu] = smp_get_enable_ops(enable_method);
324 cpu_ops[cpu] = cpu_get_ops(enable_method);
346
325
347 if (!smp_enable_ops[cpu]) {
326 if (!cpu_ops[cpu]) {
348 pr_err("%s: invalid enable-method property: %s\n",
349 dn->full_name, enable_method);
350 goto next;
351 }
352
327 pr_err("%s: invalid enable-method property: %s\n",
328 dn->full_name, enable_method);
329 goto next;
330 }
331
353 if (smp_enable_ops[cpu]->init_cpu(dn, cpu))
332 if (cpu_ops[cpu]->cpu_init(dn, cpu))
354 goto next;
355
356 pr_debug("cpu logical map 0x%llx\n", hwid);
357 cpu_logical_map(cpu) = hwid;
358next:
359 cpu++;
360 }
361

--- 13 unchanged lines hidden (view full) ---

375 */
376 for (i = 0; i < NR_CPUS; i++)
377 if (cpu_logical_map(i) != INVALID_HWID)
378 set_cpu_possible(i, true);
379}
380
381void __init smp_prepare_cpus(unsigned int max_cpus)
382{
333 goto next;
334
335 pr_debug("cpu logical map 0x%llx\n", hwid);
336 cpu_logical_map(cpu) = hwid;
337next:
338 cpu++;
339 }
340

--- 13 unchanged lines hidden (view full) ---

354 */
355 for (i = 0; i < NR_CPUS; i++)
356 if (cpu_logical_map(i) != INVALID_HWID)
357 set_cpu_possible(i, true);
358}
359
360void __init smp_prepare_cpus(unsigned int max_cpus)
361{
383 int cpu, err;
384 unsigned int ncores = num_possible_cpus();
362 int err;
363 unsigned int cpu, ncores = num_possible_cpus();
385
386 /*
387 * are we trying to boot more cores than exist?
388 */
389 if (max_cpus > ncores)
390 max_cpus = ncores;
391
392 /* Don't bother if we're effectively UP */

--- 10 unchanged lines hidden (view full) ---

403 max_cpus--;
404 for_each_possible_cpu(cpu) {
405 if (max_cpus == 0)
406 break;
407
408 if (cpu == smp_processor_id())
409 continue;
410
364
365 /*
366 * are we trying to boot more cores than exist?
367 */
368 if (max_cpus > ncores)
369 max_cpus = ncores;
370
371 /* Don't bother if we're effectively UP */

--- 10 unchanged lines hidden (view full) ---

382 max_cpus--;
383 for_each_possible_cpu(cpu) {
384 if (max_cpus == 0)
385 break;
386
387 if (cpu == smp_processor_id())
388 continue;
389
411 if (!smp_enable_ops[cpu])
390 if (!cpu_ops[cpu])
412 continue;
413
391 continue;
392
414 err = smp_enable_ops[cpu]->prepare_cpu(cpu);
393 err = cpu_ops[cpu]->cpu_prepare(cpu);
415 if (err)
416 continue;
417
418 set_cpu_present(cpu, true);
419 max_cpus--;
420 }
421}
422

--- 148 unchanged lines hidden ---
394 if (err)
395 continue;
396
397 set_cpu_present(cpu, true);
398 max_cpus--;
399 }
400}
401

--- 148 unchanged lines hidden ---