smp.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Author: Huacai Chen <[email protected]>
  4. * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
  5. */
  6. #ifndef __ASM_SMP_H
  7. #define __ASM_SMP_H
  8. #include <linux/atomic.h>
  9. #include <linux/bitops.h>
  10. #include <linux/linkage.h>
  11. #include <linux/threads.h>
  12. #include <linux/cpumask.h>
  13. extern int smp_num_siblings;
  14. extern int num_processors;
  15. extern int disabled_cpus;
  16. extern cpumask_t cpu_sibling_map[];
  17. extern cpumask_t cpu_core_map[];
  18. extern cpumask_t cpu_foreign_map[];
  19. void loongson_smp_setup(void);
  20. void loongson_prepare_cpus(unsigned int max_cpus);
  21. void loongson_boot_secondary(int cpu, struct task_struct *idle);
  22. void loongson_init_secondary(void);
  23. void loongson_smp_finish(void);
  24. void loongson_send_ipi_single(int cpu, unsigned int action);
  25. void loongson_send_ipi_mask(const struct cpumask *mask, unsigned int action);
  26. #ifdef CONFIG_HOTPLUG_CPU
  27. int loongson_cpu_disable(void);
  28. void loongson_cpu_die(unsigned int cpu);
  29. #endif
  30. static inline void plat_smp_setup(void)
  31. {
  32. loongson_smp_setup();
  33. }
  34. static inline int raw_smp_processor_id(void)
  35. {
  36. #if defined(__VDSO__)
  37. extern int vdso_smp_processor_id(void)
  38. __compiletime_error("VDSO should not call smp_processor_id()");
  39. return vdso_smp_processor_id();
  40. #else
  41. return current_thread_info()->cpu;
  42. #endif
  43. }
  44. #define raw_smp_processor_id raw_smp_processor_id
  45. /* Map from cpu id to sequential logical cpu number. This will only
  46. * not be idempotent when cpus failed to come on-line. */
  47. extern int __cpu_number_map[NR_CPUS];
  48. #define cpu_number_map(cpu) __cpu_number_map[cpu]
  49. /* The reverse map from sequential logical cpu number to cpu id. */
  50. extern int __cpu_logical_map[NR_CPUS];
  51. #define cpu_logical_map(cpu) __cpu_logical_map[cpu]
  52. #define cpu_physical_id(cpu) cpu_logical_map(cpu)
  53. #define SMP_BOOT_CPU 0x1
  54. #define SMP_RESCHEDULE 0x2
  55. #define SMP_CALL_FUNCTION 0x4
  56. struct secondary_data {
  57. unsigned long stack;
  58. unsigned long thread_info;
  59. };
  60. extern struct secondary_data cpuboot_data;
  61. extern asmlinkage void smpboot_entry(void);
  62. extern void calculate_cpu_foreign_map(void);
  63. /*
  64. * Generate IPI list text
  65. */
  66. extern void show_ipi_list(struct seq_file *p, int prec);
  67. static inline void arch_send_call_function_single_ipi(int cpu)
  68. {
  69. loongson_send_ipi_single(cpu, SMP_CALL_FUNCTION);
  70. }
  71. static inline void arch_send_call_function_ipi_mask(const struct cpumask *mask)
  72. {
  73. loongson_send_ipi_mask(mask, SMP_CALL_FUNCTION);
  74. }
  75. #ifdef CONFIG_HOTPLUG_CPU
  76. static inline int __cpu_disable(void)
  77. {
  78. return loongson_cpu_disable();
  79. }
  80. static inline void __cpu_die(unsigned int cpu)
  81. {
  82. loongson_cpu_die(cpu);
  83. }
  84. extern void play_dead(void);
  85. #endif
  86. #endif /* __ASM_SMP_H */