smp.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * SMP Support
  4. *
  5. * Copyright (C) 1999 VA Linux Systems
  6. * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
  7. * (c) Copyright 2001-2003, 2005 Hewlett-Packard Development Company, L.P.
  8. * David Mosberger-Tang <davidm@hpl.hp.com>
  9. * Bjorn Helgaas <bjorn.helgaas@hp.com>
  10. */
  11. #ifndef _ASM_IA64_SMP_H
  12. #define _ASM_IA64_SMP_H
  13. #include <linux/init.h>
  14. #include <linux/threads.h>
  15. #include <linux/kernel.h>
  16. #include <linux/cpumask.h>
  17. #include <linux/bitops.h>
  18. #include <linux/irqreturn.h>
  19. #include <asm/io.h>
  20. #include <asm/param.h>
  21. #include <asm/processor.h>
  22. #include <asm/ptrace.h>
  23. static inline unsigned int
  24. ia64_get_lid (void)
  25. {
  26. union {
  27. struct {
  28. unsigned long reserved : 16;
  29. unsigned long eid : 8;
  30. unsigned long id : 8;
  31. unsigned long ignored : 32;
  32. } f;
  33. unsigned long bits;
  34. } lid;
  35. lid.bits = ia64_getreg(_IA64_REG_CR_LID);
  36. return lid.f.id << 8 | lid.f.eid;
  37. }
  38. #define hard_smp_processor_id() ia64_get_lid()
  39. #ifdef CONFIG_SMP
  40. #define XTP_OFFSET 0x1e0008
  41. #define SMP_IRQ_REDIRECTION (1 << 0)
  42. #define SMP_IPI_REDIRECTION (1 << 1)
  43. #define raw_smp_processor_id() (current_thread_info()->cpu)
  44. extern struct smp_boot_data {
  45. int cpu_count;
  46. int cpu_phys_id[NR_CPUS];
  47. } smp_boot_data __initdata;
  48. extern char no_int_routing;
  49. extern cpumask_t cpu_core_map[NR_CPUS];
  50. DECLARE_PER_CPU_SHARED_ALIGNED(cpumask_t, cpu_sibling_map);
  51. extern int smp_num_siblings;
  52. extern void __iomem *ipi_base_addr;
  53. extern unsigned char smp_int_redirect;
  54. extern volatile int ia64_cpu_to_sapicid[];
  55. #define cpu_physical_id(i) ia64_cpu_to_sapicid[i]
  56. extern unsigned long ap_wakeup_vector;
  57. /*
  58. * Function to map hard smp processor id to logical id. Slow, so don't use this in
  59. * performance-critical code.
  60. */
  61. static inline int
  62. cpu_logical_id (int cpuid)
  63. {
  64. int i;
  65. for (i = 0; i < NR_CPUS; ++i)
  66. if (cpu_physical_id(i) == cpuid)
  67. break;
  68. return i;
  69. }
  70. /*
  71. * XTP control functions:
  72. * min_xtp : route all interrupts to this CPU
  73. * normal_xtp: nominal XTP value
  74. * max_xtp : never deliver interrupts to this CPU.
  75. */
  76. static inline void
  77. min_xtp (void)
  78. {
  79. if (smp_int_redirect & SMP_IRQ_REDIRECTION)
  80. writeb(0x00, ipi_base_addr + XTP_OFFSET); /* XTP to min */
  81. }
  82. static inline void
  83. normal_xtp (void)
  84. {
  85. if (smp_int_redirect & SMP_IRQ_REDIRECTION)
  86. writeb(0x08, ipi_base_addr + XTP_OFFSET); /* XTP normal */
  87. }
  88. static inline void
  89. max_xtp (void)
  90. {
  91. if (smp_int_redirect & SMP_IRQ_REDIRECTION)
  92. writeb(0x0f, ipi_base_addr + XTP_OFFSET); /* Set XTP to max */
  93. }
  94. /* Upping and downing of CPUs */
  95. extern int __cpu_disable (void);
  96. extern void __cpu_die (unsigned int cpu);
  97. extern void cpu_die (void) __attribute__ ((noreturn));
  98. extern void __init smp_build_cpu_map(void);
  99. extern void __init init_smp_config (void);
  100. extern void smp_do_timer (struct pt_regs *regs);
  101. extern irqreturn_t handle_IPI(int irq, void *dev_id);
  102. extern void smp_send_reschedule (int cpu);
  103. extern void identify_siblings (struct cpuinfo_ia64 *);
  104. extern int is_multithreading_enabled(void);
  105. extern void arch_send_call_function_single_ipi(int cpu);
  106. extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
  107. #else /* CONFIG_SMP */
  108. #define cpu_logical_id(i) 0
  109. #define cpu_physical_id(i) ia64_get_lid()
  110. #endif /* CONFIG_SMP */
  111. #endif /* _ASM_IA64_SMP_H */