diff options
author | Daniel J Blueman <daniel@numascale.com> | 2015-09-20 13:01:59 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2015-09-22 16:25:32 -0400 |
commit | db1003a719d75cebe5843a7906c02c29bec9922c (patch) | |
tree | 853ca4d310f22901b1731d0de62985763d42ed23 | |
parent | 1f93e4a96c9109378204c147b3eec0d0e8100fde (diff) |
x86/numachip: Cleanup Numachip support
Drop unused code and includes in Numachip header files and APIC driver.
Additionally, use the 'numachip1' prefix on Numachip1-specific functions;
this prepares for adding Numachip2 support in later patches.
Signed-off-by: Daniel J Blueman <daniel@numascale.com>
Acked-by: Steffen Persvold <sp@numascale.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: http://lkml.kernel.org/r/1442768522-19217-1-git-send-email-daniel@numascale.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | arch/x86/include/asm/numachip/numachip_csr.h | 118 | ||||
-rw-r--r-- | arch/x86/kernel/apic/apic_numachip.c | 104 |
2 files changed, 44 insertions, 178 deletions
diff --git a/arch/x86/include/asm/numachip/numachip_csr.h b/arch/x86/include/asm/numachip/numachip_csr.h index 660f843df928..7469b13a9cfa 100644 --- a/arch/x86/include/asm/numachip/numachip_csr.h +++ b/arch/x86/include/asm/numachip/numachip_csr.h | |||
@@ -14,12 +14,7 @@ | |||
14 | #ifndef _ASM_X86_NUMACHIP_NUMACHIP_CSR_H | 14 | #ifndef _ASM_X86_NUMACHIP_NUMACHIP_CSR_H |
15 | #define _ASM_X86_NUMACHIP_NUMACHIP_CSR_H | 15 | #define _ASM_X86_NUMACHIP_NUMACHIP_CSR_H |
16 | 16 | ||
17 | #include <linux/numa.h> | ||
18 | #include <linux/percpu.h> | ||
19 | #include <linux/io.h> | 17 | #include <linux/io.h> |
20 | #include <linux/swab.h> | ||
21 | #include <asm/types.h> | ||
22 | #include <asm/processor.h> | ||
23 | 18 | ||
24 | #define CSR_NODE_SHIFT 16 | 19 | #define CSR_NODE_SHIFT 16 |
25 | #define CSR_NODE_BITS(p) (((unsigned long)(p)) << CSR_NODE_SHIFT) | 20 | #define CSR_NODE_BITS(p) (((unsigned long)(p)) << CSR_NODE_SHIFT) |
@@ -27,11 +22,8 @@ | |||
27 | 22 | ||
28 | /* 32K CSR space, b15 indicates geo/non-geo */ | 23 | /* 32K CSR space, b15 indicates geo/non-geo */ |
29 | #define CSR_OFFSET_MASK 0x7fffUL | 24 | #define CSR_OFFSET_MASK 0x7fffUL |
30 | 25 | #define CSR_G0_NODE_IDS (0x008 + (0 << 12)) | |
31 | /* Global CSR space covers all 4K possible nodes with 64K CSR space per node */ | 26 | #define CSR_G3_EXT_IRQ_GEN (0x030 + (3 << 12)) |
32 | #define NUMACHIP_GCSR_BASE 0x3fff00000000ULL | ||
33 | #define NUMACHIP_GCSR_LIM 0x3fff0fffffffULL | ||
34 | #define NUMACHIP_GCSR_SIZE (NUMACHIP_GCSR_LIM - NUMACHIP_GCSR_BASE + 1) | ||
35 | 27 | ||
36 | /* | 28 | /* |
37 | * Local CSR space starts in global CSR space with "nodeid" = 0xfff0, however | 29 | * Local CSR space starts in global CSR space with "nodeid" = 0xfff0, however |
@@ -42,28 +34,12 @@ | |||
42 | #define NUMACHIP_LCSR_LIM 0x3fffffffffffULL | 34 | #define NUMACHIP_LCSR_LIM 0x3fffffffffffULL |
43 | #define NUMACHIP_LCSR_SIZE (NUMACHIP_LCSR_LIM - NUMACHIP_LCSR_BASE + 1) | 35 | #define NUMACHIP_LCSR_SIZE (NUMACHIP_LCSR_LIM - NUMACHIP_LCSR_BASE + 1) |
44 | 36 | ||
45 | static inline void *gcsr_address(int node, unsigned long offset) | ||
46 | { | ||
47 | return __va(NUMACHIP_GCSR_BASE | (1UL << 15) | | ||
48 | CSR_NODE_BITS(node & CSR_NODE_MASK) | (offset & CSR_OFFSET_MASK)); | ||
49 | } | ||
50 | |||
51 | static inline void *lcsr_address(unsigned long offset) | 37 | static inline void *lcsr_address(unsigned long offset) |
52 | { | 38 | { |
53 | return __va(NUMACHIP_LCSR_BASE | (1UL << 15) | | 39 | return __va(NUMACHIP_LCSR_BASE | (1UL << 15) | |
54 | CSR_NODE_BITS(0xfff0) | (offset & CSR_OFFSET_MASK)); | 40 | CSR_NODE_BITS(0xfff0) | (offset & CSR_OFFSET_MASK)); |
55 | } | 41 | } |
56 | 42 | ||
57 | static inline unsigned int read_gcsr(int node, unsigned long offset) | ||
58 | { | ||
59 | return swab32(readl(gcsr_address(node, offset))); | ||
60 | } | ||
61 | |||
62 | static inline void write_gcsr(int node, unsigned long offset, unsigned int val) | ||
63 | { | ||
64 | writel(swab32(val), gcsr_address(node, offset)); | ||
65 | } | ||
66 | |||
67 | static inline unsigned int read_lcsr(unsigned long offset) | 43 | static inline unsigned int read_lcsr(unsigned long offset) |
68 | { | 44 | { |
69 | return swab32(readl(lcsr_address(offset))); | 45 | return swab32(readl(lcsr_address(offset))); |
@@ -74,94 +50,4 @@ static inline void write_lcsr(unsigned long offset, unsigned int val) | |||
74 | writel(swab32(val), lcsr_address(offset)); | 50 | writel(swab32(val), lcsr_address(offset)); |
75 | } | 51 | } |
76 | 52 | ||
77 | /* ========================================================================= */ | ||
78 | /* CSR_G0_STATE_CLEAR */ | ||
79 | /* ========================================================================= */ | ||
80 | |||
81 | #define CSR_G0_STATE_CLEAR (0x000 + (0 << 12)) | ||
82 | union numachip_csr_g0_state_clear { | ||
83 | unsigned int v; | ||
84 | struct numachip_csr_g0_state_clear_s { | ||
85 | unsigned int _state:2; | ||
86 | unsigned int _rsvd_2_6:5; | ||
87 | unsigned int _lost:1; | ||
88 | unsigned int _rsvd_8_31:24; | ||
89 | } s; | ||
90 | }; | ||
91 | |||
92 | /* ========================================================================= */ | ||
93 | /* CSR_G0_NODE_IDS */ | ||
94 | /* ========================================================================= */ | ||
95 | |||
96 | #define CSR_G0_NODE_IDS (0x008 + (0 << 12)) | ||
97 | union numachip_csr_g0_node_ids { | ||
98 | unsigned int v; | ||
99 | struct numachip_csr_g0_node_ids_s { | ||
100 | unsigned int _initialid:16; | ||
101 | unsigned int _nodeid:12; | ||
102 | unsigned int _rsvd_28_31:4; | ||
103 | } s; | ||
104 | }; | ||
105 | |||
106 | /* ========================================================================= */ | ||
107 | /* CSR_G3_EXT_IRQ_GEN */ | ||
108 | /* ========================================================================= */ | ||
109 | |||
110 | #define CSR_G3_EXT_IRQ_GEN (0x030 + (3 << 12)) | ||
111 | union numachip_csr_g3_ext_irq_gen { | ||
112 | unsigned int v; | ||
113 | struct numachip_csr_g3_ext_irq_gen_s { | ||
114 | unsigned int _vector:8; | ||
115 | unsigned int _msgtype:3; | ||
116 | unsigned int _index:5; | ||
117 | unsigned int _destination_apic_id:16; | ||
118 | } s; | ||
119 | }; | ||
120 | |||
121 | /* ========================================================================= */ | ||
122 | /* CSR_G3_EXT_IRQ_STATUS */ | ||
123 | /* ========================================================================= */ | ||
124 | |||
125 | #define CSR_G3_EXT_IRQ_STATUS (0x034 + (3 << 12)) | ||
126 | union numachip_csr_g3_ext_irq_status { | ||
127 | unsigned int v; | ||
128 | struct numachip_csr_g3_ext_irq_status_s { | ||
129 | unsigned int _result:32; | ||
130 | } s; | ||
131 | }; | ||
132 | |||
133 | /* ========================================================================= */ | ||
134 | /* CSR_G3_EXT_IRQ_DEST */ | ||
135 | /* ========================================================================= */ | ||
136 | |||
137 | #define CSR_G3_EXT_IRQ_DEST (0x038 + (3 << 12)) | ||
138 | union numachip_csr_g3_ext_irq_dest { | ||
139 | unsigned int v; | ||
140 | struct numachip_csr_g3_ext_irq_dest_s { | ||
141 | unsigned int _irq:8; | ||
142 | unsigned int _rsvd_8_31:24; | ||
143 | } s; | ||
144 | }; | ||
145 | |||
146 | /* ========================================================================= */ | ||
147 | /* CSR_G3_NC_ATT_MAP_SELECT */ | ||
148 | /* ========================================================================= */ | ||
149 | |||
150 | #define CSR_G3_NC_ATT_MAP_SELECT (0x7fc + (3 << 12)) | ||
151 | union numachip_csr_g3_nc_att_map_select { | ||
152 | unsigned int v; | ||
153 | struct numachip_csr_g3_nc_att_map_select_s { | ||
154 | unsigned int _upper_address_bits:4; | ||
155 | unsigned int _select_ram:4; | ||
156 | unsigned int _rsvd_8_31:24; | ||
157 | } s; | ||
158 | }; | ||
159 | |||
160 | /* ========================================================================= */ | ||
161 | /* CSR_G3_NC_ATT_MAP_SELECT_0-255 */ | ||
162 | /* ========================================================================= */ | ||
163 | |||
164 | #define CSR_G3_NC_ATT_MAP_SELECT_0 (0x800 + (3 << 12)) | ||
165 | |||
166 | #endif /* _ASM_X86_NUMACHIP_NUMACHIP_CSR_H */ | 53 | #endif /* _ASM_X86_NUMACHIP_NUMACHIP_CSR_H */ |
167 | |||
diff --git a/arch/x86/kernel/apic/apic_numachip.c b/arch/x86/kernel/apic/apic_numachip.c index b548fd3b764b..eeefbb11ec79 100644 --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c | |||
@@ -11,30 +11,20 @@ | |||
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/errno.h> | ||
15 | #include <linux/threads.h> | ||
16 | #include <linux/cpumask.h> | ||
17 | #include <linux/string.h> | ||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/ctype.h> | ||
21 | #include <linux/init.h> | 14 | #include <linux/init.h> |
22 | #include <linux/hardirq.h> | ||
23 | #include <linux/delay.h> | ||
24 | 15 | ||
25 | #include <asm/numachip/numachip.h> | 16 | #include <asm/numachip/numachip.h> |
26 | #include <asm/numachip/numachip_csr.h> | 17 | #include <asm/numachip/numachip_csr.h> |
27 | #include <asm/smp.h> | ||
28 | #include <asm/apic.h> | ||
29 | #include <asm/ipi.h> | 18 | #include <asm/ipi.h> |
30 | #include <asm/apic_flat_64.h> | 19 | #include <asm/apic_flat_64.h> |
31 | #include <asm/pgtable.h> | 20 | #include <asm/pgtable.h> |
21 | #include <asm/pci_x86.h> | ||
32 | 22 | ||
33 | static int numachip_system __read_mostly; | 23 | u8 numachip_system __read_mostly; |
24 | static const struct apic apic_numachip1; | ||
25 | static void (*numachip_apic_icr_write)(int apicid, unsigned int val) __read_mostly; | ||
34 | 26 | ||
35 | static const struct apic apic_numachip; | 27 | static unsigned int numachip1_get_apic_id(unsigned long x) |
36 | |||
37 | static unsigned int get_apic_id(unsigned long x) | ||
38 | { | 28 | { |
39 | unsigned long value; | 29 | unsigned long value; |
40 | unsigned int id = (x >> 24) & 0xff; | 30 | unsigned int id = (x >> 24) & 0xff; |
@@ -47,7 +37,7 @@ static unsigned int get_apic_id(unsigned long x) | |||
47 | return id; | 37 | return id; |
48 | } | 38 | } |
49 | 39 | ||
50 | static unsigned long set_apic_id(unsigned int id) | 40 | static unsigned long numachip1_set_apic_id(unsigned int id) |
51 | { | 41 | { |
52 | unsigned long x; | 42 | unsigned long x; |
53 | 43 | ||
@@ -55,11 +45,6 @@ static unsigned long set_apic_id(unsigned int id) | |||
55 | return x; | 45 | return x; |
56 | } | 46 | } |
57 | 47 | ||
58 | static unsigned int read_xapic_id(void) | ||
59 | { | ||
60 | return get_apic_id(apic_read(APIC_ID)); | ||
61 | } | ||
62 | |||
63 | static int numachip_apic_id_valid(int apicid) | 48 | static int numachip_apic_id_valid(int apicid) |
64 | { | 49 | { |
65 | /* Trust what bootloader passes in MADT */ | 50 | /* Trust what bootloader passes in MADT */ |
@@ -68,7 +53,7 @@ static int numachip_apic_id_valid(int apicid) | |||
68 | 53 | ||
69 | static int numachip_apic_id_registered(void) | 54 | static int numachip_apic_id_registered(void) |
70 | { | 55 | { |
71 | return physid_isset(read_xapic_id(), phys_cpu_present_map); | 56 | return 1; |
72 | } | 57 | } |
73 | 58 | ||
74 | static int numachip_phys_pkg_id(int initial_apic_id, int index_msb) | 59 | static int numachip_phys_pkg_id(int initial_apic_id, int index_msb) |
@@ -76,36 +61,27 @@ static int numachip_phys_pkg_id(int initial_apic_id, int index_msb) | |||
76 | return initial_apic_id >> index_msb; | 61 | return initial_apic_id >> index_msb; |
77 | } | 62 | } |
78 | 63 | ||
79 | static int numachip_wakeup_secondary(int phys_apicid, unsigned long start_rip) | 64 | static void numachip1_apic_icr_write(int apicid, unsigned int val) |
80 | { | 65 | { |
81 | union numachip_csr_g3_ext_irq_gen int_gen; | 66 | write_lcsr(CSR_G3_EXT_IRQ_GEN, (apicid << 16) | val); |
82 | 67 | } | |
83 | int_gen.s._destination_apic_id = phys_apicid; | ||
84 | int_gen.s._vector = 0; | ||
85 | int_gen.s._msgtype = APIC_DM_INIT >> 8; | ||
86 | int_gen.s._index = 0; | ||
87 | |||
88 | write_lcsr(CSR_G3_EXT_IRQ_GEN, int_gen.v); | ||
89 | |||
90 | int_gen.s._msgtype = APIC_DM_STARTUP >> 8; | ||
91 | int_gen.s._vector = start_rip >> 12; | ||
92 | 68 | ||
93 | write_lcsr(CSR_G3_EXT_IRQ_GEN, int_gen.v); | 69 | static int numachip_wakeup_secondary(int phys_apicid, unsigned long start_rip) |
70 | { | ||
71 | numachip_apic_icr_write(phys_apicid, APIC_DM_INIT); | ||
72 | numachip_apic_icr_write(phys_apicid, APIC_DM_STARTUP | | ||
73 | (start_rip >> 12)); | ||
94 | 74 | ||
95 | return 0; | 75 | return 0; |
96 | } | 76 | } |
97 | 77 | ||
98 | static void numachip_send_IPI_one(int cpu, int vector) | 78 | static void numachip_send_IPI_one(int cpu, int vector) |
99 | { | 79 | { |
100 | union numachip_csr_g3_ext_irq_gen int_gen; | ||
101 | int apicid = per_cpu(x86_cpu_to_apicid, cpu); | 80 | int apicid = per_cpu(x86_cpu_to_apicid, cpu); |
81 | unsigned int dmode; | ||
102 | 82 | ||
103 | int_gen.s._destination_apic_id = apicid; | 83 | dmode = (vector == NMI_VECTOR) ? APIC_DM_NMI : APIC_DM_FIXED; |
104 | int_gen.s._vector = vector; | 84 | numachip_apic_icr_write(apicid, dmode | vector); |
105 | int_gen.s._msgtype = (vector == NMI_VECTOR ? APIC_DM_NMI : APIC_DM_FIXED) >> 8; | ||
106 | int_gen.s._index = 0; | ||
107 | |||
108 | write_lcsr(CSR_G3_EXT_IRQ_GEN, int_gen.v); | ||
109 | } | 85 | } |
110 | 86 | ||
111 | static void numachip_send_IPI_mask(const struct cpumask *mask, int vector) | 87 | static void numachip_send_IPI_mask(const struct cpumask *mask, int vector) |
@@ -149,9 +125,9 @@ static void numachip_send_IPI_self(int vector) | |||
149 | apic_write(APIC_SELF_IPI, vector); | 125 | apic_write(APIC_SELF_IPI, vector); |
150 | } | 126 | } |
151 | 127 | ||
152 | static int __init numachip_probe(void) | 128 | static int __init numachip1_probe(void) |
153 | { | 129 | { |
154 | return apic == &apic_numachip; | 130 | return apic == &apic_numachip1; |
155 | } | 131 | } |
156 | 132 | ||
157 | static void fixup_cpu_id(struct cpuinfo_x86 *c, int node) | 133 | static void fixup_cpu_id(struct cpuinfo_x86 *c, int node) |
@@ -172,34 +148,38 @@ static void fixup_cpu_id(struct cpuinfo_x86 *c, int node) | |||
172 | 148 | ||
173 | static int __init numachip_system_init(void) | 149 | static int __init numachip_system_init(void) |
174 | { | 150 | { |
175 | if (!numachip_system) | 151 | /* Map the LCSR area and set up the apic_icr_write function */ |
152 | switch (numachip_system) { | ||
153 | case 1: | ||
154 | init_extra_mapping_uc(NUMACHIP_LCSR_BASE, NUMACHIP_LCSR_SIZE); | ||
155 | numachip_apic_icr_write = numachip1_apic_icr_write; | ||
156 | x86_init.pci.arch_init = pci_numachip_init; | ||
157 | break; | ||
158 | default: | ||
176 | return 0; | 159 | return 0; |
177 | 160 | } | |
178 | init_extra_mapping_uc(NUMACHIP_LCSR_BASE, NUMACHIP_LCSR_SIZE); | ||
179 | init_extra_mapping_uc(NUMACHIP_GCSR_BASE, NUMACHIP_GCSR_SIZE); | ||
180 | 161 | ||
181 | x86_cpuinit.fixup_cpu_id = fixup_cpu_id; | 162 | x86_cpuinit.fixup_cpu_id = fixup_cpu_id; |
182 | x86_init.pci.arch_init = pci_numachip_init; | ||
183 | 163 | ||
184 | return 0; | 164 | return 0; |
185 | } | 165 | } |
186 | early_initcall(numachip_system_init); | 166 | early_initcall(numachip_system_init); |
187 | 167 | ||
188 | static int numachip_acpi_madt_oem_check(char *oem_id, char *oem_table_id) | 168 | static int numachip1_acpi_madt_oem_check(char *oem_id, char *oem_table_id) |
189 | { | 169 | { |
190 | if (!strncmp(oem_id, "NUMASC", 6)) { | 170 | if ((strncmp(oem_id, "NUMASC", 6) != 0) || |
191 | numachip_system = 1; | 171 | (strncmp(oem_table_id, "NCONNECT", 8) != 0)) |
192 | return 1; | 172 | return 0; |
193 | } | ||
194 | 173 | ||
195 | return 0; | 174 | numachip_system = 1; |
196 | } | ||
197 | 175 | ||
198 | static const struct apic apic_numachip __refconst = { | 176 | return 1; |
177 | } | ||
199 | 178 | ||
179 | static const struct apic apic_numachip1 __refconst = { | ||
200 | .name = "NumaConnect system", | 180 | .name = "NumaConnect system", |
201 | .probe = numachip_probe, | 181 | .probe = numachip1_probe, |
202 | .acpi_madt_oem_check = numachip_acpi_madt_oem_check, | 182 | .acpi_madt_oem_check = numachip1_acpi_madt_oem_check, |
203 | .apic_id_valid = numachip_apic_id_valid, | 183 | .apic_id_valid = numachip_apic_id_valid, |
204 | .apic_id_registered = numachip_apic_id_registered, | 184 | .apic_id_registered = numachip_apic_id_registered, |
205 | 185 | ||
@@ -221,8 +201,8 @@ static const struct apic apic_numachip __refconst = { | |||
221 | .check_phys_apicid_present = default_check_phys_apicid_present, | 201 | .check_phys_apicid_present = default_check_phys_apicid_present, |
222 | .phys_pkg_id = numachip_phys_pkg_id, | 202 | .phys_pkg_id = numachip_phys_pkg_id, |
223 | 203 | ||
224 | .get_apic_id = get_apic_id, | 204 | .get_apic_id = numachip1_get_apic_id, |
225 | .set_apic_id = set_apic_id, | 205 | .set_apic_id = numachip1_set_apic_id, |
226 | .apic_id_mask = 0xffU << 24, | 206 | .apic_id_mask = 0xffU << 24, |
227 | 207 | ||
228 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, | 208 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, |
@@ -244,5 +224,5 @@ static const struct apic apic_numachip __refconst = { | |||
244 | .wait_icr_idle = native_apic_wait_icr_idle, | 224 | .wait_icr_idle = native_apic_wait_icr_idle, |
245 | .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, | 225 | .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, |
246 | }; | 226 | }; |
247 | apic_driver(apic_numachip); | ||
248 | 227 | ||
228 | apic_driver(apic_numachip1); | ||