smp_plat.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * ARM specific SMP header, this contains our implementation
  3. * details.
  4. */
  5. #ifndef __ASMARM_SMP_PLAT_H
  6. #define __ASMARM_SMP_PLAT_H
  7. #include <linux/cpumask.h>
  8. #include <linux/err.h>
  9. #include <asm/cpu.h>
  10. #include <asm/cputype.h>
  11. /*
  12. * Return true if we are running on a SMP platform
  13. */
  14. static inline bool is_smp(void)
  15. {
  16. #ifndef CONFIG_SMP
  17. return false;
  18. #elif defined(CONFIG_SMP_ON_UP)
  19. extern unsigned int smp_on_up;
  20. return !!smp_on_up;
  21. #else
  22. return true;
  23. #endif
  24. }
  25. /**
  26. * smp_cpuid_part() - return part id for a given cpu
  27. * @cpu: logical cpu id.
  28. *
  29. * Return: part id of logical cpu passed as argument.
  30. */
  31. static inline unsigned int smp_cpuid_part(int cpu)
  32. {
  33. struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpu);
  34. return is_smp() ? cpu_info->cpuid & ARM_CPU_PART_MASK :
  35. read_cpuid_part();
  36. }
  37. /* all SMP configurations have the extended CPUID registers */
  38. #ifndef CONFIG_MMU
  39. #define tlb_ops_need_broadcast() 0
  40. #else
  41. static inline int tlb_ops_need_broadcast(void)
  42. {
  43. if (!is_smp())
  44. return 0;
  45. return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 2;
  46. }
  47. #endif
  48. #if !defined(CONFIG_SMP) || __LINUX_ARM_ARCH__ >= 7
  49. #define cache_ops_need_broadcast() 0
  50. #else
  51. static inline int cache_ops_need_broadcast(void)
  52. {
  53. if (!is_smp())
  54. return 0;
  55. return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 1;
  56. }
  57. #endif
  58. /*
  59. * Logical CPU mapping.
  60. */
  61. extern u32 __cpu_logical_map[];
  62. #define cpu_logical_map(cpu) __cpu_logical_map[cpu]
  63. /*
  64. * Retrieve logical cpu index corresponding to a given MPIDR[23:0]
  65. * - mpidr: MPIDR[23:0] to be used for the look-up
  66. *
  67. * Returns the cpu logical index or -EINVAL on look-up error
  68. */
  69. static inline int get_logical_index(u32 mpidr)
  70. {
  71. int cpu;
  72. for (cpu = 0; cpu < nr_cpu_ids; cpu++)
  73. if (cpu_logical_map(cpu) == mpidr)
  74. return cpu;
  75. return -EINVAL;
  76. }
  77. /*
  78. * NOTE ! Assembly code relies on the following
  79. * structure memory layout in order to carry out load
  80. * multiple from its base address. For more
  81. * information check arch/arm/kernel/sleep.S
  82. */
  83. struct mpidr_hash {
  84. u32 mask; /* used by sleep.S */
  85. u32 shift_aff[3]; /* used by sleep.S */
  86. u32 bits;
  87. };
  88. extern struct mpidr_hash mpidr_hash;
  89. static inline u32 mpidr_hash_size(void)
  90. {
  91. return 1 << mpidr_hash.bits;
  92. }
  93. extern int platform_can_secondary_boot(void);
  94. extern int platform_can_cpu_hotplug(void);
  95. #ifdef CONFIG_HOTPLUG_CPU
  96. extern int platform_can_hotplug_cpu(unsigned int cpu);
  97. #else
  98. static inline int platform_can_hotplug_cpu(unsigned int cpu)
  99. {
  100. return 0;
  101. }
  102. #endif
  103. #endif