smp_plat.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. static inline int tlb_ops_need_broadcast(void)
  26. {
  27. if (!is_smp())
  28. return 0;
  29. return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 2;
  30. }
  31. #if !defined(CONFIG_SMP) || __LINUX_ARM_ARCH__ >= 7
  32. #define cache_ops_need_broadcast() 0
  33. #else
  34. static inline int cache_ops_need_broadcast(void)
  35. {
  36. if (!is_smp())
  37. return 0;
  38. return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 1;
  39. }
  40. #endif
  41. /*
  42. * Logical CPU mapping.
  43. */
  44. extern int __cpu_logical_map[];
  45. #define cpu_logical_map(cpu) __cpu_logical_map[cpu]
  46. /*
  47. * Retrieve logical cpu index corresponding to a given MPIDR[23:0]
  48. * - mpidr: MPIDR[23:0] to be used for the look-up
  49. *
  50. * Returns the cpu logical index or -EINVAL on look-up error
  51. */
  52. static inline int get_logical_index(u32 mpidr)
  53. {
  54. int cpu;
  55. for (cpu = 0; cpu < nr_cpu_ids; cpu++)
  56. if (cpu_logical_map(cpu) == mpidr)
  57. return cpu;
  58. return -EINVAL;
  59. }
  60. #endif