Marc Gonzalez | 222de7b | 2016-06-29 14:21:42 +0200 | [diff] [blame^] | 1 | #include <linux/delay.h> |
Marc Gonzalez | d6bd057 | 2016-01-06 10:27:43 +0100 | [diff] [blame] | 2 | #include <linux/init.h> |
| 3 | #include <linux/smp.h> |
| 4 | #include "smc.h" |
| 5 | |
| 6 | static int tango_boot_secondary(unsigned int cpu, struct task_struct *idle) |
| 7 | { |
| 8 | tango_set_aux_boot_addr(virt_to_phys(secondary_startup)); |
| 9 | tango_start_aux_core(cpu); |
| 10 | return 0; |
| 11 | } |
| 12 | |
Marc Gonzalez | 222de7b | 2016-06-29 14:21:42 +0200 | [diff] [blame^] | 13 | #ifdef CONFIG_HOTPLUG_CPU |
| 14 | /* |
| 15 | * cpu_kill() and cpu_die() run concurrently on different cores. |
| 16 | * Firmware will only "kill" a core once it has properly "died". |
| 17 | * Try a few times to kill a core before giving up, and sleep |
| 18 | * between tries to give that core enough time to die. |
| 19 | */ |
| 20 | static int tango_cpu_kill(unsigned int cpu) |
| 21 | { |
| 22 | int i, err; |
| 23 | |
| 24 | for (i = 0; i < 10; ++i) { |
| 25 | msleep(10); |
| 26 | err = tango_aux_core_kill(cpu); |
| 27 | if (!err) |
| 28 | return true; |
| 29 | } |
| 30 | |
| 31 | return false; |
| 32 | } |
| 33 | |
| 34 | static void tango_cpu_die(unsigned int cpu) |
| 35 | { |
| 36 | while (tango_aux_core_die(cpu) < 0) |
| 37 | cpu_relax(); |
| 38 | |
| 39 | panic("cpu %d failed to die\n", cpu); |
| 40 | } |
| 41 | #else |
| 42 | #define tango_cpu_kill NULL |
| 43 | #define tango_cpu_die NULL |
| 44 | #endif |
| 45 | |
Masahiro Yamada | c38ac80 | 2016-01-25 20:33:42 +0900 | [diff] [blame] | 46 | static const struct smp_operations tango_smp_ops __initconst = { |
Marc Gonzalez | d6bd057 | 2016-01-06 10:27:43 +0100 | [diff] [blame] | 47 | .smp_boot_secondary = tango_boot_secondary, |
Marc Gonzalez | 222de7b | 2016-06-29 14:21:42 +0200 | [diff] [blame^] | 48 | .cpu_kill = tango_cpu_kill, |
| 49 | .cpu_die = tango_cpu_die, |
Marc Gonzalez | d6bd057 | 2016-01-06 10:27:43 +0100 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | CPU_METHOD_OF_DECLARE(tango4_smp, "sigma,tango4-smp", &tango_smp_ops); |