blob: 7847ae40a181e91dc6da96382ec255f3e8d5f021 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/init.h>
15#include <linux/threads.h>
16#include <linux/kernel.h>
17#include <linux/cpumask.h>
Jiri Slaby1977f032007-10-18 23:40:25 -070018#include <linux/bitops.h>
Isaku Yamahata444933c2008-05-19 22:13:28 +090019#include <linux/irqreturn.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/io.h>
22#include <asm/param.h>
23#include <asm/processor.h>
24#include <asm/ptrace.h>
25
26static inline unsigned int
27ia64_get_lid (void)
28{
29 union {
30 struct {
31 unsigned long reserved : 16;
32 unsigned long eid : 8;
33 unsigned long id : 8;
34 unsigned long ignored : 32;
35 } f;
36 unsigned long bits;
37 } lid;
38
39 lid.bits = ia64_getreg(_IA64_REG_CR_LID);
40 return lid.f.id << 8 | lid.f.eid;
41}
42
Fernando Luis Vazquez Cao818563d2007-05-09 02:33:28 -070043#define hard_smp_processor_id() ia64_get_lid()
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#ifdef CONFIG_SMP
46
47#define XTP_OFFSET 0x1e0008
48
49#define SMP_IRQ_REDIRECTION (1 << 0)
50#define SMP_IPI_REDIRECTION (1 << 1)
51
Ingo Molnar39c715b2005-06-21 17:14:34 -070052#define raw_smp_processor_id() (current_thread_info()->cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
54extern struct smp_boot_data {
55 int cpu_count;
56 int cpu_phys_id[NR_CPUS];
57} smp_boot_data __initdata;
58
Greg Kroah-Hartman5b5e76e2012-12-21 14:05:13 -080059extern char no_int_routing;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Suresh Siddhae927ecb2005-04-25 13:25:06 -070061extern cpumask_t cpu_core_map[NR_CPUS];
David Howells9b8de742009-04-21 23:00:24 +010062DECLARE_PER_CPU_SHARED_ALIGNED(cpumask_t, cpu_sibling_map);
Suresh Siddhae927ecb2005-04-25 13:25:06 -070063extern int smp_num_siblings;
Linus Torvalds1da177e2005-04-16 15:20:36 -070064extern void __iomem *ipi_base_addr;
65extern unsigned char smp_int_redirect;
66
67extern volatile int ia64_cpu_to_sapicid[];
68#define cpu_physical_id(i) ia64_cpu_to_sapicid[i]
69
70extern unsigned long ap_wakeup_vector;
71
72/*
73 * Function to map hard smp processor id to logical id. Slow, so don't use this in
74 * performance-critical code.
75 */
76static inline int
77cpu_logical_id (int cpuid)
78{
79 int i;
80
81 for (i = 0; i < NR_CPUS; ++i)
82 if (cpu_physical_id(i) == cpuid)
83 break;
84 return i;
85}
86
87/*
88 * XTP control functions:
89 * min_xtp : route all interrupts to this CPU
90 * normal_xtp: nominal XTP value
91 * max_xtp : never deliver interrupts to this CPU.
92 */
93
94static inline void
95min_xtp (void)
96{
97 if (smp_int_redirect & SMP_IRQ_REDIRECTION)
98 writeb(0x00, ipi_base_addr + XTP_OFFSET); /* XTP to min */
99}
100
101static inline void
102normal_xtp (void)
103{
104 if (smp_int_redirect & SMP_IRQ_REDIRECTION)
105 writeb(0x08, ipi_base_addr + XTP_OFFSET); /* XTP normal */
106}
107
108static inline void
109max_xtp (void)
110{
111 if (smp_int_redirect & SMP_IRQ_REDIRECTION)
112 writeb(0x0f, ipi_base_addr + XTP_OFFSET); /* Set XTP to max */
113}
114
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115/* Upping and downing of CPUs */
116extern int __cpu_disable (void);
117extern void __cpu_die (unsigned int cpu);
118extern void cpu_die (void) __attribute__ ((noreturn));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119extern void __init smp_build_cpu_map(void);
120
121extern void __init init_smp_config (void);
122extern void smp_do_timer (struct pt_regs *regs);
123
Isaku Yamahata444933c2008-05-19 22:13:28 +0900124extern irqreturn_t handle_IPI(int irq, void *dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125extern void smp_send_reschedule (int cpu);
Suresh Siddhae927ecb2005-04-25 13:25:06 -0700126extern void identify_siblings (struct cpuinfo_ia64 *);
Stephane Eraniandd562c02006-09-21 10:35:44 -0700127extern int is_multithreading_enabled(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
Jens Axboef27b4332008-06-26 11:22:30 +0200129extern void arch_send_call_function_single_ipi(int cpu);
Rusty Russell40fe6972009-03-16 14:12:41 +1030130extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
Jens Axboef27b4332008-06-26 11:22:30 +0200131
Fernando Luis Vazquez Cao2f4dfe22007-05-09 02:33:25 -0700132#else /* CONFIG_SMP */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134#define cpu_logical_id(i) 0
135#define cpu_physical_id(i) ia64_get_lid()
136
137#endif /* CONFIG_SMP */
138#endif /* _ASM_IA64_SMP_H */