aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-01-28 12:47:24 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-28 17:20:37 -0500
commit5a44632f77a9c867621f7bf80c233eac75fea672 (patch)
tree48a89d50ab1e4d8f46c663631efdb0913c5c1f58
parent328386d7ab600aa0993a1226f5817ac30a735724 (diff)
x86, numaq: consolidate code
Move all the NUMAQ subarch definitions into numaq.c. With this it ceases to depend on build-time subarch features. Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/include/asm/numaq/apic.h122
-rw-r--r--arch/x86/include/asm/numaq/apicdef.h9
-rw-r--r--arch/x86/include/asm/numaq/ipi.h22
-rw-r--r--arch/x86/include/asm/numaq/mpparse.h6
-rw-r--r--arch/x86/include/asm/numaq/wakecpu.h28
-rw-r--r--arch/x86/mach-generic/numaq.c171
-rw-r--r--arch/x86/pci/numaq_32.c2
7 files changed, 167 insertions, 193 deletions
diff --git a/arch/x86/include/asm/numaq/apic.h b/arch/x86/include/asm/numaq/apic.h
deleted file mode 100644
index ce95e79f7233..000000000000
--- a/arch/x86/include/asm/numaq/apic.h
+++ /dev/null
@@ -1,122 +0,0 @@
1#ifndef __ASM_NUMAQ_APIC_H
2#define __ASM_NUMAQ_APIC_H
3
4#include <asm/io.h>
5#include <linux/mmzone.h>
6#include <linux/nodemask.h>
7
8#define APIC_DFR_VALUE (APIC_DFR_CLUSTER)
9
10static inline const cpumask_t *numaq_target_cpus(void)
11{
12 return &CPU_MASK_ALL;
13}
14
15static inline unsigned long
16numaq_check_apicid_used(physid_mask_t bitmap, int apicid)
17{
18 return physid_isset(apicid, bitmap);
19}
20static inline unsigned long numaq_check_apicid_present(int bit)
21{
22 return physid_isset(bit, phys_cpu_present_map);
23}
24#define apicid_cluster(apicid) (apicid & 0xF0)
25
26static inline int numaq_apic_id_registered(void)
27{
28 return 1;
29}
30
31static inline void numaq_init_apic_ldr(void)
32{
33 /* Already done in NUMA-Q firmware */
34}
35
36static inline void numaq_setup_apic_routing(void)
37{
38 printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
39 "NUMA-Q", nr_ioapics);
40}
41
42/*
43 * Skip adding the timer int on secondary nodes, which causes
44 * a small but painful rift in the time-space continuum.
45 */
46static inline int numaq_multi_timer_check(int apic, int irq)
47{
48 return apic != 0 && irq == 0;
49}
50
51static inline physid_mask_t numaq_ioapic_phys_id_map(physid_mask_t phys_map)
52{
53 /* We don't have a good way to do this yet - hack */
54 return physids_promote(0xFUL);
55}
56
57/* Mapping from cpu number to logical apicid */
58extern u8 cpu_2_logical_apicid[];
59
60static inline int numaq_cpu_to_logical_apicid(int cpu)
61{
62 if (cpu >= nr_cpu_ids)
63 return BAD_APICID;
64 return (int)cpu_2_logical_apicid[cpu];
65}
66
67/*
68 * Supporting over 60 cpus on NUMA-Q requires a locality-dependent
69 * cpu to APIC ID relation to properly interact with the intelligent
70 * mode of the cluster controller.
71 */
72static inline int numaq_cpu_present_to_apicid(int mps_cpu)
73{
74 if (mps_cpu < 60)
75 return ((mps_cpu >> 2) << 4) | (1 << (mps_cpu & 0x3));
76 else
77 return BAD_APICID;
78}
79
80static inline int numaq_apicid_to_node(int logical_apicid)
81{
82 return logical_apicid >> 4;
83}
84
85static inline physid_mask_t numaq_apicid_to_cpu_present(int logical_apicid)
86{
87 int node = numaq_apicid_to_node(logical_apicid);
88 int cpu = __ffs(logical_apicid & 0xf);
89
90 return physid_mask_of_physid(cpu + 4*node);
91}
92
93extern void *xquad_portio;
94
95static inline int numaq_check_phys_apicid_present(int boot_cpu_physical_apicid)
96{
97 return 1;
98}
99
100/*
101 * We use physical apicids here, not logical, so just return the default
102 * physical broadcast to stop people from breaking us
103 */
104static inline unsigned int numaq_cpu_mask_to_apicid(const cpumask_t *cpumask)
105{
106 return 0x0F;
107}
108
109static inline unsigned int
110numaq_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
111 const struct cpumask *andmask)
112{
113 return 0x0F;
114}
115
116/* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */
117static inline int numaq_phys_pkg_id(int cpuid_apic, int index_msb)
118{
119 return cpuid_apic >> index_msb;
120}
121
122#endif /* __ASM_NUMAQ_APIC_H */
diff --git a/arch/x86/include/asm/numaq/apicdef.h b/arch/x86/include/asm/numaq/apicdef.h
deleted file mode 100644
index cd927d5bd505..000000000000
--- a/arch/x86/include/asm/numaq/apicdef.h
+++ /dev/null
@@ -1,9 +0,0 @@
1#ifndef __ASM_NUMAQ_APICDEF_H
2#define __ASM_NUMAQ_APICDEF_H
3
4static inline unsigned int numaq_get_apic_id(unsigned long x)
5{
6 return (x >> 24) & 0x0F;
7}
8
9#endif
diff --git a/arch/x86/include/asm/numaq/ipi.h b/arch/x86/include/asm/numaq/ipi.h
deleted file mode 100644
index 5dbc4b4cd5e5..000000000000
--- a/arch/x86/include/asm/numaq/ipi.h
+++ /dev/null
@@ -1,22 +0,0 @@
1#ifndef __ASM_NUMAQ_IPI_H
2#define __ASM_NUMAQ_IPI_H
3
4void default_send_IPI_mask_sequence(const struct cpumask *mask, int vector);
5void default_send_IPI_mask_allbutself(const struct cpumask *mask, int vector);
6
7static inline void numaq_send_IPI_mask(const struct cpumask *mask, int vector)
8{
9 default_send_IPI_mask_sequence(mask, vector);
10}
11
12static inline void numaq_send_IPI_allbutself(int vector)
13{
14 default_send_IPI_mask_allbutself(cpu_online_mask, vector);
15}
16
17static inline void numaq_send_IPI_all(int vector)
18{
19 numaq_send_IPI_mask(cpu_online_mask, vector);
20}
21
22#endif /* __ASM_NUMAQ_IPI_H */
diff --git a/arch/x86/include/asm/numaq/mpparse.h b/arch/x86/include/asm/numaq/mpparse.h
deleted file mode 100644
index a2eeefcd1cc7..000000000000
--- a/arch/x86/include/asm/numaq/mpparse.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_NUMAQ_MPPARSE_H
2#define __ASM_NUMAQ_MPPARSE_H
3
4extern void numaq_mps_oem_check(struct mpc_table *, char *, char *);
5
6#endif /* __ASM_NUMAQ_MPPARSE_H */
diff --git a/arch/x86/include/asm/numaq/wakecpu.h b/arch/x86/include/asm/numaq/wakecpu.h
deleted file mode 100644
index afe81439c7db..000000000000
--- a/arch/x86/include/asm/numaq/wakecpu.h
+++ /dev/null
@@ -1,28 +0,0 @@
1#ifndef __ASM_NUMAQ_WAKECPU_H
2#define __ASM_NUMAQ_WAKECPU_H
3
4/* This file copes with machines that wakeup secondary CPUs by NMIs */
5
6#define NUMAQ_TRAMPOLINE_PHYS_LOW (0x8)
7#define NUMAQ_TRAMPOLINE_PHYS_HIGH (0xa)
8
9/*
10 * Because we use NMIs rather than the INIT-STARTUP sequence to
11 * bootstrap the CPUs, the APIC may be in a weird state. Kick it:
12 */
13static inline void numaq_smp_callin_clear_local_apic(void)
14{
15 clear_local_APIC();
16}
17
18static inline void
19numaq_store_NMI_vector(unsigned short *high, unsigned short *low)
20{
21 printk("Storing NMI vector\n");
22 *high =
23 *((volatile unsigned short *)phys_to_virt(NUMAQ_TRAMPOLINE_PHYS_HIGH));
24 *low =
25 *((volatile unsigned short *)phys_to_virt(NUMAQ_TRAMPOLINE_PHYS_LOW));
26}
27
28#endif /* __ASM_NUMAQ_WAKECPU_H */
diff --git a/arch/x86/mach-generic/numaq.c b/arch/x86/mach-generic/numaq.c
index ddb50fba2868..c221cfb2c2db 100644
--- a/arch/x86/mach-generic/numaq.c
+++ b/arch/x86/mach-generic/numaq.c
@@ -11,14 +11,175 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/string.h> 12#include <linux/string.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <asm/numaq/apicdef.h> 14#include <linux/numa.h>
15#include <linux/smp.h> 15#include <linux/smp.h>
16#include <asm/numaq/apic.h>
17#include <asm/numaq/ipi.h>
18#include <asm/numaq/mpparse.h>
19#include <asm/numaq/wakecpu.h>
20#include <asm/numaq.h> 16#include <asm/numaq.h>
17#include <asm/io.h>
18#include <linux/mmzone.h>
19#include <linux/nodemask.h>
21 20
21#define NUMAQ_APIC_DFR_VALUE (APIC_DFR_CLUSTER)
22
23static inline unsigned int numaq_get_apic_id(unsigned long x)
24{
25 return (x >> 24) & 0x0F;
26}
27
28void default_send_IPI_mask_sequence(const struct cpumask *mask, int vector);
29void default_send_IPI_mask_allbutself(const struct cpumask *mask, int vector);
30
31static inline void numaq_send_IPI_mask(const struct cpumask *mask, int vector)
32{
33 default_send_IPI_mask_sequence(mask, vector);
34}
35
36static inline void numaq_send_IPI_allbutself(int vector)
37{
38 default_send_IPI_mask_allbutself(cpu_online_mask, vector);
39}
40
41static inline void numaq_send_IPI_all(int vector)
42{
43 numaq_send_IPI_mask(cpu_online_mask, vector);
44}
45
46extern void numaq_mps_oem_check(struct mpc_table *, char *, char *);
47
48#define NUMAQ_TRAMPOLINE_PHYS_LOW (0x8)
49#define NUMAQ_TRAMPOLINE_PHYS_HIGH (0xa)
50
51/*
52 * Because we use NMIs rather than the INIT-STARTUP sequence to
53 * bootstrap the CPUs, the APIC may be in a weird state. Kick it:
54 */
55static inline void numaq_smp_callin_clear_local_apic(void)
56{
57 clear_local_APIC();
58}
59
60static inline void
61numaq_store_NMI_vector(unsigned short *high, unsigned short *low)
62{
63 printk("Storing NMI vector\n");
64 *high =
65 *((volatile unsigned short *)phys_to_virt(NUMAQ_TRAMPOLINE_PHYS_HIGH));
66 *low =
67 *((volatile unsigned short *)phys_to_virt(NUMAQ_TRAMPOLINE_PHYS_LOW));
68}
69
70static inline const cpumask_t *numaq_target_cpus(void)
71{
72 return &CPU_MASK_ALL;
73}
74
75static inline unsigned long
76numaq_check_apicid_used(physid_mask_t bitmap, int apicid)
77{
78 return physid_isset(apicid, bitmap);
79}
80
81static inline unsigned long numaq_check_apicid_present(int bit)
82{
83 return physid_isset(bit, phys_cpu_present_map);
84}
85
86#define apicid_cluster(apicid) (apicid & 0xF0)
87
88static inline int numaq_apic_id_registered(void)
89{
90 return 1;
91}
92
93static inline void numaq_init_apic_ldr(void)
94{
95 /* Already done in NUMA-Q firmware */
96}
97
98static inline void numaq_setup_apic_routing(void)
99{
100 printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
101 "NUMA-Q", nr_ioapics);
102}
103
104/*
105 * Skip adding the timer int on secondary nodes, which causes
106 * a small but painful rift in the time-space continuum.
107 */
108static inline int numaq_multi_timer_check(int apic, int irq)
109{
110 return apic != 0 && irq == 0;
111}
112
113static inline physid_mask_t numaq_ioapic_phys_id_map(physid_mask_t phys_map)
114{
115 /* We don't have a good way to do this yet - hack */
116 return physids_promote(0xFUL);
117}
118
119/* Mapping from cpu number to logical apicid */
120extern u8 cpu_2_logical_apicid[];
121
122static inline int numaq_cpu_to_logical_apicid(int cpu)
123{
124 if (cpu >= nr_cpu_ids)
125 return BAD_APICID;
126 return (int)cpu_2_logical_apicid[cpu];
127}
128
129/*
130 * Supporting over 60 cpus on NUMA-Q requires a locality-dependent
131 * cpu to APIC ID relation to properly interact with the intelligent
132 * mode of the cluster controller.
133 */
134static inline int numaq_cpu_present_to_apicid(int mps_cpu)
135{
136 if (mps_cpu < 60)
137 return ((mps_cpu >> 2) << 4) | (1 << (mps_cpu & 0x3));
138 else
139 return BAD_APICID;
140}
141
142static inline int numaq_apicid_to_node(int logical_apicid)
143{
144 return logical_apicid >> 4;
145}
146
147static inline physid_mask_t numaq_apicid_to_cpu_present(int logical_apicid)
148{
149 int node = numaq_apicid_to_node(logical_apicid);
150 int cpu = __ffs(logical_apicid & 0xf);
151
152 return physid_mask_of_physid(cpu + 4*node);
153}
154
155extern void *xquad_portio;
156
157static inline int numaq_check_phys_apicid_present(int boot_cpu_physical_apicid)
158{
159 return 1;
160}
161
162/*
163 * We use physical apicids here, not logical, so just return the default
164 * physical broadcast to stop people from breaking us
165 */
166static inline unsigned int numaq_cpu_mask_to_apicid(const cpumask_t *cpumask)
167{
168 return 0x0F;
169}
170
171static inline unsigned int
172numaq_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
173 const struct cpumask *andmask)
174{
175 return 0x0F;
176}
177
178/* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */
179static inline int numaq_phys_pkg_id(int cpuid_apic, int index_msb)
180{
181 return cpuid_apic >> index_msb;
182}
22static int __numaq_mps_oem_check(struct mpc_table *mpc, char *oem, char *productid) 183static int __numaq_mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
23{ 184{
24 numaq_mps_oem_check(mpc, oem, productid); 185 numaq_mps_oem_check(mpc, oem, productid);
diff --git a/arch/x86/pci/numaq_32.c b/arch/x86/pci/numaq_32.c
index 2089354968a2..1b2d773612e7 100644
--- a/arch/x86/pci/numaq_32.c
+++ b/arch/x86/pci/numaq_32.c
@@ -5,7 +5,7 @@
5#include <linux/pci.h> 5#include <linux/pci.h>
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/nodemask.h> 7#include <linux/nodemask.h>
8#include <mach_apic.h> 8#include <asm/genapic.h>
9#include <asm/mpspec.h> 9#include <asm/mpspec.h>
10#include <asm/pci_x86.h> 10#include <asm/pci_x86.h>
11 11