diff options
Diffstat (limited to 'arch/x86/kernel/apic/x2apic_phys.c')
-rw-r--r-- | arch/x86/kernel/apic/x2apic_phys.c | 117 |
1 files changed, 29 insertions, 88 deletions
diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c index 8972f38c5ced..f5373dfde21e 100644 --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c | |||
@@ -7,11 +7,12 @@ | |||
7 | #include <linux/dmar.h> | 7 | #include <linux/dmar.h> |
8 | 8 | ||
9 | #include <asm/smp.h> | 9 | #include <asm/smp.h> |
10 | #include <asm/apic.h> | 10 | #include <asm/x2apic.h> |
11 | #include <asm/ipi.h> | ||
12 | 11 | ||
13 | int x2apic_phys; | 12 | int x2apic_phys; |
14 | 13 | ||
14 | static struct apic apic_x2apic_phys; | ||
15 | |||
15 | static int set_x2apic_phys_mode(char *arg) | 16 | static int set_x2apic_phys_mode(char *arg) |
16 | { | 17 | { |
17 | x2apic_phys = 1; | 18 | x2apic_phys = 1; |
@@ -27,94 +28,46 @@ static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id) | |||
27 | return 0; | 28 | return 0; |
28 | } | 29 | } |
29 | 30 | ||
30 | /* | 31 | static void |
31 | * need to use more than cpu 0, because we need more vectors when | 32 | __x2apic_send_IPI_mask(const struct cpumask *mask, int vector, int apic_dest) |
32 | * MSI-X are used. | ||
33 | */ | ||
34 | static const struct cpumask *x2apic_target_cpus(void) | ||
35 | { | ||
36 | return cpu_online_mask; | ||
37 | } | ||
38 | |||
39 | static void x2apic_vector_allocation_domain(int cpu, struct cpumask *retmask) | ||
40 | { | ||
41 | cpumask_clear(retmask); | ||
42 | cpumask_set_cpu(cpu, retmask); | ||
43 | } | ||
44 | |||
45 | static void __x2apic_send_IPI_dest(unsigned int apicid, int vector, | ||
46 | unsigned int dest) | ||
47 | { | ||
48 | unsigned long cfg; | ||
49 | |||
50 | cfg = __prepare_ICR(0, vector, dest); | ||
51 | |||
52 | /* | ||
53 | * send the IPI. | ||
54 | */ | ||
55 | native_x2apic_icr_write(cfg, apicid); | ||
56 | } | ||
57 | |||
58 | static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector) | ||
59 | { | 33 | { |
60 | unsigned long query_cpu; | 34 | unsigned long query_cpu; |
35 | unsigned long this_cpu; | ||
61 | unsigned long flags; | 36 | unsigned long flags; |
62 | 37 | ||
63 | x2apic_wrmsr_fence(); | 38 | x2apic_wrmsr_fence(); |
64 | 39 | ||
65 | local_irq_save(flags); | 40 | local_irq_save(flags); |
41 | |||
42 | this_cpu = smp_processor_id(); | ||
66 | for_each_cpu(query_cpu, mask) { | 43 | for_each_cpu(query_cpu, mask) { |
44 | if (apic_dest == APIC_DEST_ALLBUT && this_cpu == query_cpu) | ||
45 | continue; | ||
67 | __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu), | 46 | __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu), |
68 | vector, APIC_DEST_PHYSICAL); | 47 | vector, APIC_DEST_PHYSICAL); |
69 | } | 48 | } |
70 | local_irq_restore(flags); | 49 | local_irq_restore(flags); |
71 | } | 50 | } |
72 | 51 | ||
52 | static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector) | ||
53 | { | ||
54 | __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLINC); | ||
55 | } | ||
56 | |||
73 | static void | 57 | static void |
74 | x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector) | 58 | x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector) |
75 | { | 59 | { |
76 | unsigned long this_cpu = smp_processor_id(); | 60 | __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLBUT); |
77 | unsigned long query_cpu; | ||
78 | unsigned long flags; | ||
79 | |||
80 | x2apic_wrmsr_fence(); | ||
81 | |||
82 | local_irq_save(flags); | ||
83 | for_each_cpu(query_cpu, mask) { | ||
84 | if (query_cpu != this_cpu) | ||
85 | __x2apic_send_IPI_dest( | ||
86 | per_cpu(x86_cpu_to_apicid, query_cpu), | ||
87 | vector, APIC_DEST_PHYSICAL); | ||
88 | } | ||
89 | local_irq_restore(flags); | ||
90 | } | 61 | } |
91 | 62 | ||
92 | static void x2apic_send_IPI_allbutself(int vector) | 63 | static void x2apic_send_IPI_allbutself(int vector) |
93 | { | 64 | { |
94 | unsigned long this_cpu = smp_processor_id(); | 65 | __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLBUT); |
95 | unsigned long query_cpu; | ||
96 | unsigned long flags; | ||
97 | |||
98 | x2apic_wrmsr_fence(); | ||
99 | |||
100 | local_irq_save(flags); | ||
101 | for_each_online_cpu(query_cpu) { | ||
102 | if (query_cpu == this_cpu) | ||
103 | continue; | ||
104 | __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu), | ||
105 | vector, APIC_DEST_PHYSICAL); | ||
106 | } | ||
107 | local_irq_restore(flags); | ||
108 | } | 66 | } |
109 | 67 | ||
110 | static void x2apic_send_IPI_all(int vector) | 68 | static void x2apic_send_IPI_all(int vector) |
111 | { | 69 | { |
112 | x2apic_send_IPI_mask(cpu_online_mask, vector); | 70 | __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC); |
113 | } | ||
114 | |||
115 | static int x2apic_apic_id_registered(void) | ||
116 | { | ||
117 | return 1; | ||
118 | } | 71 | } |
119 | 72 | ||
120 | static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask) | 73 | static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask) |
@@ -149,34 +102,22 @@ x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | |||
149 | return per_cpu(x86_cpu_to_apicid, cpu); | 102 | return per_cpu(x86_cpu_to_apicid, cpu); |
150 | } | 103 | } |
151 | 104 | ||
152 | static unsigned int x2apic_phys_get_apic_id(unsigned long x) | 105 | static void init_x2apic_ldr(void) |
153 | { | ||
154 | return x; | ||
155 | } | ||
156 | |||
157 | static unsigned long set_apic_id(unsigned int id) | ||
158 | { | ||
159 | return id; | ||
160 | } | ||
161 | |||
162 | static int x2apic_phys_pkg_id(int initial_apicid, int index_msb) | ||
163 | { | 106 | { |
164 | return initial_apicid >> index_msb; | ||
165 | } | 107 | } |
166 | 108 | ||
167 | static void x2apic_send_IPI_self(int vector) | 109 | static int x2apic_phys_probe(void) |
168 | { | 110 | { |
169 | apic_write(APIC_SELF_IPI, vector); | 111 | if (x2apic_mode && x2apic_phys) |
170 | } | 112 | return 1; |
171 | 113 | ||
172 | static void init_x2apic_ldr(void) | 114 | return apic == &apic_x2apic_phys; |
173 | { | ||
174 | } | 115 | } |
175 | 116 | ||
176 | struct apic apic_x2apic_phys = { | 117 | static struct apic apic_x2apic_phys = { |
177 | 118 | ||
178 | .name = "physical x2apic", | 119 | .name = "physical x2apic", |
179 | .probe = NULL, | 120 | .probe = x2apic_phys_probe, |
180 | .acpi_madt_oem_check = x2apic_acpi_madt_oem_check, | 121 | .acpi_madt_oem_check = x2apic_acpi_madt_oem_check, |
181 | .apic_id_registered = x2apic_apic_id_registered, | 122 | .apic_id_registered = x2apic_apic_id_registered, |
182 | 123 | ||
@@ -195,8 +136,6 @@ struct apic apic_x2apic_phys = { | |||
195 | .ioapic_phys_id_map = NULL, | 136 | .ioapic_phys_id_map = NULL, |
196 | .setup_apic_routing = NULL, | 137 | .setup_apic_routing = NULL, |
197 | .multi_timer_check = NULL, | 138 | .multi_timer_check = NULL, |
198 | .apicid_to_node = NULL, | ||
199 | .cpu_to_logical_apicid = NULL, | ||
200 | .cpu_present_to_apicid = default_cpu_present_to_apicid, | 139 | .cpu_present_to_apicid = default_cpu_present_to_apicid, |
201 | .apicid_to_cpu_present = NULL, | 140 | .apicid_to_cpu_present = NULL, |
202 | .setup_portio_remap = NULL, | 141 | .setup_portio_remap = NULL, |
@@ -205,8 +144,8 @@ struct apic apic_x2apic_phys = { | |||
205 | .phys_pkg_id = x2apic_phys_pkg_id, | 144 | .phys_pkg_id = x2apic_phys_pkg_id, |
206 | .mps_oem_check = NULL, | 145 | .mps_oem_check = NULL, |
207 | 146 | ||
208 | .get_apic_id = x2apic_phys_get_apic_id, | 147 | .get_apic_id = x2apic_get_apic_id, |
209 | .set_apic_id = set_apic_id, | 148 | .set_apic_id = x2apic_set_apic_id, |
210 | .apic_id_mask = 0xFFFFFFFFu, | 149 | .apic_id_mask = 0xFFFFFFFFu, |
211 | 150 | ||
212 | .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, | 151 | .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, |
@@ -231,3 +170,5 @@ struct apic apic_x2apic_phys = { | |||
231 | .wait_icr_idle = native_x2apic_wait_icr_idle, | 170 | .wait_icr_idle = native_x2apic_wait_icr_idle, |
232 | .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle, | 171 | .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle, |
233 | }; | 172 | }; |
173 | |||
174 | apic_driver(apic_x2apic_phys); | ||