smp.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. /* Set up this tile to support receiving hypervisor messages */
  21. void init_messaging(void);
  22. /* Set up this tile to support receiving device interrupts and IPIs. */
  23. void init_per_tile_IRQs(void);
  24. /* Send a message to processors specified in mask */
  25. void send_IPI_many(const struct cpumask *mask, int tag);
  26. /* Send a message to all but the sending processor */
  27. void send_IPI_allbutself(int tag);
  28. /* Send a message to a specific processor */
  29. void send_IPI_single(int dest, int tag);
  30. /* Process an IPI message */
  31. void evaluate_message(int tag);
  32. /* Process an IRQ_RESCHEDULE IPI. */
  33. irqreturn_t handle_reschedule_ipi(int irq, void *token);
  34. /* Boot a secondary cpu */
  35. void online_secondary(void);
  36. /* Call a function on a specified set of CPUs (may include this one). */
  37. extern void on_each_cpu_mask(const struct cpumask *mask,
  38. void (*func)(void *), void *info, bool wait);
  39. /* Topology of the supervisor tile grid, and coordinates of boot processor */
  40. extern HV_Topology smp_topology;
  41. /* Accessors for grid size */
  42. #define smp_height (smp_topology.height)
  43. #define smp_width (smp_topology.width)
  44. /* Hypervisor message tags sent via the tile send_IPI*() routines. */
  45. #define MSG_TAG_START_CPU 1
  46. #define MSG_TAG_STOP_CPU 2
  47. #define MSG_TAG_CALL_FUNCTION_MANY 3
  48. #define MSG_TAG_CALL_FUNCTION_SINGLE 4
  49. /* Hook for the generic smp_call_function_many() routine. */
  50. static inline void arch_send_call_function_ipi_mask(struct cpumask *mask)
  51. {
  52. send_IPI_many(mask, MSG_TAG_CALL_FUNCTION_MANY);
  53. }
  54. /* Hook for the generic smp_call_function_single() routine. */
  55. static inline void arch_send_call_function_single_ipi(int cpu)
  56. {
  57. send_IPI_single(cpu, MSG_TAG_CALL_FUNCTION_SINGLE);
  58. }
  59. /* Print out the boot string describing which cpus were disabled. */
  60. void print_disabled_cpus(void);
  61. #else /* !CONFIG_SMP */
  62. #define on_each_cpu_mask(mask, func, info, wait) \
  63. do { if (cpumask_test_cpu(0, (mask))) func(info); } while (0)
  64. #define smp_master_cpu 0
  65. #define smp_height 1
  66. #define smp_width 1
  67. #endif /* !CONFIG_SMP */
  68. /* Which cpus may be used as the lotar in a page table entry. */
  69. extern struct cpumask cpu_lotar_map;
  70. #define cpu_is_valid_lotar(cpu) cpumask_test_cpu((cpu), &cpu_lotar_map)
  71. #if CHIP_HAS_CBOX_HOME_MAP()
  72. /* Which processors are used for hash-for-home mapping */
  73. extern struct cpumask hash_for_home_map;
  74. #endif
  75. /* Which cpus can have their cache flushed by hv_flush_remote(). */
  76. extern struct cpumask cpu_cacheable_map;
  77. #define cpu_cacheable(cpu) cpumask_test_cpu((cpu), &cpu_cacheable_map)
  78. /* Convert an HV_LOTAR value into a cpu. */
  79. static inline int hv_lotar_to_cpu(HV_LOTAR lotar)
  80. {
  81. return HV_LOTAR_X(lotar) + (HV_LOTAR_Y(lotar) * smp_width);
  82. }
  83. /*
  84. * Extension of <linux/cpumask.h> functionality when you just want
  85. * to express a mask or suppression or inclusion region without
  86. * being too concerned about exactly which cpus are valid in that region.
  87. */
  88. int bitmap_parselist_crop(const char *bp, unsigned long *maskp, int nmaskbits);
  89. #define cpulist_parse_crop(buf, dst) \
  90. __cpulist_parse_crop((buf), (dst), NR_CPUS)
  91. static inline int __cpulist_parse_crop(const char *buf, struct cpumask *dstp,
  92. int nbits)
  93. {
  94. return bitmap_parselist_crop(buf, cpumask_bits(dstp), nbits);
  95. }
  96. #endif /* _ASM_TILE_SMP_H */