Commit | Line | Data |
---|---|---|
2d9579a1 SS |
1 | #include <linux/threads.h> |
2 | #include <linux/cpumask.h> | |
3 | #include <linux/string.h> | |
4 | #include <linux/kernel.h> | |
5 | #include <linux/ctype.h> | |
6 | #include <linux/init.h> | |
1b9b89e7 YL |
7 | #include <linux/dmar.h> |
8 | ||
2d9579a1 | 9 | #include <asm/smp.h> |
79deb8e5 | 10 | #include <asm/x2apic.h> |
2d9579a1 | 11 | |
ef1f87aa | 12 | int x2apic_phys; |
1b9b89e7 | 13 | |
1a8880a1 SS |
14 | static struct apic apic_x2apic_phys; |
15 | ||
1b9b89e7 YL |
16 | static int set_x2apic_phys_mode(char *arg) |
17 | { | |
18 | x2apic_phys = 1; | |
19 | return 0; | |
20 | } | |
21 | early_param("x2apic_phys", set_x2apic_phys_mode); | |
22 | ||
3cfba089 | 23 | static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id) |
1b9b89e7 | 24 | { |
ef1f87aa SS |
25 | if (x2apic_phys) |
26 | return x2apic_enabled(); | |
ea0dcf90 GP |
27 | else if ((acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) && |
28 | (acpi_gbl_FADT.flags & ACPI_FADT_APIC_PHYSICAL) && | |
29 | x2apic_enabled()) { | |
30 | printk(KERN_DEBUG "System requires x2apic physical mode\n"); | |
31 | return 1; | |
32 | } | |
ef1f87aa SS |
33 | else |
34 | return 0; | |
1b9b89e7 | 35 | } |
2d9579a1 | 36 | |
a27d0b5e SS |
37 | static void |
38 | __x2apic_send_IPI_mask(const struct cpumask *mask, int vector, int apic_dest) | |
2d9579a1 | 39 | { |
2d9579a1 | 40 | unsigned long query_cpu; |
a27d0b5e | 41 | unsigned long this_cpu; |
dac5f412 | 42 | unsigned long flags; |
2d9579a1 | 43 | |
ce4e240c SS |
44 | x2apic_wrmsr_fence(); |
45 | ||
2d9579a1 | 46 | local_irq_save(flags); |
a27d0b5e SS |
47 | |
48 | this_cpu = smp_processor_id(); | |
bcda016e | 49 | for_each_cpu(query_cpu, mask) { |
a27d0b5e SS |
50 | if (apic_dest == APIC_DEST_ALLBUT && this_cpu == query_cpu) |
51 | continue; | |
2d9579a1 SS |
52 | __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu), |
53 | vector, APIC_DEST_PHYSICAL); | |
54 | } | |
55 | local_irq_restore(flags); | |
56 | } | |
57 | ||
a27d0b5e SS |
58 | static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector) |
59 | { | |
60 | __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLINC); | |
61 | } | |
62 | ||
dac5f412 IM |
63 | static void |
64 | x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector) | |
2d9579a1 | 65 | { |
a27d0b5e | 66 | __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLBUT); |
e7986739 | 67 | } |
2d9579a1 | 68 | |
e7986739 MT |
69 | static void x2apic_send_IPI_allbutself(int vector) |
70 | { | |
a27d0b5e | 71 | __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLBUT); |
2d9579a1 SS |
72 | } |
73 | ||
74 | static void x2apic_send_IPI_all(int vector) | |
75 | { | |
a27d0b5e | 76 | __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC); |
2d9579a1 SS |
77 | } |
78 | ||
4d08d97f | 79 | static void init_x2apic_ldr(void) |
2d9579a1 | 80 | { |
2d9579a1 SS |
81 | } |
82 | ||
9ebd680b SS |
83 | static int x2apic_phys_probe(void) |
84 | { | |
85 | if (x2apic_mode && x2apic_phys) | |
86 | return 1; | |
87 | ||
88 | return apic == &apic_x2apic_phys; | |
89 | } | |
90 | ||
1a8880a1 | 91 | static struct apic apic_x2apic_phys = { |
05c155c2 IM |
92 | |
93 | .name = "physical x2apic", | |
9ebd680b | 94 | .probe = x2apic_phys_probe, |
05c155c2 | 95 | .acpi_madt_oem_check = x2apic_acpi_madt_oem_check, |
b7157acf | 96 | .apic_id_valid = x2apic_apic_id_valid, |
05c155c2 IM |
97 | .apic_id_registered = x2apic_apic_id_registered, |
98 | ||
f8987a10 | 99 | .irq_delivery_mode = dest_Fixed, |
0b06e734 | 100 | .irq_dest_mode = 0, /* physical */ |
05c155c2 | 101 | |
bf721d3a | 102 | .target_cpus = online_target_cpus, |
08125d3e | 103 | .disable_esr = 0, |
bdb1a9b6 | 104 | .dest_logical = 0, |
05c155c2 IM |
105 | .check_apicid_used = NULL, |
106 | .check_apicid_present = NULL, | |
107 | ||
9d8e1066 | 108 | .vector_allocation_domain = default_vector_allocation_domain, |
05c155c2 IM |
109 | .init_apic_ldr = init_x2apic_ldr, |
110 | ||
111 | .ioapic_phys_id_map = NULL, | |
112 | .setup_apic_routing = NULL, | |
113 | .multi_timer_check = NULL, | |
a21769a4 | 114 | .cpu_present_to_apicid = default_cpu_present_to_apicid, |
05c155c2 IM |
115 | .apicid_to_cpu_present = NULL, |
116 | .setup_portio_remap = NULL, | |
a27a6210 | 117 | .check_phys_apicid_present = default_check_phys_apicid_present, |
05c155c2 | 118 | .enable_apic_mode = NULL, |
d4c9a9f3 | 119 | .phys_pkg_id = x2apic_phys_pkg_id, |
05c155c2 IM |
120 | .mps_oem_check = NULL, |
121 | ||
79deb8e5 CG |
122 | .get_apic_id = x2apic_get_apic_id, |
123 | .set_apic_id = x2apic_set_apic_id, | |
05c155c2 IM |
124 | .apic_id_mask = 0xFFFFFFFFu, |
125 | ||
6398268d | 126 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, |
05c155c2 IM |
127 | |
128 | .send_IPI_mask = x2apic_send_IPI_mask, | |
129 | .send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself, | |
130 | .send_IPI_allbutself = x2apic_send_IPI_allbutself, | |
131 | .send_IPI_all = x2apic_send_IPI_all, | |
132 | .send_IPI_self = x2apic_send_IPI_self, | |
133 | ||
abfa584c IM |
134 | .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW, |
135 | .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH, | |
05c155c2 IM |
136 | .wait_for_init_deassert = NULL, |
137 | .smp_callin_clear_local_apic = NULL, | |
05c155c2 | 138 | .inquire_remote_apic = NULL, |
c1eeb2de YL |
139 | |
140 | .read = native_apic_msr_read, | |
141 | .write = native_apic_msr_write, | |
0ab711ae | 142 | .eoi_write = native_apic_msr_eoi_write, |
c1eeb2de YL |
143 | .icr_read = native_x2apic_icr_read, |
144 | .icr_write = native_x2apic_icr_write, | |
145 | .wait_icr_idle = native_x2apic_wait_icr_idle, | |
146 | .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle, | |
2d9579a1 | 147 | }; |
107e0e0c SS |
148 | |
149 | apic_driver(apic_x2apic_phys); |