Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[deliverable/linux.git] / include / asm-x86 / smp.h
CommitLineData
c27cfeff
GC
1#ifndef _ASM_X86_SMP_H_
2#define _ASM_X86_SMP_H_
3#ifndef __ASSEMBLY__
53ebef49 4#include <linux/cpumask.h>
93b016f8 5#include <linux/init.h>
7e1efc0c 6#include <asm/percpu.h>
53ebef49 7
b23dab08
GC
8/*
9 * We need the APIC definitions automatically as part of 'smp.h'
10 */
11#ifdef CONFIG_X86_LOCAL_APIC
12# include <asm/mpspec.h>
13# include <asm/apic.h>
14# ifdef CONFIG_X86_IO_APIC
15# include <asm/io_apic.h>
16# endif
17#endif
18#include <asm/pda.h>
19#include <asm/thread_info.h>
20
53ebef49 21extern cpumask_t cpu_callout_map;
8be9ac85
GC
22extern cpumask_t cpu_initialized;
23extern cpumask_t cpu_callin_map;
24
25extern void (*mtrr_hook)(void);
26extern void zap_low_mappings(void);
53ebef49 27
7c33b1e6
JF
28extern int __cpuinit get_local_pda(int cpu);
29
53ebef49
GC
30extern int smp_num_siblings;
31extern unsigned int num_processors;
cb3c8b90 32extern cpumask_t cpu_initialized;
c27cfeff 33
7e1efc0c
GOC
34DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
35DECLARE_PER_CPU(cpumask_t, cpu_core_map);
36DECLARE_PER_CPU(u16, cpu_llc_id);
23ca4bba
MT
37
38DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid);
39DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid);
7e1efc0c 40
9d97d0da
GOC
41/* Static state in head.S used to set up a CPU */
42extern struct {
43 void *sp;
44 unsigned short ss;
45} stack_start;
46
16694024
GC
47struct smp_ops {
48 void (*smp_prepare_boot_cpu)(void);
49 void (*smp_prepare_cpus)(unsigned max_cpus);
50 int (*cpu_up)(unsigned cpu);
51 void (*smp_cpus_done)(unsigned max_cpus);
52
53 void (*smp_send_stop)(void);
54 void (*smp_send_reschedule)(int cpu);
3b16cf87
JA
55
56 void (*send_call_func_ipi)(cpumask_t mask);
57 void (*send_call_func_single_ipi)(int cpu);
16694024
GC
58};
59
14522076
GC
60/* Globals due to paravirt */
61extern void set_cpu_sibling_map(int cpu);
62
c76cb368 63#ifdef CONFIG_SMP
d0173aea
GOC
64#ifndef CONFIG_PARAVIRT
65#define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
66#endif
c76cb368 67extern struct smp_ops smp_ops;
8678969e 68
377d6984
GC
69static inline void smp_send_stop(void)
70{
71 smp_ops.smp_send_stop();
72}
73
1e3fac83
GC
74static inline void smp_prepare_boot_cpu(void)
75{
76 smp_ops.smp_prepare_boot_cpu();
77}
78
7557da67
GC
79static inline void smp_prepare_cpus(unsigned int max_cpus)
80{
81 smp_ops.smp_prepare_cpus(max_cpus);
82}
83
c5597649
GC
84static inline void smp_cpus_done(unsigned int max_cpus)
85{
86 smp_ops.smp_cpus_done(max_cpus);
87}
88
71d19549
GC
89static inline int __cpu_up(unsigned int cpu)
90{
91 return smp_ops.cpu_up(cpu);
92}
93
8678969e
GC
94static inline void smp_send_reschedule(int cpu)
95{
96 smp_ops.smp_send_reschedule(cpu);
97}
64b1a21e 98
3b16cf87
JA
99static inline void arch_send_call_function_single_ipi(int cpu)
100{
101 smp_ops.send_call_func_single_ipi(cpu);
102}
103
104static inline void arch_send_call_function_ipi(cpumask_t mask)
64b1a21e 105{
3b16cf87 106 smp_ops.send_call_func_ipi(mask);
64b1a21e 107}
71d19549 108
1e3fac83 109void native_smp_prepare_boot_cpu(void);
7557da67 110void native_smp_prepare_cpus(unsigned int max_cpus);
c5597649 111void native_smp_cpus_done(unsigned int max_cpus);
71d19549 112int native_cpu_up(unsigned int cpunum);
3b16cf87
JA
113void native_send_call_func_ipi(cpumask_t mask);
114void native_send_call_func_single_ipi(int cpu);
93b016f8 115
69c18c15
GC
116extern int __cpu_disable(void);
117extern void __cpu_die(unsigned int cpu);
118
1d89a7f0 119void smp_store_cpu_info(int id);
c70dcb74 120#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
a9c057c1
GC
121
122/* We don't mark CPUs online until __cpu_up(), so we need another measure */
123static inline int num_booting_cpus(void)
124{
125 return cpus_weight(cpu_callout_map);
126}
4a701737
IM
127#endif /* CONFIG_SMP */
128
129#if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_CPU)
130extern void prefill_possible_map(void);
329513a3
YL
131#else
132static inline void prefill_possible_map(void)
133{
134}
4a701737 135#endif
a9c057c1 136
2fe60147
AS
137extern unsigned disabled_cpus __cpuinitdata;
138
a9c057c1
GC
139#ifdef CONFIG_X86_32_SMP
140/*
141 * This function is needed by all SMP systems. It must _always_ be valid
142 * from the initial startup. We map APIC_BASE very early in page_setup(),
143 * so this is correct in the x86 case.
144 */
145DECLARE_PER_CPU(int, cpu_number);
146#define raw_smp_processor_id() (x86_read_percpu(cpu_number))
147extern int safe_smp_processor_id(void);
148
149#elif defined(CONFIG_X86_64_SMP)
150#define raw_smp_processor_id() read_pda(cpunumber)
151
152#define stack_smp_processor_id() \
153({ \
154 struct thread_info *ti; \
155 __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
156 ti->cpu; \
157})
158#define safe_smp_processor_id() smp_processor_id()
159
160#else /* !CONFIG_X86_32_SMP && !CONFIG_X86_64_SMP */
c70dcb74 161#define cpu_physical_id(cpu) boot_cpu_physical_apicid
a9c057c1
GC
162#define safe_smp_processor_id() 0
163#define stack_smp_processor_id() 0
c76cb368 164#endif
16694024 165
1b000843
GC
166#ifdef CONFIG_X86_LOCAL_APIC
167
168static inline int logical_smp_processor_id(void)
169{
170 /* we don't want to mark this access volatile - bad code generation */
171 return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
172}
173
a24eae88 174#ifndef CONFIG_X86_64
05f2d12c
JS
175static inline unsigned int read_apic_id(void)
176{
177 return *(u32 *)(APIC_BASE + APIC_ID);
178}
ac23d4ee
JS
179#else
180extern unsigned int read_apic_id(void);
181#endif
182
05f2d12c 183
1b000843
GC
184# ifdef APIC_DEFINITION
185extern int hard_smp_processor_id(void);
186# else
187# include <mach_apicdef.h>
188static inline int hard_smp_processor_id(void)
189{
190 /* we don't want to mark this access volatile - bad code generation */
05f2d12c 191 return GET_APIC_ID(read_apic_id());
1b000843
GC
192}
193# endif /* APIC_DEFINITION */
194
195#else /* CONFIG_X86_LOCAL_APIC */
196
197# ifndef CONFIG_SMP
198# define hard_smp_processor_id() 0
199# endif
200
201#endif /* CONFIG_X86_LOCAL_APIC */
202
1dbb4726 203#ifdef CONFIG_HOTPLUG_CPU
1dbb4726 204extern void cpu_uninit(void);
1dbb4726
GC
205#endif
206
c27cfeff
GC
207#endif /* __ASSEMBLY__ */
208#endif
This page took 0.099769 seconds and 5 git commands to generate.