platsmp.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/delay.h>
  3. #include <linux/init.h>
  4. #include <linux/smp.h>
  5. #include "smc.h"
  6. static int tango_boot_secondary(unsigned int cpu, struct task_struct *idle)
  7. {
  8. tango_set_aux_boot_addr(__pa_symbol(secondary_startup));
  9. tango_start_aux_core(cpu);
  10. return 0;
  11. }
  12. #ifdef CONFIG_HOTPLUG_CPU
  13. /*
  14. * cpu_kill() and cpu_die() run concurrently on different cores.
  15. * Firmware will only "kill" a core once it has properly "died".
  16. * Try a few times to kill a core before giving up, and sleep
  17. * between tries to give that core enough time to die.
  18. */
  19. static int tango_cpu_kill(unsigned int cpu)
  20. {
  21. int i, err;
  22. for (i = 0; i < 10; ++i) {
  23. msleep(10);
  24. err = tango_aux_core_kill(cpu);
  25. if (!err)
  26. return true;
  27. }
  28. return false;
  29. }
  30. static void tango_cpu_die(unsigned int cpu)
  31. {
  32. while (tango_aux_core_die(cpu) < 0)
  33. cpu_relax();
  34. panic("cpu %d failed to die\n", cpu);
  35. }
  36. #endif
  37. static const struct smp_operations tango_smp_ops __initconst = {
  38. .smp_boot_secondary = tango_boot_secondary,
  39. #ifdef CONFIG_HOTPLUG_CPU
  40. .cpu_kill = tango_cpu_kill,
  41. .cpu_die = tango_cpu_die,
  42. #endif
  43. };
  44. CPU_METHOD_OF_DECLARE(tango4_smp, "sigma,tango4-smp", &tango_smp_ops);