platsmp.c 1.1 KB

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