smp.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. /* Topology of the supervisor tile grid, and coordinates of boot processor */
  36. extern HV_Topology smp_topology;
  37. /* Accessors for grid size */
  38. #define smp_height (smp_topology.height)
  39. #define smp_width (smp_topology.width)
  40. /* Convenience functions for converting cpu <-> coords. */
  41. static inline int cpu_x(int cpu)
  42. {
  43. return cpu % smp_width;
  44. }
  45. static inline int cpu_y(int cpu)
  46. {
  47. return cpu / smp_width;
  48. }
  49. static inline int xy_to_cpu(int x, int y)
  50. {
  51. return y * smp_width + x;
  52. }
  53. /* Hypervisor message tags sent via the tile send_IPI*() routines. */
  54. #define MSG_TAG_START_CPU 1
  55. #define MSG_TAG_STOP_CPU 2
  56. #define MSG_TAG_CALL_FUNCTION_MANY 3
  57. #define MSG_TAG_CALL_FUNCTION_SINGLE 4
  58. #define MSG_TAG_IRQ_WORK 5
  59. /* Hook for the generic smp_call_function_many() routine. */
  60. static inline void arch_send_call_function_ipi_mask(struct cpumask *mask)
  61. {
  62. send_IPI_many(mask, MSG_TAG_CALL_FUNCTION_MANY);
  63. }
  64. /* Hook for the generic smp_call_function_single() routine. */
  65. static inline void arch_send_call_function_single_ipi(int cpu)
  66. {
  67. send_IPI_single(cpu, MSG_TAG_CALL_FUNCTION_SINGLE);
  68. }
  69. /* Print out the boot string describing which cpus were disabled. */
  70. void print_disabled_cpus(void);
  71. #else /* !CONFIG_SMP */
  72. #define smp_master_cpu 0
  73. #define smp_height 1
  74. #define smp_width 1
  75. #define cpu_x(cpu) 0
  76. #define cpu_y(cpu) 0
  77. #define xy_to_cpu(x, y) 0
  78. #endif /* !CONFIG_SMP */
  79. /* Which cpus may be used as the lotar in a page table entry. */
  80. extern struct cpumask cpu_lotar_map;
  81. #define cpu_is_valid_lotar(cpu) cpumask_test_cpu((cpu), &cpu_lotar_map)
  82. /* Which processors are used for hash-for-home mapping */
  83. extern struct cpumask hash_for_home_map;
  84. /* Which cpus can have their cache flushed by hv_flush_remote(). */
  85. extern struct cpumask cpu_cacheable_map;
  86. #define cpu_cacheable(cpu) cpumask_test_cpu((cpu), &cpu_cacheable_map)
  87. /* Convert an HV_LOTAR value into a cpu. */
  88. static inline int hv_lotar_to_cpu(HV_LOTAR lotar)
  89. {
  90. return HV_LOTAR_X(lotar) + (HV_LOTAR_Y(lotar) * smp_width);
  91. }
  92. /*
  93. * Extension of <linux/cpumask.h> functionality when you just want
  94. * to express a mask or suppression or inclusion region without
  95. * being too concerned about exactly which cpus are valid in that region.
  96. */
  97. int bitmap_parselist_crop(const char *bp, unsigned long *maskp, int nmaskbits);
  98. #define cpulist_parse_crop(buf, dst) \
  99. __cpulist_parse_crop((buf), (dst), NR_CPUS)
  100. static inline int __cpulist_parse_crop(const char *buf, struct cpumask *dstp,
  101. int nbits)
  102. {
  103. return bitmap_parselist_crop(buf, cpumask_bits(dstp), nbits);
  104. }
  105. /* Initialize the IPI subsystem. */
  106. void ipi_init(void);
  107. /* Function for start-cpu message to cause us to jump to. */
  108. extern unsigned long start_cpu_function_addr;
  109. #endif /* _ASM_TILE_SMP_H */