Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004 James Cleverdon, IBM. |
| 3 | * Subject to the GNU Public License, v.2 |
| 4 | * |
Andi Kleen | f8d3119 | 2005-07-28 21:15:42 -0700 | [diff] [blame] | 5 | * Flat APIC subarch code. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * |
| 7 | * Hacked for x86-64 by James Cleverdon from i386 architecture code by |
| 8 | * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and |
| 9 | * James Cleverdon. |
| 10 | */ |
Andi Kleen | f19cccf | 2007-05-02 19:27:21 +0200 | [diff] [blame] | 11 | #include <linux/errno.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/threads.h> |
| 13 | #include <linux/cpumask.h> |
| 14 | #include <linux/string.h> |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/ctype.h> |
| 17 | #include <linux/init.h> |
Suresh Siddha | 0c81c74 | 2008-07-10 11:16:48 -0700 | [diff] [blame] | 18 | #include <linux/hardirq.h> |
Randy Dunlap | b18bf09 | 2011-05-23 10:43:00 -0700 | [diff] [blame] | 19 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <asm/smp.h> |
Ingo Molnar | 7b6aa33 | 2009-02-17 13:58:15 +0100 | [diff] [blame] | 21 | #include <asm/apic.h> |
Yinghai Lu | c1eeb2d | 2009-02-16 23:02:14 -0800 | [diff] [blame] | 22 | #include <asm/ipi.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | |
Lv Zheng | 8b48463 | 2013-12-03 08:49:16 +0800 | [diff] [blame^] | 24 | #include <linux/acpi.h> |
Yinghai Lu | 1b9b89e | 2008-07-21 22:08:21 -0700 | [diff] [blame] | 25 | |
Suresh Siddha | 1a8880a | 2011-05-20 17:51:20 -0700 | [diff] [blame] | 26 | static struct apic apic_physflat; |
| 27 | static struct apic apic_flat; |
| 28 | |
| 29 | struct apic __read_mostly *apic = &apic_flat; |
| 30 | EXPORT_SYMBOL_GPL(apic); |
| 31 | |
Marcin Slusarz | 983f91f | 2008-10-12 11:44:08 +0200 | [diff] [blame] | 32 | static int flat_acpi_madt_oem_check(char *oem_id, char *oem_table_id) |
Yinghai Lu | 1b9b89e | 2008-07-21 22:08:21 -0700 | [diff] [blame] | 33 | { |
| 34 | return 1; |
| 35 | } |
| 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | /* |
| 38 | * Set up the logical destination ID. |
| 39 | * |
| 40 | * Intel recommends to set DFR, LDR and TPR before enabling |
| 41 | * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel |
| 42 | * document number 292116). So here it goes... |
| 43 | */ |
Daniel J Blueman | 9a0ebfb | 2011-12-05 16:20:36 +0800 | [diff] [blame] | 44 | void flat_init_apic_ldr(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | { |
| 46 | unsigned long val; |
| 47 | unsigned long num, id; |
| 48 | |
| 49 | num = smp_processor_id(); |
| 50 | id = 1UL << num; |
Andi Kleen | eddfb4e | 2005-09-12 18:49:23 +0200 | [diff] [blame] | 51 | apic_write(APIC_DFR, APIC_DFR_FLAT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | val = apic_read(APIC_LDR) & ~APIC_LDR_MASK; |
| 53 | val |= SET_APIC_LOGICAL_ID(id); |
Andi Kleen | eddfb4e | 2005-09-12 18:49:23 +0200 | [diff] [blame] | 54 | apic_write(APIC_LDR, val); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | } |
| 56 | |
Mike Travis | e798673 | 2008-12-16 17:33:52 -0800 | [diff] [blame] | 57 | static inline void _flat_send_IPI_mask(unsigned long mask, int vector) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | unsigned long flags; |
| 60 | |
Fernando Luis Vázquez Cao | 2b94ab2 | 2006-09-26 10:52:33 +0200 | [diff] [blame] | 61 | local_irq_save(flags); |
Ingo Molnar | dac5f41 | 2009-01-28 15:42:24 +0100 | [diff] [blame] | 62 | __default_send_IPI_dest_field(mask, vector, apic->dest_logical); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | local_irq_restore(flags); |
| 64 | } |
| 65 | |
Mike Travis | bcda016 | 2008-12-16 17:33:59 -0800 | [diff] [blame] | 66 | static void flat_send_IPI_mask(const struct cpumask *cpumask, int vector) |
Mike Travis | e798673 | 2008-12-16 17:33:52 -0800 | [diff] [blame] | 67 | { |
Mike Travis | bcda016 | 2008-12-16 17:33:59 -0800 | [diff] [blame] | 68 | unsigned long mask = cpumask_bits(cpumask)[0]; |
Mike Travis | e798673 | 2008-12-16 17:33:52 -0800 | [diff] [blame] | 69 | |
| 70 | _flat_send_IPI_mask(mask, vector); |
| 71 | } |
| 72 | |
Ingo Molnar | dac5f41 | 2009-01-28 15:42:24 +0100 | [diff] [blame] | 73 | static void |
Alexander Gordeev | 49d0c7a | 2012-06-05 13:23:15 +0200 | [diff] [blame] | 74 | flat_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector) |
Mike Travis | e798673 | 2008-12-16 17:33:52 -0800 | [diff] [blame] | 75 | { |
Mike Travis | bcda016 | 2008-12-16 17:33:59 -0800 | [diff] [blame] | 76 | unsigned long mask = cpumask_bits(cpumask)[0]; |
Mike Travis | e798673 | 2008-12-16 17:33:52 -0800 | [diff] [blame] | 77 | int cpu = smp_processor_id(); |
| 78 | |
| 79 | if (cpu < BITS_PER_LONG) |
| 80 | clear_bit(cpu, &mask); |
Ingo Molnar | dac5f41 | 2009-01-28 15:42:24 +0100 | [diff] [blame] | 81 | |
Mike Travis | e798673 | 2008-12-16 17:33:52 -0800 | [diff] [blame] | 82 | _flat_send_IPI_mask(mask, vector); |
| 83 | } |
| 84 | |
Ashok Raj | 884d9e4 | 2005-06-25 14:55:02 -0700 | [diff] [blame] | 85 | static void flat_send_IPI_allbutself(int vector) |
| 86 | { |
Mike Travis | e798673 | 2008-12-16 17:33:52 -0800 | [diff] [blame] | 87 | int cpu = smp_processor_id(); |
Keith Owens | e77deac | 2006-06-26 13:59:56 +0200 | [diff] [blame] | 88 | #ifdef CONFIG_HOTPLUG_CPU |
| 89 | int hotplug = 1; |
Ashok Raj | fdf26d9 | 2005-09-09 13:01:52 -0700 | [diff] [blame] | 90 | #else |
Keith Owens | e77deac | 2006-06-26 13:59:56 +0200 | [diff] [blame] | 91 | int hotplug = 0; |
Ashok Raj | fdf26d9 | 2005-09-09 13:01:52 -0700 | [diff] [blame] | 92 | #endif |
Keith Owens | e77deac | 2006-06-26 13:59:56 +0200 | [diff] [blame] | 93 | if (hotplug || vector == NMI_VECTOR) { |
Mike Travis | bcda016 | 2008-12-16 17:33:59 -0800 | [diff] [blame] | 94 | if (!cpumask_equal(cpu_online_mask, cpumask_of(cpu))) { |
| 95 | unsigned long mask = cpumask_bits(cpu_online_mask)[0]; |
Keith Owens | e77deac | 2006-06-26 13:59:56 +0200 | [diff] [blame] | 96 | |
Mike Travis | e798673 | 2008-12-16 17:33:52 -0800 | [diff] [blame] | 97 | if (cpu < BITS_PER_LONG) |
| 98 | clear_bit(cpu, &mask); |
Keith Owens | e77deac | 2006-06-26 13:59:56 +0200 | [diff] [blame] | 99 | |
Mike Travis | e798673 | 2008-12-16 17:33:52 -0800 | [diff] [blame] | 100 | _flat_send_IPI_mask(mask, vector); |
| 101 | } |
Keith Owens | e77deac | 2006-06-26 13:59:56 +0200 | [diff] [blame] | 102 | } else if (num_online_cpus() > 1) { |
Ingo Molnar | dac5f41 | 2009-01-28 15:42:24 +0100 | [diff] [blame] | 103 | __default_send_IPI_shortcut(APIC_DEST_ALLBUT, |
| 104 | vector, apic->dest_logical); |
Keith Owens | e77deac | 2006-06-26 13:59:56 +0200 | [diff] [blame] | 105 | } |
Ashok Raj | 884d9e4 | 2005-06-25 14:55:02 -0700 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | static void flat_send_IPI_all(int vector) |
| 109 | { |
Ingo Molnar | dac5f41 | 2009-01-28 15:42:24 +0100 | [diff] [blame] | 110 | if (vector == NMI_VECTOR) { |
Mike Travis | bcda016 | 2008-12-16 17:33:59 -0800 | [diff] [blame] | 111 | flat_send_IPI_mask(cpu_online_mask, vector); |
Ingo Molnar | dac5f41 | 2009-01-28 15:42:24 +0100 | [diff] [blame] | 112 | } else { |
| 113 | __default_send_IPI_shortcut(APIC_DEST_ALLINC, |
| 114 | vector, apic->dest_logical); |
| 115 | } |
Ashok Raj | 884d9e4 | 2005-06-25 14:55:02 -0700 | [diff] [blame] | 116 | } |
| 117 | |
Ingo Molnar | ca6c8ed | 2009-01-28 14:08:38 +0100 | [diff] [blame] | 118 | static unsigned int flat_get_apic_id(unsigned long x) |
Yinghai Lu | f910a9d | 2008-07-12 01:01:20 -0700 | [diff] [blame] | 119 | { |
| 120 | unsigned int id; |
| 121 | |
| 122 | id = (((x)>>24) & 0xFFu); |
Ingo Molnar | ca6c8ed | 2009-01-28 14:08:38 +0100 | [diff] [blame] | 123 | |
Yinghai Lu | f910a9d | 2008-07-12 01:01:20 -0700 | [diff] [blame] | 124 | return id; |
| 125 | } |
| 126 | |
| 127 | static unsigned long set_apic_id(unsigned int id) |
| 128 | { |
| 129 | unsigned long x; |
| 130 | |
| 131 | x = ((id & 0xFFu)<<24); |
| 132 | return x; |
| 133 | } |
| 134 | |
Suresh Siddha | 0c81c74 | 2008-07-10 11:16:48 -0700 | [diff] [blame] | 135 | static unsigned int read_xapic_id(void) |
| 136 | { |
| 137 | unsigned int id; |
| 138 | |
Ingo Molnar | ca6c8ed | 2009-01-28 14:08:38 +0100 | [diff] [blame] | 139 | id = flat_get_apic_id(apic_read(APIC_ID)); |
Suresh Siddha | 0c81c74 | 2008-07-10 11:16:48 -0700 | [diff] [blame] | 140 | return id; |
| 141 | } |
| 142 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | static int flat_apic_id_registered(void) |
| 144 | { |
Suresh Siddha | 0c81c74 | 2008-07-10 11:16:48 -0700 | [diff] [blame] | 145 | return physid_isset(read_xapic_id(), phys_cpu_present_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | } |
| 147 | |
Ingo Molnar | d4c9a9f | 2009-01-28 13:31:22 +0100 | [diff] [blame] | 148 | static int flat_phys_pkg_id(int initial_apic_id, int index_msb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | { |
Yinghai Lu | 2759c32 | 2009-05-15 13:05:16 -0700 | [diff] [blame] | 150 | return initial_apic_id >> index_msb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Yinghai Lu | e8524b2 | 2011-12-21 17:45:15 -0800 | [diff] [blame] | 153 | static int flat_probe(void) |
| 154 | { |
| 155 | return 1; |
| 156 | } |
| 157 | |
Suresh Siddha | 1a8880a | 2011-05-20 17:51:20 -0700 | [diff] [blame] | 158 | static struct apic apic_flat = { |
Ingo Molnar | f2f05ee | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 159 | .name = "flat", |
Yinghai Lu | e8524b2 | 2011-12-21 17:45:15 -0800 | [diff] [blame] | 160 | .probe = flat_probe, |
Ingo Molnar | f2f05ee | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 161 | .acpi_madt_oem_check = flat_acpi_madt_oem_check, |
Daniel J Blueman | fa63030 | 2012-03-14 15:17:34 +0800 | [diff] [blame] | 162 | .apic_id_valid = default_apic_id_valid, |
Ingo Molnar | f2f05ee | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 163 | .apic_id_registered = flat_apic_id_registered, |
| 164 | |
Ingo Molnar | f8987a1 | 2009-01-28 04:02:31 +0100 | [diff] [blame] | 165 | .irq_delivery_mode = dest_LowestPrio, |
Ingo Molnar | 0b06e73 | 2009-01-28 05:13:04 +0100 | [diff] [blame] | 166 | .irq_dest_mode = 1, /* logical */ |
Ingo Molnar | f2f05ee | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 167 | |
Alexander Gordeev | bf721d3 | 2012-06-05 13:23:29 +0200 | [diff] [blame] | 168 | .target_cpus = online_target_cpus, |
Ingo Molnar | 08125d3 | 2009-01-28 05:08:44 +0100 | [diff] [blame] | 169 | .disable_esr = 0, |
Ingo Molnar | bdb1a9b | 2009-01-28 05:29:25 +0100 | [diff] [blame] | 170 | .dest_logical = APIC_DEST_LOGICAL, |
Ingo Molnar | f2f05ee | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 171 | .check_apicid_used = NULL, |
| 172 | .check_apicid_present = NULL, |
| 173 | |
Ingo Molnar | f2f05ee | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 174 | .vector_allocation_domain = flat_vector_allocation_domain, |
| 175 | .init_apic_ldr = flat_init_apic_ldr, |
| 176 | |
| 177 | .ioapic_phys_id_map = NULL, |
| 178 | .setup_apic_routing = NULL, |
| 179 | .multi_timer_check = NULL, |
Ingo Molnar | a21769a4 | 2009-01-28 06:50:47 +0100 | [diff] [blame] | 180 | .cpu_present_to_apicid = default_cpu_present_to_apicid, |
Ingo Molnar | f2f05ee | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 181 | .apicid_to_cpu_present = NULL, |
| 182 | .setup_portio_remap = NULL, |
Ingo Molnar | a27a621 | 2009-01-28 12:43:18 +0100 | [diff] [blame] | 183 | .check_phys_apicid_present = default_check_phys_apicid_present, |
Ingo Molnar | f2f05ee | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 184 | .enable_apic_mode = NULL, |
Ingo Molnar | d4c9a9f | 2009-01-28 13:31:22 +0100 | [diff] [blame] | 185 | .phys_pkg_id = flat_phys_pkg_id, |
Ingo Molnar | f2f05ee | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 186 | .mps_oem_check = NULL, |
| 187 | |
Ingo Molnar | ca6c8ed | 2009-01-28 14:08:38 +0100 | [diff] [blame] | 188 | .get_apic_id = flat_get_apic_id, |
Ingo Molnar | f2f05ee | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 189 | .set_apic_id = set_apic_id, |
| 190 | .apic_id_mask = 0xFFu << 24, |
| 191 | |
Alexander Gordeev | 6398268 | 2012-06-05 13:23:44 +0200 | [diff] [blame] | 192 | .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and, |
Ingo Molnar | f2f05ee | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 193 | |
| 194 | .send_IPI_mask = flat_send_IPI_mask, |
| 195 | .send_IPI_mask_allbutself = flat_send_IPI_mask_allbutself, |
| 196 | .send_IPI_allbutself = flat_send_IPI_allbutself, |
| 197 | .send_IPI_all = flat_send_IPI_all, |
| 198 | .send_IPI_self = apic_send_IPI_self, |
| 199 | |
Ingo Molnar | abfa584 | 2009-01-28 16:15:16 +0100 | [diff] [blame] | 200 | .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW, |
| 201 | .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH, |
Ingo Molnar | f2f05ee | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 202 | .wait_for_init_deassert = NULL, |
| 203 | .smp_callin_clear_local_apic = NULL, |
Yinghai Lu | 08d63b1 | 2009-04-08 08:00:01 -0700 | [diff] [blame] | 204 | .inquire_remote_apic = default_inquire_remote_apic, |
Yinghai Lu | c1eeb2d | 2009-02-16 23:02:14 -0800 | [diff] [blame] | 205 | |
| 206 | .read = native_apic_mem_read, |
| 207 | .write = native_apic_mem_write, |
Michael S. Tsirkin | 2a43195 | 2012-05-16 19:03:52 +0300 | [diff] [blame] | 208 | .eoi_write = native_apic_mem_write, |
Yinghai Lu | c1eeb2d | 2009-02-16 23:02:14 -0800 | [diff] [blame] | 209 | .icr_read = native_apic_icr_read, |
| 210 | .icr_write = native_apic_icr_write, |
| 211 | .wait_icr_idle = native_apic_wait_icr_idle, |
| 212 | .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | }; |
Andi Kleen | f8d3119 | 2005-07-28 21:15:42 -0700 | [diff] [blame] | 214 | |
| 215 | /* |
Jasper Spaans | e34b700 | 2009-11-20 14:20:05 +0100 | [diff] [blame] | 216 | * Physflat mode is used when there are more than 8 CPUs on a system. |
Andi Kleen | f8d3119 | 2005-07-28 21:15:42 -0700 | [diff] [blame] | 217 | * We cannot use logical delivery in this case because the mask |
| 218 | * overflows, so use physical mode. |
| 219 | */ |
Marcin Slusarz | fae17216 | 2008-10-12 11:44:09 +0200 | [diff] [blame] | 220 | static int physflat_acpi_madt_oem_check(char *oem_id, char *oem_table_id) |
Yinghai Lu | 1b9b89e | 2008-07-21 22:08:21 -0700 | [diff] [blame] | 221 | { |
| 222 | #ifdef CONFIG_ACPI |
| 223 | /* |
| 224 | * Quirk: some x86_64 machines can only use physical APIC mode |
| 225 | * regardless of how many processors are present (x86_64 ES7000 |
| 226 | * is an example). |
| 227 | */ |
Yinghai Lu | 61fe91e | 2009-05-09 23:47:42 -0700 | [diff] [blame] | 228 | if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID && |
Yinghai Lu | 02c1df1 | 2008-09-04 20:57:11 +0200 | [diff] [blame] | 229 | (acpi_gbl_FADT.flags & ACPI_FADT_APIC_PHYSICAL)) { |
| 230 | printk(KERN_DEBUG "system APIC only can use physical flat"); |
Yinghai Lu | 1b9b89e | 2008-07-21 22:08:21 -0700 | [diff] [blame] | 231 | return 1; |
Yinghai Lu | 02c1df1 | 2008-09-04 20:57:11 +0200 | [diff] [blame] | 232 | } |
Suresh Siddha | dfea91d | 2010-01-18 12:10:48 -0800 | [diff] [blame] | 233 | |
| 234 | if (!strncmp(oem_id, "IBM", 3) && !strncmp(oem_table_id, "EXA", 3)) { |
| 235 | printk(KERN_DEBUG "IBM Summit detected, will use apic physical"); |
| 236 | return 1; |
| 237 | } |
Yinghai Lu | 1b9b89e | 2008-07-21 22:08:21 -0700 | [diff] [blame] | 238 | #endif |
| 239 | |
| 240 | return 0; |
| 241 | } |
Andi Kleen | f8d3119 | 2005-07-28 21:15:42 -0700 | [diff] [blame] | 242 | |
Mike Travis | bcda016 | 2008-12-16 17:33:59 -0800 | [diff] [blame] | 243 | static void physflat_send_IPI_mask(const struct cpumask *cpumask, int vector) |
Andi Kleen | f8d3119 | 2005-07-28 21:15:42 -0700 | [diff] [blame] | 244 | { |
Yinghai Lu | 43f3989 | 2009-01-29 19:31:49 -0800 | [diff] [blame] | 245 | default_send_IPI_mask_sequence_phys(cpumask, vector); |
Andi Kleen | f8d3119 | 2005-07-28 21:15:42 -0700 | [diff] [blame] | 246 | } |
| 247 | |
Mike Travis | bcda016 | 2008-12-16 17:33:59 -0800 | [diff] [blame] | 248 | static void physflat_send_IPI_mask_allbutself(const struct cpumask *cpumask, |
Mike Travis | e798673 | 2008-12-16 17:33:52 -0800 | [diff] [blame] | 249 | int vector) |
| 250 | { |
Yinghai Lu | 43f3989 | 2009-01-29 19:31:49 -0800 | [diff] [blame] | 251 | default_send_IPI_mask_allbutself_phys(cpumask, vector); |
Mike Travis | e798673 | 2008-12-16 17:33:52 -0800 | [diff] [blame] | 252 | } |
| 253 | |
Andi Kleen | f8d3119 | 2005-07-28 21:15:42 -0700 | [diff] [blame] | 254 | static void physflat_send_IPI_allbutself(int vector) |
| 255 | { |
Yinghai Lu | 43f3989 | 2009-01-29 19:31:49 -0800 | [diff] [blame] | 256 | default_send_IPI_mask_allbutself_phys(cpu_online_mask, vector); |
Andi Kleen | f8d3119 | 2005-07-28 21:15:42 -0700 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | static void physflat_send_IPI_all(int vector) |
| 260 | { |
Mike Travis | bcda016 | 2008-12-16 17:33:59 -0800 | [diff] [blame] | 261 | physflat_send_IPI_mask(cpu_online_mask, vector); |
Andi Kleen | f8d3119 | 2005-07-28 21:15:42 -0700 | [diff] [blame] | 262 | } |
| 263 | |
Suresh Siddha | 9ebd680 | 2011-05-19 16:45:46 -0700 | [diff] [blame] | 264 | static int physflat_probe(void) |
| 265 | { |
| 266 | if (apic == &apic_physflat || num_possible_cpus() > 8) |
| 267 | return 1; |
| 268 | |
| 269 | return 0; |
| 270 | } |
| 271 | |
Suresh Siddha | 1a8880a | 2011-05-20 17:51:20 -0700 | [diff] [blame] | 272 | static struct apic apic_physflat = { |
Ingo Molnar | 4c3e51e | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 273 | |
| 274 | .name = "physical flat", |
Suresh Siddha | 9ebd680 | 2011-05-19 16:45:46 -0700 | [diff] [blame] | 275 | .probe = physflat_probe, |
Ingo Molnar | 4c3e51e | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 276 | .acpi_madt_oem_check = physflat_acpi_madt_oem_check, |
Daniel J Blueman | fa63030 | 2012-03-14 15:17:34 +0800 | [diff] [blame] | 277 | .apic_id_valid = default_apic_id_valid, |
Ingo Molnar | 4c3e51e | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 278 | .apic_id_registered = flat_apic_id_registered, |
| 279 | |
Ingo Molnar | f8987a1 | 2009-01-28 04:02:31 +0100 | [diff] [blame] | 280 | .irq_delivery_mode = dest_Fixed, |
Ingo Molnar | 0b06e73 | 2009-01-28 05:13:04 +0100 | [diff] [blame] | 281 | .irq_dest_mode = 0, /* physical */ |
Ingo Molnar | 4c3e51e | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 282 | |
Alexander Gordeev | bf721d3 | 2012-06-05 13:23:29 +0200 | [diff] [blame] | 283 | .target_cpus = online_target_cpus, |
Ingo Molnar | 08125d3 | 2009-01-28 05:08:44 +0100 | [diff] [blame] | 284 | .disable_esr = 0, |
Ingo Molnar | bdb1a9b | 2009-01-28 05:29:25 +0100 | [diff] [blame] | 285 | .dest_logical = 0, |
Ingo Molnar | 4c3e51e | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 286 | .check_apicid_used = NULL, |
| 287 | .check_apicid_present = NULL, |
| 288 | |
Alexander Gordeev | 9d8e106 | 2012-06-07 15:14:49 +0200 | [diff] [blame] | 289 | .vector_allocation_domain = default_vector_allocation_domain, |
Ingo Molnar | 4c3e51e | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 290 | /* not needed, but shouldn't hurt: */ |
| 291 | .init_apic_ldr = flat_init_apic_ldr, |
| 292 | |
| 293 | .ioapic_phys_id_map = NULL, |
| 294 | .setup_apic_routing = NULL, |
| 295 | .multi_timer_check = NULL, |
Ingo Molnar | a21769a4 | 2009-01-28 06:50:47 +0100 | [diff] [blame] | 296 | .cpu_present_to_apicid = default_cpu_present_to_apicid, |
Ingo Molnar | 4c3e51e | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 297 | .apicid_to_cpu_present = NULL, |
| 298 | .setup_portio_remap = NULL, |
Ingo Molnar | a27a621 | 2009-01-28 12:43:18 +0100 | [diff] [blame] | 299 | .check_phys_apicid_present = default_check_phys_apicid_present, |
Ingo Molnar | 4c3e51e | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 300 | .enable_apic_mode = NULL, |
Ingo Molnar | d4c9a9f | 2009-01-28 13:31:22 +0100 | [diff] [blame] | 301 | .phys_pkg_id = flat_phys_pkg_id, |
Ingo Molnar | 4c3e51e | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 302 | .mps_oem_check = NULL, |
| 303 | |
Ingo Molnar | ca6c8ed | 2009-01-28 14:08:38 +0100 | [diff] [blame] | 304 | .get_apic_id = flat_get_apic_id, |
Ingo Molnar | 4c3e51e | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 305 | .set_apic_id = set_apic_id, |
Ingo Molnar | 5b81272 | 2009-01-28 14:59:17 +0100 | [diff] [blame] | 306 | .apic_id_mask = 0xFFu << 24, |
Ingo Molnar | 4c3e51e | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 307 | |
Alexander Gordeev | 6398268 | 2012-06-05 13:23:44 +0200 | [diff] [blame] | 308 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, |
Ingo Molnar | 4c3e51e | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 309 | |
| 310 | .send_IPI_mask = physflat_send_IPI_mask, |
| 311 | .send_IPI_mask_allbutself = physflat_send_IPI_mask_allbutself, |
| 312 | .send_IPI_allbutself = physflat_send_IPI_allbutself, |
| 313 | .send_IPI_all = physflat_send_IPI_all, |
| 314 | .send_IPI_self = apic_send_IPI_self, |
| 315 | |
Ingo Molnar | abfa584 | 2009-01-28 16:15:16 +0100 | [diff] [blame] | 316 | .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW, |
| 317 | .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH, |
Ingo Molnar | 4c3e51e | 2009-01-28 02:37:01 +0100 | [diff] [blame] | 318 | .wait_for_init_deassert = NULL, |
| 319 | .smp_callin_clear_local_apic = NULL, |
Yinghai Lu | 08d63b1 | 2009-04-08 08:00:01 -0700 | [diff] [blame] | 320 | .inquire_remote_apic = default_inquire_remote_apic, |
Yinghai Lu | c1eeb2d | 2009-02-16 23:02:14 -0800 | [diff] [blame] | 321 | |
| 322 | .read = native_apic_mem_read, |
| 323 | .write = native_apic_mem_write, |
Michael S. Tsirkin | 2a43195 | 2012-05-16 19:03:52 +0300 | [diff] [blame] | 324 | .eoi_write = native_apic_mem_write, |
Yinghai Lu | c1eeb2d | 2009-02-16 23:02:14 -0800 | [diff] [blame] | 325 | .icr_read = native_apic_icr_read, |
| 326 | .icr_write = native_apic_icr_write, |
| 327 | .wait_icr_idle = native_apic_wait_icr_idle, |
| 328 | .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, |
Andi Kleen | f8d3119 | 2005-07-28 21:15:42 -0700 | [diff] [blame] | 329 | }; |
Suresh Siddha | 107e0e0 | 2011-05-20 17:51:17 -0700 | [diff] [blame] | 330 | |
| 331 | /* |
| 332 | * We need to check for physflat first, so this order is important. |
| 333 | */ |
| 334 | apic_drivers(apic_physflat, apic_flat); |