smp.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. /* Hook for the generic smp_call_function_many() routine. */
  59. static inline void arch_send_call_function_ipi_mask(struct cpumask *mask)
  60. {
  61. send_IPI_many(mask, MSG_TAG_CALL_FUNCTION_MANY);
  62. }
  63. /* Hook for the generic smp_call_function_single() routine. */
  64. static inline void arch_send_call_function_single_ipi(int cpu)
  65. {
  66. send_IPI_single(cpu, MSG_TAG_CALL_FUNCTION_SINGLE);
  67. }
  68. /* Print out the boot string describing which cpus were disabled. */
  69. void print_disabled_cpus(void);
  70. #else /* !CONFIG_SMP */
  71. #define smp_master_cpu 0
  72. #define smp_height 1
  73. #define smp_width 1
  74. #define cpu_x(cpu) 0
  75. #define cpu_y(cpu) 0
  76. #define xy_to_cpu(x, y) 0
  77. #endif /* !CONFIG_SMP */
  78. /* Which cpus may be used as the lotar in a page table entry. */
  79. extern struct cpumask cpu_lotar_map;
  80. #define cpu_is_valid_lotar(cpu) cpumask_test_cpu((cpu), &cpu_lotar_map)
  81. #if CHIP_HAS_CBOX_HOME_MAP()
  82. /* Which processors are used for hash-for-home mapping */
  83. extern struct cpumask hash_for_home_map;
  84. #endif
  85. /* Which cpus can have their cache flushed by hv_flush_remote(). */
  86. extern struct cpumask cpu_cacheable_map;
  87. #define cpu_cacheable(cpu) cpumask_test_cpu((cpu), &cpu_cacheable_map)
  88. /* Convert an HV_LOTAR value into a cpu. */
  89. static inline int hv_lotar_to_cpu(HV_LOTAR lotar)
  90. {
  91. return HV_LOTAR_X(lotar) + (HV_LOTAR_Y(lotar) * smp_width);
  92. }
  93. /*
  94. * Extension of <linux/cpumask.h> functionality when you just want
  95. * to express a mask or suppression or inclusion region without
  96. * being too concerned about exactly which cpus are valid in that region.
  97. */
  98. int bitmap_parselist_crop(const char *bp, unsigned long *maskp, int nmaskbits);
  99. #define cpulist_parse_crop(buf, dst) \
  100. __cpulist_parse_crop((buf), (dst), NR_CPUS)
  101. static inline int __cpulist_parse_crop(const char *buf, struct cpumask *dstp,
  102. int nbits)
  103. {
  104. return bitmap_parselist_crop(buf, cpumask_bits(dstp), nbits);
  105. }
  106. /* Initialize the IPI subsystem. */
  107. void ipi_init(void);
  108. /* Function for start-cpu message to cause us to jump to. */
  109. extern unsigned long start_cpu_function_addr;
  110. #endif /* _ASM_TILE_SMP_H */