smp_plat.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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/cputype.h>
  10. /*
  11. * Return true if we are running on a SMP platform
  12. */
  13. static inline bool is_smp(void)
  14. {
  15. #ifndef CONFIG_SMP
  16. return false;
  17. #elif defined(CONFIG_SMP_ON_UP)
  18. extern unsigned int smp_on_up;
  19. return !!smp_on_up;
  20. #else
  21. return true;
  22. #endif
  23. }
  24. /* all SMP configurations have the extended CPUID registers */
  25. #ifndef CONFIG_MMU
  26. #define tlb_ops_need_broadcast() 0
  27. #else
  28. static inline int tlb_ops_need_broadcast(void)
  29. {
  30. if (!is_smp())
  31. return 0;
  32. return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 2;
  33. }
  34. #endif
  35. #if !defined(CONFIG_SMP) || __LINUX_ARM_ARCH__ >= 7
  36. #define cache_ops_need_broadcast() 0
  37. #else
  38. static inline int cache_ops_need_broadcast(void)
  39. {
  40. if (!is_smp())
  41. return 0;
  42. return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 1;
  43. }
  44. #endif
  45. /*
  46. * Logical CPU mapping.
  47. */
  48. extern u32 __cpu_logical_map[];
  49. #define cpu_logical_map(cpu) __cpu_logical_map[cpu]
  50. /*
  51. * Retrieve logical cpu index corresponding to a given MPIDR[23:0]
  52. * - mpidr: MPIDR[23:0] to be used for the look-up
  53. *
  54. * Returns the cpu logical index or -EINVAL on look-up error
  55. */
  56. static inline int get_logical_index(u32 mpidr)
  57. {
  58. int cpu;
  59. for (cpu = 0; cpu < nr_cpu_ids; cpu++)
  60. if (cpu_logical_map(cpu) == mpidr)
  61. return cpu;
  62. return -EINVAL;
  63. }
  64. /*
  65. * NOTE ! Assembly code relies on the following
  66. * structure memory layout in order to carry out load
  67. * multiple from its base address. For more
  68. * information check arch/arm/kernel/sleep.S
  69. */
  70. struct mpidr_hash {
  71. u32 mask; /* used by sleep.S */
  72. u32 shift_aff[3]; /* used by sleep.S */
  73. u32 bits;
  74. };
  75. extern struct mpidr_hash mpidr_hash;
  76. static inline u32 mpidr_hash_size(void)
  77. {
  78. return 1 << mpidr_hash.bits;
  79. }
  80. #endif