smp.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. #ifndef _ASM_TILE_SMP_H
  15. #define _ASM_TILE_SMP_H
  16. #ifdef CONFIG_SMP
  17. #include <asm/processor.h>
  18. #include <linux/cpumask.h>
  19. #include <linux/irqreturn.h>
  20. #include <hv/hypervisor.h>
  21. /* Set up this tile to support receiving hypervisor messages */
  22. void init_messaging(void);
  23. /* Set up this tile to support receiving device interrupts and IPIs. */
  24. void init_per_tile_IRQs(void);
  25. /* Send a message to processors specified in mask */
  26. void send_IPI_many(const struct cpumask *mask, int tag);
  27. /* Send a message to all but the sending processor */
  28. void send_IPI_allbutself(int tag);
  29. /* Send a message to a specific processor */
  30. void send_IPI_single(int dest, int tag);
  31. /* Process an IPI message */
  32. void evaluate_message(int tag);
  33. /* Boot a secondary cpu */
  34. void online_secondary(void);
  35. /* Call a function on a specified set of CPUs (may include this one). */
  36. extern void on_each_cpu_mask(const struct cpumask *mask,
  37. void (*func)(void *), void *info, bool wait);
  38. /* Topology of the supervisor tile grid, and coordinates of boot processor */
  39. extern HV_Topology smp_topology;
  40. /* Accessors for grid size */
  41. #define smp_height (smp_topology.height)
  42. #define smp_width (smp_topology.width)
  43. /* Convenience functions for converting cpu <-> coords. */
  44. static inline int cpu_x(int cpu)
  45. {
  46. return cpu % smp_width;
  47. }
  48. static inline int cpu_y(int cpu)
  49. {
  50. return cpu / smp_width;
  51. }
  52. static inline int xy_to_cpu(int x, int y)
  53. {
  54. return y * smp_width + x;
  55. }
  56. /* Hypervisor message tags sent via the tile send_IPI*() routines. */
  57. #define MSG_TAG_START_CPU 1
  58. #define MSG_TAG_STOP_CPU 2
  59. #define MSG_TAG_CALL_FUNCTION_MANY 3
  60. #define MSG_TAG_CALL_FUNCTION_SINGLE 4
  61. /* Hook for the generic smp_call_function_many() routine. */
  62. static inline void arch_send_call_function_ipi_mask(struct cpumask *mask)
  63. {
  64. send_IPI_many(mask, MSG_TAG_CALL_FUNCTION_MANY);
  65. }
  66. /* Hook for the generic smp_call_function_single() routine. */
  67. static inline void arch_send_call_function_single_ipi(int cpu)
  68. {
  69. send_IPI_single(cpu, MSG_TAG_CALL_FUNCTION_SINGLE);
  70. }
  71. /* Print out the boot string describing which cpus were disabled. */
  72. void print_disabled_cpus(void);
  73. #else /* !CONFIG_SMP */
  74. #define on_each_cpu_mask(mask, func, info, wait) \
  75. do { if (cpumask_test_cpu(0, (mask))) func(info); } while (0)
  76. #define smp_master_cpu 0
  77. #define smp_height 1
  78. #define smp_width 1
  79. #define cpu_x(cpu) 0
  80. #define cpu_y(cpu) 0
  81. #define xy_to_cpu(x, y) 0
  82. #endif /* !CONFIG_SMP */
  83. /* Which cpus may be used as the lotar in a page table entry. */
  84. extern struct cpumask cpu_lotar_map;
  85. #define cpu_is_valid_lotar(cpu) cpumask_test_cpu((cpu), &cpu_lotar_map)
  86. #if CHIP_HAS_CBOX_HOME_MAP()
  87. /* Which processors are used for hash-for-home mapping */
  88. extern struct cpumask hash_for_home_map;
  89. #endif
  90. /* Which cpus can have their cache flushed by hv_flush_remote(). */
  91. extern struct cpumask cpu_cacheable_map;
  92. #define cpu_cacheable(cpu) cpumask_test_cpu((cpu), &cpu_cacheable_map)
  93. /* Convert an HV_LOTAR value into a cpu. */
  94. static inline int hv_lotar_to_cpu(HV_LOTAR lotar)
  95. {
  96. return HV_LOTAR_X(lotar) + (HV_LOTAR_Y(lotar) * smp_width);
  97. }
  98. /*
  99. * Extension of <linux/cpumask.h> functionality when you just want
  100. * to express a mask or suppression or inclusion region without
  101. * being too concerned about exactly which cpus are valid in that region.
  102. */
  103. int bitmap_parselist_crop(const char *bp, unsigned long *maskp, int nmaskbits);
  104. #define cpulist_parse_crop(buf, dst) \
  105. __cpulist_parse_crop((buf), (dst), NR_CPUS)
  106. static inline int __cpulist_parse_crop(const char *buf, struct cpumask *dstp,
  107. int nbits)
  108. {
  109. return bitmap_parselist_crop(buf, cpumask_bits(dstp), nbits);
  110. }
  111. /* Initialize the IPI subsystem. */
  112. void ipi_init(void);
  113. /* Function for start-cpu message to cause us to jump to. */
  114. extern unsigned long start_cpu_function_addr;
  115. #endif /* _ASM_TILE_SMP_H */