Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 2 | * Intel Multiprocessor Specification 1.1 and 1.4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * compliant MP-table parsing routines. |
| 4 | * |
| 5 | * (c) 1995 Alan Cox, Building #3 <alan@redhat.com> |
| 6 | * (c) 1998, 1999, 2000 Ingo Molnar <mingo@redhat.com> |
Alexey Starikovskiy | 85bddde | 2008-04-04 23:43:18 +0400 | [diff] [blame] | 7 | * (c) 2008 Alexey Starikovskiy <astarikovskiy@suse.de> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <linux/mm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/init.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/delay.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/bootmem.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/kernel_stat.h> |
| 15 | #include <linux/mc146818rtc.h> |
| 16 | #include <linux/bitops.h> |
Alexey Starikovskiy | 85bddde | 2008-04-04 23:43:18 +0400 | [diff] [blame] | 17 | #include <linux/acpi.h> |
| 18 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | #include <asm/smp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <asm/mtrr.h> |
| 22 | #include <asm/mpspec.h> |
Alexey Starikovskiy | 85bddde | 2008-04-04 23:43:18 +0400 | [diff] [blame] | 23 | #include <asm/pgalloc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include <asm/io_apic.h> |
Alexey Starikovskiy | 85bddde | 2008-04-04 23:43:18 +0400 | [diff] [blame] | 25 | #include <asm/proto.h> |
| 26 | #include <asm/acpi.h> |
Alexey Starikovskiy | ce3fe6b | 2008-03-17 22:08:17 +0300 | [diff] [blame] | 27 | #include <asm/bios_ebda.h> |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 28 | #include <asm/e820.h> |
| 29 | #include <asm/trampoline.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
| 31 | #include <mach_apic.h> |
Alexey Starikovskiy | 85bddde | 2008-04-04 23:43:18 +0400 | [diff] [blame] | 32 | #ifdef CONFIG_X86_32 |
Andi Kleen | 874c4fe | 2006-09-26 10:52:26 +0200 | [diff] [blame] | 33 | #include <mach_apicdef.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include <mach_mpparse.h> |
Alexey Starikovskiy | 85bddde | 2008-04-04 23:43:18 +0400 | [diff] [blame] | 35 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | * Checksum an MP configuration block. |
| 39 | */ |
| 40 | |
| 41 | static int __init mpf_checksum(unsigned char *mp, int len) |
| 42 | { |
| 43 | int sum = 0; |
| 44 | |
| 45 | while (len--) |
| 46 | sum += *mp++; |
| 47 | |
| 48 | return sum & 0xFF; |
| 49 | } |
| 50 | |
Alexey Starikovskiy | 8642050 | 2008-03-17 22:08:55 +0300 | [diff] [blame] | 51 | #ifdef CONFIG_X86_NUMAQ |
Yinghai Lu | d49c428 | 2008-06-08 18:31:54 -0700 | [diff] [blame] | 52 | int found_numaq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | /* |
| 54 | * Have to match translation table entries to main table entries by counter |
| 55 | * hence the mpc_record variable .... can't see a less disgusting way of |
| 56 | * doing this .... |
| 57 | */ |
Yinghai Lu | d49c428 | 2008-06-08 18:31:54 -0700 | [diff] [blame] | 58 | struct mpc_config_translation { |
| 59 | unsigned char mpc_type; |
| 60 | unsigned char trans_len; |
| 61 | unsigned char trans_type; |
| 62 | unsigned char trans_quad; |
| 63 | unsigned char trans_global; |
| 64 | unsigned char trans_local; |
| 65 | unsigned short trans_reserved; |
| 66 | }; |
| 67 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 69 | static int mpc_record; |
| 70 | static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY] |
| 71 | __cpuinitdata; |
Yinghai Lu | d49c428 | 2008-06-08 18:31:54 -0700 | [diff] [blame] | 72 | |
| 73 | static inline int generate_logical_apicid(int quad, int phys_apicid) |
| 74 | { |
| 75 | return (quad << 4) + (phys_apicid ? phys_apicid << 1 : 1); |
| 76 | } |
| 77 | |
| 78 | |
| 79 | static inline int mpc_apic_id(struct mpc_config_processor *m, |
| 80 | struct mpc_config_translation *translation_record) |
| 81 | { |
| 82 | int quad = translation_record->trans_quad; |
| 83 | int logical_apicid = generate_logical_apicid(quad, m->mpc_apicid); |
| 84 | |
| 85 | printk(KERN_DEBUG "Processor #%d %u:%u APIC version %d (quad %d, apic %d)\n", |
| 86 | m->mpc_apicid, |
| 87 | (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, |
| 88 | (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4, |
| 89 | m->mpc_apicver, quad, logical_apicid); |
| 90 | return logical_apicid; |
| 91 | } |
| 92 | |
| 93 | int mp_bus_id_to_node[MAX_MP_BUSSES]; |
| 94 | |
| 95 | int mp_bus_id_to_local[MAX_MP_BUSSES]; |
| 96 | |
| 97 | static void mpc_oem_bus_info(struct mpc_config_bus *m, char *name, |
| 98 | struct mpc_config_translation *translation) |
| 99 | { |
| 100 | int quad = translation->trans_quad; |
| 101 | int local = translation->trans_local; |
| 102 | |
| 103 | mp_bus_id_to_node[m->mpc_busid] = quad; |
| 104 | mp_bus_id_to_local[m->mpc_busid] = local; |
| 105 | printk(KERN_INFO "Bus #%d is %s (node %d)\n", |
| 106 | m->mpc_busid, name, quad); |
| 107 | } |
| 108 | |
| 109 | int quad_local_to_mp_bus_id [NR_CPUS/4][4]; |
| 110 | static void mpc_oem_pci_bus(struct mpc_config_bus *m, |
| 111 | struct mpc_config_translation *translation) |
| 112 | { |
| 113 | int quad = translation->trans_quad; |
| 114 | int local = translation->trans_local; |
| 115 | |
| 116 | quad_local_to_mp_bus_id[quad][local] = m->mpc_busid; |
| 117 | } |
| 118 | |
Alexey Starikovskiy | 8642050 | 2008-03-17 22:08:55 +0300 | [diff] [blame] | 119 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
Alexey Starikovskiy | c853c67 | 2008-03-27 23:54:13 +0300 | [diff] [blame] | 121 | static void __cpuinit MP_processor_info(struct mpc_config_processor *m) |
| 122 | { |
| 123 | int apicid; |
Alexey Starikovskiy | 746f224 | 2008-04-04 23:42:15 +0400 | [diff] [blame] | 124 | char *bootup_cpu = ""; |
Alexey Starikovskiy | c853c67 | 2008-03-27 23:54:13 +0300 | [diff] [blame] | 125 | |
Glauber Costa | 7b1292e | 2008-03-03 14:12:41 -0300 | [diff] [blame] | 126 | if (!(m->mpc_cpuflag & CPU_ENABLED)) { |
| 127 | disabled_cpus++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | return; |
Glauber Costa | 7b1292e | 2008-03-03 14:12:41 -0300 | [diff] [blame] | 129 | } |
Alexey Starikovskiy | 4655c7d | 2008-03-17 22:08:36 +0300 | [diff] [blame] | 130 | #ifdef CONFIG_X86_NUMAQ |
Yinghai Lu | ab530e1 | 2008-06-03 10:25:54 -0700 | [diff] [blame] | 131 | if (found_numaq) |
| 132 | apicid = mpc_apic_id(m, translation_table[mpc_record]); |
| 133 | else |
| 134 | apicid = m->mpc_apicid; |
Alexey Starikovskiy | 4655c7d | 2008-03-17 22:08:36 +0300 | [diff] [blame] | 135 | #else |
Alexey Starikovskiy | 4655c7d | 2008-03-17 22:08:36 +0300 | [diff] [blame] | 136 | apicid = m->mpc_apicid; |
| 137 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) { |
Alexey Starikovskiy | 746f224 | 2008-04-04 23:42:15 +0400 | [diff] [blame] | 139 | bootup_cpu = " (Bootup-CPU)"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | boot_cpu_physical_apicid = m->mpc_apicid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | } |
| 142 | |
Alexey Starikovskiy | 746f224 | 2008-04-04 23:42:15 +0400 | [diff] [blame] | 143 | printk(KERN_INFO "Processor #%d%s\n", m->mpc_apicid, bootup_cpu); |
Alexey Starikovskiy | c853c67 | 2008-03-27 23:54:13 +0300 | [diff] [blame] | 144 | generic_processor_info(apicid, m->mpc_apicver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | } |
| 146 | |
Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 147 | #ifdef CONFIG_X86_IO_APIC |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 148 | static void __init MP_bus_info(struct mpc_config_bus *m) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | { |
| 150 | char str[7]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | memcpy(str, m->mpc_bustype, 6); |
| 152 | str[6] = 0; |
| 153 | |
Alexey Starikovskiy | 0ec153a | 2008-03-17 22:08:48 +0300 | [diff] [blame] | 154 | #ifdef CONFIG_X86_NUMAQ |
Yinghai Lu | ab530e1 | 2008-06-03 10:25:54 -0700 | [diff] [blame] | 155 | if (found_numaq) |
| 156 | mpc_oem_bus_info(m, str, translation_table[mpc_record]); |
Alexey Starikovskiy | 0ec153a | 2008-03-17 22:08:48 +0300 | [diff] [blame] | 157 | #else |
Yinghai Lu | 11a62a0 | 2008-05-12 15:43:38 +0200 | [diff] [blame] | 158 | printk(KERN_INFO "Bus #%d is %s\n", m->mpc_busid, str); |
Alexey Starikovskiy | 0ec153a | 2008-03-17 22:08:48 +0300 | [diff] [blame] | 159 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | |
Andi Kleen | 5e4edbb | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 161 | #if MAX_MP_BUSSES < 256 |
Randy Dunlap | c0ec31a | 2006-04-10 22:53:13 -0700 | [diff] [blame] | 162 | if (m->mpc_busid >= MAX_MP_BUSSES) { |
| 163 | printk(KERN_WARNING "MP table busid value (%d) for bustype %s " |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 164 | " is too large, max. supported is %d\n", |
| 165 | m->mpc_busid, str, MAX_MP_BUSSES - 1); |
Randy Dunlap | c0ec31a | 2006-04-10 22:53:13 -0700 | [diff] [blame] | 166 | return; |
| 167 | } |
Andi Kleen | 5e4edbb | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 168 | #endif |
Randy Dunlap | c0ec31a | 2006-04-10 22:53:13 -0700 | [diff] [blame] | 169 | |
Alexey Starikovskiy | f8924e7 | 2008-04-04 23:42:21 +0400 | [diff] [blame] | 170 | if (strncmp(str, BUSTYPE_ISA, sizeof(BUSTYPE_ISA) - 1) == 0) { |
| 171 | set_bit(m->mpc_busid, mp_bus_not_pci); |
| 172 | #if defined(CONFIG_EISA) || defined (CONFIG_MCA) |
| 173 | mp_bus_id_to_type[m->mpc_busid] = MP_BUS_ISA; |
| 174 | #endif |
| 175 | } else if (strncmp(str, BUSTYPE_PCI, sizeof(BUSTYPE_PCI) - 1) == 0) { |
Alexey Starikovskiy | d285e33 | 2008-03-17 22:08:42 +0300 | [diff] [blame] | 176 | #ifdef CONFIG_X86_NUMAQ |
Yinghai Lu | ab530e1 | 2008-06-03 10:25:54 -0700 | [diff] [blame] | 177 | if (found_numaq) |
| 178 | mpc_oem_pci_bus(m, translation_table[mpc_record]); |
Alexey Starikovskiy | d285e33 | 2008-03-17 22:08:42 +0300 | [diff] [blame] | 179 | #endif |
Alexey Starikovskiy | a6333c3 | 2008-03-20 14:54:09 +0300 | [diff] [blame] | 180 | clear_bit(m->mpc_busid, mp_bus_not_pci); |
Alexey Starikovskiy | c0a282c | 2008-03-20 14:55:02 +0300 | [diff] [blame] | 181 | #if defined(CONFIG_EISA) || defined (CONFIG_MCA) |
| 182 | mp_bus_id_to_type[m->mpc_busid] = MP_BUS_PCI; |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 183 | } else if (strncmp(str, BUSTYPE_EISA, sizeof(BUSTYPE_EISA) - 1) == 0) { |
Alexey Starikovskiy | 9e0a2de | 2008-03-20 14:54:56 +0300 | [diff] [blame] | 184 | mp_bus_id_to_type[m->mpc_busid] = MP_BUS_EISA; |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 185 | } else if (strncmp(str, BUSTYPE_MCA, sizeof(BUSTYPE_MCA) - 1) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | mp_bus_id_to_type[m->mpc_busid] = MP_BUS_MCA; |
Alexey Starikovskiy | c0a282c | 2008-03-20 14:55:02 +0300 | [diff] [blame] | 187 | #endif |
Alexey Starikovskiy | f8924e7 | 2008-04-04 23:42:21 +0400 | [diff] [blame] | 188 | } else |
| 189 | printk(KERN_WARNING "Unknown bustype %s - ignoring\n", str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | } |
Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 191 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 193 | #ifdef CONFIG_X86_IO_APIC |
| 194 | |
Alexey Starikovskiy | 857033a | 2008-03-17 22:08:05 +0300 | [diff] [blame] | 195 | static int bad_ioapic(unsigned long address) |
| 196 | { |
| 197 | if (nr_ioapics >= MAX_IO_APICS) { |
| 198 | printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded " |
| 199 | "(found %d)\n", MAX_IO_APICS, nr_ioapics); |
| 200 | panic("Recompile kernel with bigger MAX_IO_APICS!\n"); |
| 201 | } |
| 202 | if (!address) { |
| 203 | printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address" |
| 204 | " found in table, skipping!\n"); |
| 205 | return 1; |
| 206 | } |
| 207 | return 0; |
| 208 | } |
| 209 | |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 210 | static void __init MP_ioapic_info(struct mpc_config_ioapic *m) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | { |
| 212 | if (!(m->mpc_flags & MPC_APIC_USABLE)) |
| 213 | return; |
| 214 | |
Thomas Gleixner | 64883ab | 2008-01-30 13:30:35 +0100 | [diff] [blame] | 215 | printk(KERN_INFO "I/O APIC #%d Version %d at 0x%X.\n", |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 216 | m->mpc_apicid, m->mpc_apicver, m->mpc_apicaddr); |
Alexey Starikovskiy | 857033a | 2008-03-17 22:08:05 +0300 | [diff] [blame] | 217 | |
| 218 | if (bad_ioapic(m->mpc_apicaddr)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | return; |
Alexey Starikovskiy | 857033a | 2008-03-17 22:08:05 +0300 | [diff] [blame] | 220 | |
Alexey Starikovskiy | ec2cd0a | 2008-05-14 19:03:10 +0400 | [diff] [blame] | 221 | mp_ioapics[nr_ioapics].mp_apicaddr = m->mpc_apicaddr; |
| 222 | mp_ioapics[nr_ioapics].mp_apicid = m->mpc_apicid; |
| 223 | mp_ioapics[nr_ioapics].mp_type = m->mpc_type; |
| 224 | mp_ioapics[nr_ioapics].mp_apicver = m->mpc_apicver; |
| 225 | mp_ioapics[nr_ioapics].mp_flags = m->mpc_flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | nr_ioapics++; |
| 227 | } |
| 228 | |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 229 | static void print_MP_intsrc_info(struct mpc_config_intsrc *m) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | { |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 231 | printk(KERN_CONT "Int: type %d, pol %d, trig %d, bus %02x," |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | " IRQ %02x, APIC ID %x, APIC INT %02x\n", |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 233 | m->mpc_irqtype, m->mpc_irqflag & 3, |
| 234 | (m->mpc_irqflag >> 2) & 3, m->mpc_srcbus, |
| 235 | m->mpc_srcbusirq, m->mpc_dstapic, m->mpc_dstirq); |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | static void __init print_mp_irq_info(struct mp_config_intsrc *mp_irq) |
| 239 | { |
| 240 | printk(KERN_CONT "Int: type %d, pol %d, trig %d, bus %02x," |
| 241 | " IRQ %02x, APIC ID %x, APIC INT %02x\n", |
| 242 | mp_irq->mp_irqtype, mp_irq->mp_irqflag & 3, |
| 243 | (mp_irq->mp_irqflag >> 2) & 3, mp_irq->mp_srcbus, |
| 244 | mp_irq->mp_srcbusirq, mp_irq->mp_dstapic, mp_irq->mp_dstirq); |
| 245 | } |
| 246 | |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 247 | static void __init assign_to_mp_irq(struct mpc_config_intsrc *m, |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 248 | struct mp_config_intsrc *mp_irq) |
| 249 | { |
| 250 | mp_irq->mp_dstapic = m->mpc_dstapic; |
| 251 | mp_irq->mp_type = m->mpc_type; |
| 252 | mp_irq->mp_irqtype = m->mpc_irqtype; |
| 253 | mp_irq->mp_irqflag = m->mpc_irqflag; |
| 254 | mp_irq->mp_srcbus = m->mpc_srcbus; |
| 255 | mp_irq->mp_srcbusirq = m->mpc_srcbusirq; |
| 256 | mp_irq->mp_dstirq = m->mpc_dstirq; |
| 257 | } |
| 258 | |
| 259 | static void __init assign_to_mpc_intsrc(struct mp_config_intsrc *mp_irq, |
| 260 | struct mpc_config_intsrc *m) |
| 261 | { |
| 262 | m->mpc_dstapic = mp_irq->mp_dstapic; |
| 263 | m->mpc_type = mp_irq->mp_type; |
| 264 | m->mpc_irqtype = mp_irq->mp_irqtype; |
| 265 | m->mpc_irqflag = mp_irq->mp_irqflag; |
| 266 | m->mpc_srcbus = mp_irq->mp_srcbus; |
| 267 | m->mpc_srcbusirq = mp_irq->mp_srcbusirq; |
| 268 | m->mpc_dstirq = mp_irq->mp_dstirq; |
| 269 | } |
| 270 | |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 271 | static int __init mp_irq_mpc_intsrc_cmp(struct mp_config_intsrc *mp_irq, |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 272 | struct mpc_config_intsrc *m) |
| 273 | { |
| 274 | if (mp_irq->mp_dstapic != m->mpc_dstapic) |
| 275 | return 1; |
| 276 | if (mp_irq->mp_type != m->mpc_type) |
| 277 | return 2; |
| 278 | if (mp_irq->mp_irqtype != m->mpc_irqtype) |
| 279 | return 3; |
| 280 | if (mp_irq->mp_irqflag != m->mpc_irqflag) |
| 281 | return 4; |
| 282 | if (mp_irq->mp_srcbus != m->mpc_srcbus) |
| 283 | return 5; |
| 284 | if (mp_irq->mp_srcbusirq != m->mpc_srcbusirq) |
| 285 | return 6; |
| 286 | if (mp_irq->mp_dstirq != m->mpc_dstirq) |
| 287 | return 7; |
| 288 | |
| 289 | return 0; |
| 290 | } |
| 291 | |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 292 | static void __init MP_intsrc_info(struct mpc_config_intsrc *m) |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 293 | { |
| 294 | int i; |
| 295 | |
| 296 | print_MP_intsrc_info(m); |
| 297 | |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 298 | for (i = 0; i < mp_irq_entries; i++) { |
| 299 | if (!mp_irq_mpc_intsrc_cmp(&mp_irqs[i], m)) |
| 300 | return; |
| 301 | } |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 302 | |
| 303 | assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | if (++mp_irq_entries == MAX_IRQ_SOURCES) |
| 305 | panic("Max # of irq sources exceeded!!\n"); |
| 306 | } |
| 307 | |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 308 | #endif |
| 309 | |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 310 | static void __init MP_lintsrc_info(struct mpc_config_lintsrc *m) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | { |
Yinghai Lu | 11a62a0 | 2008-05-12 15:43:38 +0200 | [diff] [blame] | 312 | printk(KERN_INFO "Lint: type %d, pol %d, trig %d, bus %02x," |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | " IRQ %02x, APIC ID %x, APIC LINT %02x\n", |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 314 | m->mpc_irqtype, m->mpc_irqflag & 3, |
| 315 | (m->mpc_irqflag >> 2) & 3, m->mpc_srcbusid, |
| 316 | m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | #ifdef CONFIG_X86_NUMAQ |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 320 | static void __init MP_translation_info(struct mpc_config_translation *m) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 322 | printk(KERN_INFO |
| 323 | "Translation: record %d, type %d, quad %d, global %d, local %d\n", |
| 324 | mpc_record, m->trans_type, m->trans_quad, m->trans_global, |
| 325 | m->trans_local); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 327 | if (mpc_record >= MAX_MPC_ENTRY) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | printk(KERN_ERR "MAX_MPC_ENTRY exceeded!\n"); |
| 329 | else |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 330 | translation_table[mpc_record] = m; /* stash this for later */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | if (m->trans_quad < MAX_NUMNODES && !node_online(m->trans_quad)) |
| 332 | node_set_online(m->trans_quad); |
| 333 | } |
| 334 | |
| 335 | /* |
| 336 | * Read/parse the MPC oem tables |
| 337 | */ |
| 338 | |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 339 | static void __init smp_read_mpc_oem(struct mp_config_oemtable *oemtable, |
| 340 | unsigned short oemsize) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 342 | int count = sizeof(*oemtable); /* the header size */ |
| 343 | unsigned char *oemptr = ((unsigned char *)oemtable) + count; |
| 344 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | mpc_record = 0; |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 346 | printk(KERN_INFO "Found an OEM MPC table at %8p - parsing it ... \n", |
| 347 | oemtable); |
| 348 | if (memcmp(oemtable->oem_signature, MPC_OEM_SIGNATURE, 4)) { |
| 349 | printk(KERN_WARNING |
| 350 | "SMP mpc oemtable: bad signature [%c%c%c%c]!\n", |
| 351 | oemtable->oem_signature[0], oemtable->oem_signature[1], |
| 352 | oemtable->oem_signature[2], oemtable->oem_signature[3]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | return; |
| 354 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 355 | if (mpf_checksum((unsigned char *)oemtable, oemtable->oem_length)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | printk(KERN_WARNING "SMP oem mptable: checksum error!\n"); |
| 357 | return; |
| 358 | } |
| 359 | while (count < oemtable->oem_length) { |
| 360 | switch (*oemptr) { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 361 | case MP_TRANSLATION: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 363 | struct mpc_config_translation *m = |
| 364 | (struct mpc_config_translation *)oemptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | MP_translation_info(m); |
| 366 | oemptr += sizeof(*m); |
| 367 | count += sizeof(*m); |
| 368 | ++mpc_record; |
| 369 | break; |
| 370 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 371 | default: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 373 | printk(KERN_WARNING |
| 374 | "Unrecognised OEM table entry type! - %d\n", |
| 375 | (int)*oemptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | return; |
| 377 | } |
| 378 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 379 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | } |
| 381 | |
Yinghai Lu | d49c428 | 2008-06-08 18:31:54 -0700 | [diff] [blame] | 382 | void numaq_mps_oem_check(struct mp_config_table *mpc, char *oem, |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 383 | char *productid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | { |
| 385 | if (strncmp(oem, "IBM NUMA", 8)) |
Yinghai Lu | d49c428 | 2008-06-08 18:31:54 -0700 | [diff] [blame] | 386 | printk("Warning! Not a NUMA-Q system!\n"); |
Yinghai Lu | ab530e1 | 2008-06-03 10:25:54 -0700 | [diff] [blame] | 387 | else |
| 388 | found_numaq = 1; |
| 389 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | if (mpc->mpc_oemptr) |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 391 | smp_read_mpc_oem((struct mp_config_oemtable *)mpc->mpc_oemptr, |
| 392 | mpc->mpc_oemsize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 394 | #endif /* CONFIG_X86_NUMAQ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | |
| 396 | /* |
| 397 | * Read/parse the MPC |
| 398 | */ |
| 399 | |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 400 | static int __init smp_check_mpc(struct mp_config_table *mpc, char *oem, |
| 401 | char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 404 | if (memcmp(mpc->mpc_signature, MPC_SIGNATURE, 4)) { |
Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 405 | printk(KERN_ERR "MPTABLE: bad signature [%c%c%c%c]!\n", |
| 406 | mpc->mpc_signature[0], mpc->mpc_signature[1], |
| 407 | mpc->mpc_signature[2], mpc->mpc_signature[3]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | return 0; |
| 409 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 410 | if (mpf_checksum((unsigned char *)mpc, mpc->mpc_length)) { |
Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 411 | printk(KERN_ERR "MPTABLE: checksum error!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | return 0; |
| 413 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 414 | if (mpc->mpc_spec != 0x01 && mpc->mpc_spec != 0x04) { |
Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 415 | printk(KERN_ERR "MPTABLE: bad table version (%d)!!\n", |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 416 | mpc->mpc_spec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | return 0; |
| 418 | } |
| 419 | if (!mpc->mpc_lapic) { |
Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 420 | printk(KERN_ERR "MPTABLE: null local APIC address!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | return 0; |
| 422 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 423 | memcpy(oem, mpc->mpc_oem, 8); |
| 424 | oem[8] = 0; |
Yinghai Lu | 11a62a0 | 2008-05-12 15:43:38 +0200 | [diff] [blame] | 425 | printk(KERN_INFO "MPTABLE: OEM ID: %s\n", oem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 427 | memcpy(str, mpc->mpc_productid, 12); |
| 428 | str[12] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | |
Yinghai Lu | 11a62a0 | 2008-05-12 15:43:38 +0200 | [diff] [blame] | 430 | printk(KERN_INFO "MPTABLE: Product ID: %s\n", str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | |
Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 432 | printk(KERN_INFO "MPTABLE: APIC at: 0x%X\n", mpc->mpc_lapic); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 434 | return 1; |
| 435 | } |
| 436 | |
| 437 | static int __init smp_read_mpc(struct mp_config_table *mpc, unsigned early) |
| 438 | { |
| 439 | char str[16]; |
| 440 | char oem[10]; |
| 441 | |
| 442 | int count = sizeof(*mpc); |
| 443 | unsigned char *mpt = ((unsigned char *)mpc) + count; |
| 444 | |
| 445 | if (!smp_check_mpc(mpc, oem, str)) |
| 446 | return 0; |
| 447 | |
| 448 | #ifdef CONFIG_X86_32 |
Yinghai Lu | d49c428 | 2008-06-08 18:31:54 -0700 | [diff] [blame] | 449 | /* |
| 450 | * need to make sure summit and es7000's mps_oem_check is safe to be |
| 451 | * called early via genericarch 's mps_oem_check |
| 452 | */ |
| 453 | if (early) { |
| 454 | #ifdef CONFIG_X86_NUMAQ |
| 455 | numaq_mps_oem_check(mpc, oem, str); |
| 456 | #endif |
| 457 | } else |
| 458 | mps_oem_check(mpc, oem, str); |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 459 | #endif |
| 460 | |
Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 461 | /* save the local APIC address, it might be non-default */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | if (!acpi_lapic) |
| 463 | mp_lapic_addr = mpc->mpc_lapic; |
| 464 | |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 465 | if (early) |
| 466 | return 1; |
| 467 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | /* |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 469 | * Now process the configuration blocks. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | */ |
Alexey Starikovskiy | 8642050 | 2008-03-17 22:08:55 +0300 | [diff] [blame] | 471 | #ifdef CONFIG_X86_NUMAQ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | mpc_record = 0; |
Alexey Starikovskiy | 8642050 | 2008-03-17 22:08:55 +0300 | [diff] [blame] | 473 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | while (count < mpc->mpc_length) { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 475 | switch (*mpt) { |
| 476 | case MP_PROCESSOR: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 478 | struct mpc_config_processor *m = |
| 479 | (struct mpc_config_processor *)mpt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | /* ACPI may have already provided this data */ |
| 481 | if (!acpi_lapic) |
| 482 | MP_processor_info(m); |
| 483 | mpt += sizeof(*m); |
| 484 | count += sizeof(*m); |
| 485 | break; |
| 486 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 487 | case MP_BUS: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 489 | struct mpc_config_bus *m = |
| 490 | (struct mpc_config_bus *)mpt; |
Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 491 | #ifdef CONFIG_X86_IO_APIC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | MP_bus_info(m); |
Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 493 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | mpt += sizeof(*m); |
| 495 | count += sizeof(*m); |
| 496 | break; |
| 497 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 498 | case MP_IOAPIC: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | { |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 500 | #ifdef CONFIG_X86_IO_APIC |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 501 | struct mpc_config_ioapic *m = |
| 502 | (struct mpc_config_ioapic *)mpt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | MP_ioapic_info(m); |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 504 | #endif |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 505 | mpt += sizeof(struct mpc_config_ioapic); |
| 506 | count += sizeof(struct mpc_config_ioapic); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | break; |
| 508 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 509 | case MP_INTSRC: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | { |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 511 | #ifdef CONFIG_X86_IO_APIC |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 512 | struct mpc_config_intsrc *m = |
| 513 | (struct mpc_config_intsrc *)mpt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | |
| 515 | MP_intsrc_info(m); |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 516 | #endif |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 517 | mpt += sizeof(struct mpc_config_intsrc); |
| 518 | count += sizeof(struct mpc_config_intsrc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | break; |
| 520 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 521 | case MP_LINTSRC: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 523 | struct mpc_config_lintsrc *m = |
| 524 | (struct mpc_config_lintsrc *)mpt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | MP_lintsrc_info(m); |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 526 | mpt += sizeof(*m); |
| 527 | count += sizeof(*m); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | break; |
| 529 | } |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 530 | default: |
Yinghai Lu | 711554d | 2008-04-07 11:36:39 -0700 | [diff] [blame] | 531 | /* wrong mptable */ |
| 532 | printk(KERN_ERR "Your mptable is wrong, contact your HW vendor!\n"); |
| 533 | printk(KERN_ERR "type %x\n", *mpt); |
| 534 | print_hex_dump(KERN_ERR, " ", DUMP_PREFIX_ADDRESS, 16, |
| 535 | 1, mpc, mpc->mpc_length, 1); |
| 536 | count = mpc->mpc_length; |
| 537 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | } |
Alexey Starikovskiy | 8642050 | 2008-03-17 22:08:55 +0300 | [diff] [blame] | 539 | #ifdef CONFIG_X86_NUMAQ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | ++mpc_record; |
Alexey Starikovskiy | 8642050 | 2008-03-17 22:08:55 +0300 | [diff] [blame] | 541 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | } |
Yinghai Lu | e0da336 | 2008-06-08 18:29:22 -0700 | [diff] [blame] | 543 | |
| 544 | #ifdef CONFIG_X86_GENERICARCH |
| 545 | generic_bigsmp_probe(); |
| 546 | #endif |
| 547 | |
Ingo Molnar | 3c43f03 | 2007-05-02 19:27:04 +0200 | [diff] [blame] | 548 | setup_apic_routing(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | if (!num_processors) |
Alexey Starikovskiy | e950bea | 2008-04-04 23:42:27 +0400 | [diff] [blame] | 550 | printk(KERN_ERR "MPTABLE: no processors registered!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | return num_processors; |
| 552 | } |
| 553 | |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 554 | #ifdef CONFIG_X86_IO_APIC |
| 555 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | static int __init ELCR_trigger(unsigned int irq) |
| 557 | { |
| 558 | unsigned int port; |
| 559 | |
| 560 | port = 0x4d0 + (irq >> 3); |
| 561 | return (inb(port) >> (irq & 7)) & 1; |
| 562 | } |
| 563 | |
| 564 | static void __init construct_default_ioirq_mptable(int mpc_default_type) |
| 565 | { |
| 566 | struct mpc_config_intsrc intsrc; |
| 567 | int i; |
| 568 | int ELCR_fallback = 0; |
| 569 | |
| 570 | intsrc.mpc_type = MP_INTSRC; |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 571 | intsrc.mpc_irqflag = 0; /* conforming */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | intsrc.mpc_srcbus = 0; |
Alexey Starikovskiy | ec2cd0a | 2008-05-14 19:03:10 +0400 | [diff] [blame] | 573 | intsrc.mpc_dstapic = mp_ioapics[0].mp_apicid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | |
| 575 | intsrc.mpc_irqtype = mp_INT; |
| 576 | |
| 577 | /* |
| 578 | * If true, we have an ISA/PCI system with no IRQ entries |
| 579 | * in the MP table. To prevent the PCI interrupts from being set up |
| 580 | * incorrectly, we try to use the ELCR. The sanity check to see if |
| 581 | * there is good ELCR data is very simple - IRQ0, 1, 2 and 13 can |
| 582 | * never be level sensitive, so we simply see if the ELCR agrees. |
| 583 | * If it does, we assume it's valid. |
| 584 | */ |
| 585 | if (mpc_default_type == 5) { |
Alexey Starikovskiy | 62441bf | 2008-04-04 23:42:34 +0400 | [diff] [blame] | 586 | printk(KERN_INFO "ISA/PCI bus type with no IRQ information... " |
| 587 | "falling back to ELCR\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | |
Alexey Starikovskiy | 62441bf | 2008-04-04 23:42:34 +0400 | [diff] [blame] | 589 | if (ELCR_trigger(0) || ELCR_trigger(1) || ELCR_trigger(2) || |
| 590 | ELCR_trigger(13)) |
| 591 | printk(KERN_ERR "ELCR contains invalid data... " |
| 592 | "not using ELCR\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | else { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 594 | printk(KERN_INFO |
| 595 | "Using ELCR to identify PCI interrupts\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | ELCR_fallback = 1; |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | for (i = 0; i < 16; i++) { |
| 601 | switch (mpc_default_type) { |
| 602 | case 2: |
| 603 | if (i == 0 || i == 13) |
| 604 | continue; /* IRQ0 & IRQ13 not connected */ |
| 605 | /* fall through */ |
| 606 | default: |
| 607 | if (i == 2) |
| 608 | continue; /* IRQ2 is never connected */ |
| 609 | } |
| 610 | |
| 611 | if (ELCR_fallback) { |
| 612 | /* |
| 613 | * If the ELCR indicates a level-sensitive interrupt, we |
| 614 | * copy that information over to the MP table in the |
| 615 | * irqflag field (level sensitive, active high polarity). |
| 616 | */ |
| 617 | if (ELCR_trigger(i)) |
| 618 | intsrc.mpc_irqflag = 13; |
| 619 | else |
| 620 | intsrc.mpc_irqflag = 0; |
| 621 | } |
| 622 | |
| 623 | intsrc.mpc_srcbusirq = i; |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 624 | intsrc.mpc_dstirq = i ? i : 2; /* IRQ0 to INTIN2 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | MP_intsrc_info(&intsrc); |
| 626 | } |
| 627 | |
| 628 | intsrc.mpc_irqtype = mp_ExtINT; |
| 629 | intsrc.mpc_srcbusirq = 0; |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 630 | intsrc.mpc_dstirq = 0; /* 8259A to INTIN0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | MP_intsrc_info(&intsrc); |
| 632 | } |
| 633 | |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 634 | |
Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 635 | static void construct_ioapic_table(int mpc_default_type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | struct mpc_config_ioapic ioapic; |
Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 638 | struct mpc_config_bus bus; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | |
| 640 | bus.mpc_type = MP_BUS; |
| 641 | bus.mpc_busid = 0; |
| 642 | switch (mpc_default_type) { |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 643 | default: |
Alexey Starikovskiy | 62441bf | 2008-04-04 23:42:34 +0400 | [diff] [blame] | 644 | printk(KERN_ERR "???\nUnknown standard configuration %d\n", |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 645 | mpc_default_type); |
| 646 | /* fall through */ |
| 647 | case 1: |
| 648 | case 5: |
| 649 | memcpy(bus.mpc_bustype, "ISA ", 6); |
| 650 | break; |
| 651 | case 2: |
| 652 | case 6: |
| 653 | case 3: |
| 654 | memcpy(bus.mpc_bustype, "EISA ", 6); |
| 655 | break; |
| 656 | case 4: |
| 657 | case 7: |
| 658 | memcpy(bus.mpc_bustype, "MCA ", 6); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | } |
| 660 | MP_bus_info(&bus); |
| 661 | if (mpc_default_type > 4) { |
| 662 | bus.mpc_busid = 1; |
| 663 | memcpy(bus.mpc_bustype, "PCI ", 6); |
| 664 | MP_bus_info(&bus); |
| 665 | } |
| 666 | |
| 667 | ioapic.mpc_type = MP_IOAPIC; |
| 668 | ioapic.mpc_apicid = 2; |
| 669 | ioapic.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01; |
| 670 | ioapic.mpc_flags = MPC_APIC_USABLE; |
| 671 | ioapic.mpc_apicaddr = 0xFEC00000; |
| 672 | MP_ioapic_info(&ioapic); |
| 673 | |
| 674 | /* |
| 675 | * We set up most of the low 16 IO-APIC pins according to MPS rules. |
| 676 | */ |
| 677 | construct_default_ioirq_mptable(mpc_default_type); |
Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 678 | } |
| 679 | #else |
| 680 | static inline void construct_ioapic_table(int mpc_default_type) { } |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 681 | #endif |
Thomas Gleixner | 85cc35f | 2008-05-25 21:21:36 +0200 | [diff] [blame] | 682 | |
| 683 | static inline void __init construct_default_ISA_mptable(int mpc_default_type) |
| 684 | { |
| 685 | struct mpc_config_processor processor; |
| 686 | struct mpc_config_lintsrc lintsrc; |
| 687 | int linttypes[2] = { mp_ExtINT, mp_NMI }; |
| 688 | int i; |
| 689 | |
| 690 | /* |
| 691 | * local APIC has default address |
| 692 | */ |
| 693 | mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; |
| 694 | |
| 695 | /* |
| 696 | * 2 CPUs, numbered 0 & 1. |
| 697 | */ |
| 698 | processor.mpc_type = MP_PROCESSOR; |
| 699 | /* Either an integrated APIC or a discrete 82489DX. */ |
| 700 | processor.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01; |
| 701 | processor.mpc_cpuflag = CPU_ENABLED; |
| 702 | processor.mpc_cpufeature = (boot_cpu_data.x86 << 8) | |
| 703 | (boot_cpu_data.x86_model << 4) | boot_cpu_data.x86_mask; |
| 704 | processor.mpc_featureflag = boot_cpu_data.x86_capability[0]; |
| 705 | processor.mpc_reserved[0] = 0; |
| 706 | processor.mpc_reserved[1] = 0; |
| 707 | for (i = 0; i < 2; i++) { |
| 708 | processor.mpc_apicid = i; |
| 709 | MP_processor_info(&processor); |
| 710 | } |
| 711 | |
| 712 | construct_ioapic_table(mpc_default_type); |
| 713 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | lintsrc.mpc_type = MP_LINTSRC; |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 715 | lintsrc.mpc_irqflag = 0; /* conforming */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | lintsrc.mpc_srcbusid = 0; |
| 717 | lintsrc.mpc_srcbusirq = 0; |
| 718 | lintsrc.mpc_destapic = MP_APIC_ALL; |
| 719 | for (i = 0; i < 2; i++) { |
| 720 | lintsrc.mpc_irqtype = linttypes[i]; |
| 721 | lintsrc.mpc_destapiclint = i; |
| 722 | MP_lintsrc_info(&lintsrc); |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | static struct intel_mp_floating *mpf_found; |
| 727 | |
| 728 | /* |
Ingo Molnar | 3b33553 | 2008-07-10 17:30:40 +0200 | [diff] [blame^] | 729 | * Machine specific quirk for finding the SMP config before other setup |
| 730 | * activities destroy the table: |
| 731 | */ |
| 732 | int (*mach_get_smp_config_quirk)(unsigned int early); |
| 733 | |
| 734 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 735 | * Scan the memory blocks for an SMP configuration block. |
| 736 | */ |
Ingo Molnar | 3b33553 | 2008-07-10 17:30:40 +0200 | [diff] [blame^] | 737 | static void __init __get_smp_config(unsigned int early) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | { |
| 739 | struct intel_mp_floating *mpf = mpf_found; |
| 740 | |
Ingo Molnar | 3b33553 | 2008-07-10 17:30:40 +0200 | [diff] [blame^] | 741 | if (mach_get_smp_config_quirk) { |
| 742 | if (mach_get_smp_config_quirk(early)) |
| 743 | return; |
| 744 | } |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 745 | if (acpi_lapic && early) |
| 746 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 747 | /* |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 748 | * ACPI supports both logical (e.g. Hyper-Threading) and physical |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | * processors, where MPS only supports physical. |
| 750 | */ |
| 751 | if (acpi_lapic && acpi_ioapic) { |
Alexey Starikovskiy | 4421b1c | 2008-04-04 23:42:40 +0400 | [diff] [blame] | 752 | printk(KERN_INFO "Using ACPI (MADT) for SMP configuration " |
| 753 | "information\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | return; |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 755 | } else if (acpi_lapic) |
Alexey Starikovskiy | 4421b1c | 2008-04-04 23:42:40 +0400 | [diff] [blame] | 756 | printk(KERN_INFO "Using ACPI for processor (LAPIC) " |
| 757 | "configuration information\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 759 | printk(KERN_INFO "Intel MultiProcessor Specification v1.%d\n", |
| 760 | mpf->mpf_specification); |
Alexey Starikovskiy | b3e2416 | 2008-05-23 01:54:44 +0400 | [diff] [blame] | 761 | #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32) |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 762 | if (mpf->mpf_feature2 & (1 << 7)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | printk(KERN_INFO " IMCR and PIC compatibility mode.\n"); |
| 764 | pic_mode = 1; |
| 765 | } else { |
| 766 | printk(KERN_INFO " Virtual Wire compatibility mode.\n"); |
| 767 | pic_mode = 0; |
| 768 | } |
Alexey Starikovskiy | 4421b1c | 2008-04-04 23:42:40 +0400 | [diff] [blame] | 769 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | /* |
| 771 | * Now see if we need to read further. |
| 772 | */ |
| 773 | if (mpf->mpf_feature1 != 0) { |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 774 | if (early) { |
| 775 | /* |
| 776 | * local APIC has default address |
| 777 | */ |
| 778 | mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; |
| 779 | return; |
| 780 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 782 | printk(KERN_INFO "Default MP configuration #%d\n", |
| 783 | mpf->mpf_feature1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | construct_default_ISA_mptable(mpf->mpf_feature1); |
| 785 | |
| 786 | } else if (mpf->mpf_physptr) { |
| 787 | |
| 788 | /* |
| 789 | * Read the physical hardware table. Anything here will |
| 790 | * override the defaults. |
| 791 | */ |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 792 | if (!smp_read_mpc(phys_to_virt(mpf->mpf_physptr), early)) { |
Alexey Starikovskiy | bab4b27 | 2008-05-19 19:47:03 +0400 | [diff] [blame] | 793 | #ifdef CONFIG_X86_LOCAL_APIC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 794 | smp_found_config = 0; |
Alexey Starikovskiy | bab4b27 | 2008-05-19 19:47:03 +0400 | [diff] [blame] | 795 | #endif |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 796 | printk(KERN_ERR |
| 797 | "BIOS bug, MP table errors detected!...\n"); |
Alexey Starikovskiy | 4421b1c | 2008-04-04 23:42:40 +0400 | [diff] [blame] | 798 | printk(KERN_ERR "... disabling SMP support. " |
| 799 | "(tell your hw vendor)\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | return; |
| 801 | } |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 802 | |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 803 | if (early) |
| 804 | return; |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 805 | #ifdef CONFIG_X86_IO_APIC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | /* |
| 807 | * If there are no explicit MP IRQ entries, then we are |
| 808 | * broken. We set up most of the low 16 IO-APIC pins to |
| 809 | * ISA defaults and hope it will work. |
| 810 | */ |
| 811 | if (!mp_irq_entries) { |
| 812 | struct mpc_config_bus bus; |
| 813 | |
Alexey Starikovskiy | 4421b1c | 2008-04-04 23:42:40 +0400 | [diff] [blame] | 814 | printk(KERN_ERR "BIOS bug, no explicit IRQ entries, " |
| 815 | "using default mptable. " |
| 816 | "(tell your hw vendor)\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | |
| 818 | bus.mpc_type = MP_BUS; |
| 819 | bus.mpc_busid = 0; |
| 820 | memcpy(bus.mpc_bustype, "ISA ", 6); |
| 821 | MP_bus_info(&bus); |
| 822 | |
| 823 | construct_default_ioirq_mptable(0); |
| 824 | } |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 825 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 826 | } else |
| 827 | BUG(); |
| 828 | |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 829 | if (!early) |
| 830 | printk(KERN_INFO "Processors: %d\n", num_processors); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | /* |
| 832 | * Only use the first configuration found. |
| 833 | */ |
| 834 | } |
| 835 | |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 836 | void __init early_get_smp_config(void) |
| 837 | { |
| 838 | __get_smp_config(1); |
| 839 | } |
| 840 | |
| 841 | void __init get_smp_config(void) |
| 842 | { |
| 843 | __get_smp_config(0); |
| 844 | } |
| 845 | |
| 846 | static int __init smp_scan_config(unsigned long base, unsigned long length, |
| 847 | unsigned reserve) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 848 | { |
Alexey Starikovskiy | 92fd4b7 | 2008-04-04 23:42:46 +0400 | [diff] [blame] | 849 | unsigned int *bp = phys_to_virt(base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | struct intel_mp_floating *mpf; |
| 851 | |
Yinghai Lu | 11a62a0 | 2008-05-12 15:43:38 +0200 | [diff] [blame] | 852 | printk(KERN_DEBUG "Scan SMP from %p for %ld bytes.\n", bp, length); |
Akinobu Mita | 5d47a27 | 2008-04-19 23:55:11 +0900 | [diff] [blame] | 853 | BUILD_BUG_ON(sizeof(*mpf) != 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 854 | |
| 855 | while (length > 0) { |
| 856 | mpf = (struct intel_mp_floating *)bp; |
| 857 | if ((*bp == SMP_MAGIC_IDENT) && |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 858 | (mpf->mpf_length == 1) && |
| 859 | !mpf_checksum((unsigned char *)bp, 16) && |
| 860 | ((mpf->mpf_specification == 1) |
| 861 | || (mpf->mpf_specification == 4))) { |
Alexey Starikovskiy | bab4b27 | 2008-05-19 19:47:03 +0400 | [diff] [blame] | 862 | #ifdef CONFIG_X86_LOCAL_APIC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 863 | smp_found_config = 1; |
Alexey Starikovskiy | bab4b27 | 2008-05-19 19:47:03 +0400 | [diff] [blame] | 864 | #endif |
Alexey Starikovskiy | 92fd4b7 | 2008-04-04 23:42:46 +0400 | [diff] [blame] | 865 | mpf_found = mpf; |
Yinghai Lu | b1f006b | 2008-06-09 18:11:36 -0700 | [diff] [blame] | 866 | |
Ingo Molnar | e91a3b43 | 2008-01-30 13:33:08 +0100 | [diff] [blame] | 867 | printk(KERN_INFO "found SMP MP-table at [%p] %08lx\n", |
Alexey Starikovskiy | 4ef8129 | 2008-04-04 23:42:03 +0400 | [diff] [blame] | 868 | mpf, virt_to_phys(mpf)); |
Yinghai Lu | b1f006b | 2008-06-09 18:11:36 -0700 | [diff] [blame] | 869 | |
| 870 | if (!reserve) |
| 871 | return 1; |
Yinghai Lu | d2dbf34 | 2008-06-13 02:00:56 -0700 | [diff] [blame] | 872 | reserve_bootmem_generic(virt_to_phys(mpf), PAGE_SIZE, |
Bernhard Walle | 72a7fe3 | 2008-02-07 00:15:17 -0800 | [diff] [blame] | 873 | BOOTMEM_DEFAULT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 874 | if (mpf->mpf_physptr) { |
Yinghai Lu | d2dbf34 | 2008-06-13 02:00:56 -0700 | [diff] [blame] | 875 | unsigned long size = PAGE_SIZE; |
| 876 | #ifdef CONFIG_X86_32 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 877 | /* |
| 878 | * We cannot access to MPC table to compute |
| 879 | * table size yet, as only few megabytes from |
| 880 | * the bottom is mapped now. |
| 881 | * PC-9800's MPC table places on the very last |
| 882 | * of physical memory; so that simply reserving |
| 883 | * PAGE_SIZE from mpg->mpf_physptr yields BUG() |
| 884 | * in reserve_bootmem. |
| 885 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 886 | unsigned long end = max_low_pfn * PAGE_SIZE; |
| 887 | if (mpf->mpf_physptr + size > end) |
| 888 | size = end - mpf->mpf_physptr; |
Yinghai Lu | d2dbf34 | 2008-06-13 02:00:56 -0700 | [diff] [blame] | 889 | #endif |
| 890 | reserve_bootmem_generic(mpf->mpf_physptr, size, |
Bernhard Walle | 72a7fe3 | 2008-02-07 00:15:17 -0800 | [diff] [blame] | 891 | BOOTMEM_DEFAULT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 892 | } |
| 893 | |
Yinghai Lu | d2dbf34 | 2008-06-13 02:00:56 -0700 | [diff] [blame] | 894 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | } |
| 896 | bp += 4; |
| 897 | length -= 16; |
| 898 | } |
| 899 | return 0; |
| 900 | } |
| 901 | |
Ingo Molnar | 3b33553 | 2008-07-10 17:30:40 +0200 | [diff] [blame^] | 902 | int (*mach_find_smp_config_quirk)(unsigned int reserve); |
| 903 | |
| 904 | static void __init __find_smp_config(unsigned int reserve) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | { |
| 906 | unsigned int address; |
| 907 | |
Ingo Molnar | 3b33553 | 2008-07-10 17:30:40 +0200 | [diff] [blame^] | 908 | if (mach_find_smp_config_quirk) { |
| 909 | if (mach_find_smp_config_quirk(reserve)) |
| 910 | return; |
| 911 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 912 | /* |
| 913 | * FIXME: Linux assumes you have 640K of base ram.. |
| 914 | * this continues the error... |
| 915 | * |
| 916 | * 1) Scan the bottom 1K for a signature |
| 917 | * 2) Scan the top 1K of base RAM |
| 918 | * 3) Scan the 64K of bios |
| 919 | */ |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 920 | if (smp_scan_config(0x0, 0x400, reserve) || |
| 921 | smp_scan_config(639 * 0x400, 0x400, reserve) || |
| 922 | smp_scan_config(0xF0000, 0x10000, reserve)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | return; |
| 924 | /* |
| 925 | * If it is an SMP machine we should know now, unless the |
| 926 | * configuration is in an EISA/MCA bus machine with an |
| 927 | * extended bios data area. |
| 928 | * |
| 929 | * there is a real-mode segmented pointer pointing to the |
| 930 | * 4K EBDA area at 0x40E, calculate and scan it here. |
| 931 | * |
| 932 | * NOTE! There are Linux loaders that will corrupt the EBDA |
| 933 | * area, and as such this kind of SMP config may be less |
| 934 | * trustworthy, simply because the SMP table may have been |
| 935 | * stomped on during early boot. These loaders are buggy and |
| 936 | * should be fixed. |
| 937 | * |
| 938 | * MP1.4 SPEC states to only scan first 1K of 4K EBDA. |
| 939 | */ |
| 940 | |
| 941 | address = get_bios_ebda(); |
| 942 | if (address) |
Alexey Starikovskiy | 888032c | 2008-04-04 23:42:09 +0400 | [diff] [blame] | 943 | smp_scan_config(address, 0x400, reserve); |
| 944 | } |
| 945 | |
| 946 | void __init early_find_smp_config(void) |
| 947 | { |
| 948 | __find_smp_config(0); |
| 949 | } |
| 950 | |
| 951 | void __init find_smp_config(void) |
| 952 | { |
| 953 | __find_smp_config(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 954 | } |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 955 | |
| 956 | #ifdef CONFIG_X86_IO_APIC |
| 957 | static u8 __initdata irq_used[MAX_IRQ_SOURCES]; |
| 958 | |
| 959 | static int __init get_MP_intsrc_index(struct mpc_config_intsrc *m) |
| 960 | { |
| 961 | int i; |
| 962 | |
| 963 | if (m->mpc_irqtype != mp_INT) |
| 964 | return 0; |
| 965 | |
| 966 | if (m->mpc_irqflag != 0x0f) |
| 967 | return 0; |
| 968 | |
| 969 | /* not legacy */ |
| 970 | |
| 971 | for (i = 0; i < mp_irq_entries; i++) { |
| 972 | if (mp_irqs[i].mp_irqtype != mp_INT) |
| 973 | continue; |
| 974 | |
| 975 | if (mp_irqs[i].mp_irqflag != 0x0f) |
| 976 | continue; |
| 977 | |
| 978 | if (mp_irqs[i].mp_srcbus != m->mpc_srcbus) |
| 979 | continue; |
| 980 | if (mp_irqs[i].mp_srcbusirq != m->mpc_srcbusirq) |
| 981 | continue; |
| 982 | if (irq_used[i]) { |
| 983 | /* already claimed */ |
| 984 | return -2; |
| 985 | } |
| 986 | irq_used[i] = 1; |
| 987 | return i; |
| 988 | } |
| 989 | |
| 990 | /* not found */ |
| 991 | return -1; |
| 992 | } |
| 993 | |
| 994 | #define SPARE_SLOT_NUM 20 |
| 995 | |
| 996 | static struct mpc_config_intsrc __initdata *m_spare[SPARE_SLOT_NUM]; |
| 997 | #endif |
| 998 | |
| 999 | static int __init replace_intsrc_all(struct mp_config_table *mpc, |
| 1000 | unsigned long mpc_new_phys, |
| 1001 | unsigned long mpc_new_length) |
| 1002 | { |
| 1003 | #ifdef CONFIG_X86_IO_APIC |
| 1004 | int i; |
| 1005 | int nr_m_spare = 0; |
| 1006 | #endif |
| 1007 | |
| 1008 | int count = sizeof(*mpc); |
| 1009 | unsigned char *mpt = ((unsigned char *)mpc) + count; |
| 1010 | |
| 1011 | printk(KERN_INFO "mpc_length %x\n", mpc->mpc_length); |
| 1012 | while (count < mpc->mpc_length) { |
| 1013 | switch (*mpt) { |
| 1014 | case MP_PROCESSOR: |
| 1015 | { |
| 1016 | struct mpc_config_processor *m = |
| 1017 | (struct mpc_config_processor *)mpt; |
| 1018 | mpt += sizeof(*m); |
| 1019 | count += sizeof(*m); |
| 1020 | break; |
| 1021 | } |
| 1022 | case MP_BUS: |
| 1023 | { |
| 1024 | struct mpc_config_bus *m = |
| 1025 | (struct mpc_config_bus *)mpt; |
| 1026 | mpt += sizeof(*m); |
| 1027 | count += sizeof(*m); |
| 1028 | break; |
| 1029 | } |
| 1030 | case MP_IOAPIC: |
| 1031 | { |
| 1032 | mpt += sizeof(struct mpc_config_ioapic); |
| 1033 | count += sizeof(struct mpc_config_ioapic); |
| 1034 | break; |
| 1035 | } |
| 1036 | case MP_INTSRC: |
| 1037 | { |
| 1038 | #ifdef CONFIG_X86_IO_APIC |
| 1039 | struct mpc_config_intsrc *m = |
| 1040 | (struct mpc_config_intsrc *)mpt; |
| 1041 | |
| 1042 | printk(KERN_INFO "OLD "); |
| 1043 | print_MP_intsrc_info(m); |
| 1044 | i = get_MP_intsrc_index(m); |
| 1045 | if (i > 0) { |
| 1046 | assign_to_mpc_intsrc(&mp_irqs[i], m); |
| 1047 | printk(KERN_INFO "NEW "); |
| 1048 | print_mp_irq_info(&mp_irqs[i]); |
| 1049 | } else if (!i) { |
| 1050 | /* legacy, do nothing */ |
| 1051 | } else if (nr_m_spare < SPARE_SLOT_NUM) { |
| 1052 | /* |
| 1053 | * not found (-1), or duplicated (-2) |
| 1054 | * are invalid entries, |
| 1055 | * we need to use the slot later |
| 1056 | */ |
| 1057 | m_spare[nr_m_spare] = m; |
| 1058 | nr_m_spare++; |
| 1059 | } |
| 1060 | #endif |
| 1061 | mpt += sizeof(struct mpc_config_intsrc); |
| 1062 | count += sizeof(struct mpc_config_intsrc); |
| 1063 | break; |
| 1064 | } |
| 1065 | case MP_LINTSRC: |
| 1066 | { |
| 1067 | struct mpc_config_lintsrc *m = |
| 1068 | (struct mpc_config_lintsrc *)mpt; |
| 1069 | mpt += sizeof(*m); |
| 1070 | count += sizeof(*m); |
| 1071 | break; |
| 1072 | } |
| 1073 | default: |
| 1074 | /* wrong mptable */ |
| 1075 | printk(KERN_ERR "Your mptable is wrong, contact your HW vendor!\n"); |
| 1076 | printk(KERN_ERR "type %x\n", *mpt); |
| 1077 | print_hex_dump(KERN_ERR, " ", DUMP_PREFIX_ADDRESS, 16, |
| 1078 | 1, mpc, mpc->mpc_length, 1); |
| 1079 | goto out; |
| 1080 | } |
| 1081 | } |
| 1082 | |
| 1083 | #ifdef CONFIG_X86_IO_APIC |
| 1084 | for (i = 0; i < mp_irq_entries; i++) { |
| 1085 | if (irq_used[i]) |
| 1086 | continue; |
| 1087 | |
| 1088 | if (mp_irqs[i].mp_irqtype != mp_INT) |
| 1089 | continue; |
| 1090 | |
| 1091 | if (mp_irqs[i].mp_irqflag != 0x0f) |
| 1092 | continue; |
| 1093 | |
| 1094 | if (nr_m_spare > 0) { |
| 1095 | printk(KERN_INFO "*NEW* found "); |
| 1096 | nr_m_spare--; |
| 1097 | assign_to_mpc_intsrc(&mp_irqs[i], m_spare[nr_m_spare]); |
| 1098 | m_spare[nr_m_spare] = NULL; |
| 1099 | } else { |
| 1100 | struct mpc_config_intsrc *m = |
| 1101 | (struct mpc_config_intsrc *)mpt; |
| 1102 | count += sizeof(struct mpc_config_intsrc); |
| 1103 | if (!mpc_new_phys) { |
| 1104 | printk(KERN_INFO "No spare slots, try to append...take your risk, new mpc_length %x\n", count); |
| 1105 | } else { |
| 1106 | if (count <= mpc_new_length) |
| 1107 | printk(KERN_INFO "No spare slots, try to append..., new mpc_length %x\n", count); |
| 1108 | else { |
| 1109 | printk(KERN_ERR "mpc_new_length %lx is too small\n", mpc_new_length); |
| 1110 | goto out; |
| 1111 | } |
| 1112 | } |
| 1113 | assign_to_mpc_intsrc(&mp_irqs[i], m); |
| 1114 | mpc->mpc_length = count; |
| 1115 | mpt += sizeof(struct mpc_config_intsrc); |
| 1116 | } |
| 1117 | print_mp_irq_info(&mp_irqs[i]); |
| 1118 | } |
| 1119 | #endif |
| 1120 | out: |
| 1121 | /* update checksum */ |
| 1122 | mpc->mpc_checksum = 0; |
| 1123 | mpc->mpc_checksum -= mpf_checksum((unsigned char *)mpc, |
| 1124 | mpc->mpc_length); |
| 1125 | |
| 1126 | return 0; |
| 1127 | } |
| 1128 | |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 1129 | static int __initdata enable_update_mptable; |
| 1130 | |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 1131 | static int __init update_mptable_setup(char *str) |
| 1132 | { |
| 1133 | enable_update_mptable = 1; |
| 1134 | return 0; |
| 1135 | } |
| 1136 | early_param("update_mptable", update_mptable_setup); |
| 1137 | |
| 1138 | static unsigned long __initdata mpc_new_phys; |
| 1139 | static unsigned long mpc_new_length __initdata = 4096; |
| 1140 | |
| 1141 | /* alloc_mptable or alloc_mptable=4k */ |
| 1142 | static int __initdata alloc_mptable; |
| 1143 | static int __init parse_alloc_mptable_opt(char *p) |
| 1144 | { |
| 1145 | enable_update_mptable = 1; |
| 1146 | alloc_mptable = 1; |
| 1147 | if (!p) |
| 1148 | return 0; |
| 1149 | mpc_new_length = memparse(p, &p); |
| 1150 | return 0; |
| 1151 | } |
| 1152 | early_param("alloc_mptable", parse_alloc_mptable_opt); |
| 1153 | |
| 1154 | void __init early_reserve_e820_mpc_new(void) |
| 1155 | { |
| 1156 | if (enable_update_mptable && alloc_mptable) { |
| 1157 | u64 startt = 0; |
| 1158 | #ifdef CONFIG_X86_TRAMPOLINE |
| 1159 | startt = TRAMPOLINE_BASE; |
| 1160 | #endif |
| 1161 | mpc_new_phys = early_reserve_e820(startt, mpc_new_length, 4); |
| 1162 | } |
| 1163 | } |
| 1164 | |
| 1165 | static int __init update_mp_table(void) |
| 1166 | { |
| 1167 | char str[16]; |
| 1168 | char oem[10]; |
| 1169 | struct intel_mp_floating *mpf; |
| 1170 | struct mp_config_table *mpc; |
| 1171 | struct mp_config_table *mpc_new; |
| 1172 | |
| 1173 | if (!enable_update_mptable) |
| 1174 | return 0; |
| 1175 | |
| 1176 | mpf = mpf_found; |
| 1177 | if (!mpf) |
| 1178 | return 0; |
| 1179 | |
| 1180 | /* |
| 1181 | * Now see if we need to go further. |
| 1182 | */ |
| 1183 | if (mpf->mpf_feature1 != 0) |
| 1184 | return 0; |
| 1185 | |
| 1186 | if (!mpf->mpf_physptr) |
| 1187 | return 0; |
| 1188 | |
| 1189 | mpc = phys_to_virt(mpf->mpf_physptr); |
| 1190 | |
| 1191 | if (!smp_check_mpc(mpc, oem, str)) |
| 1192 | return 0; |
| 1193 | |
| 1194 | printk(KERN_INFO "mpf: %lx\n", virt_to_phys(mpf)); |
| 1195 | printk(KERN_INFO "mpf_physptr: %x\n", mpf->mpf_physptr); |
| 1196 | |
| 1197 | if (mpc_new_phys && mpc->mpc_length > mpc_new_length) { |
| 1198 | mpc_new_phys = 0; |
| 1199 | printk(KERN_INFO "mpc_new_length is %ld, please use alloc_mptable=8k\n", |
| 1200 | mpc_new_length); |
| 1201 | } |
| 1202 | |
| 1203 | if (!mpc_new_phys) { |
| 1204 | unsigned char old, new; |
| 1205 | /* check if we can change the postion */ |
| 1206 | mpc->mpc_checksum = 0; |
| 1207 | old = mpf_checksum((unsigned char *)mpc, mpc->mpc_length); |
| 1208 | mpc->mpc_checksum = 0xff; |
| 1209 | new = mpf_checksum((unsigned char *)mpc, mpc->mpc_length); |
| 1210 | if (old == new) { |
| 1211 | printk(KERN_INFO "mpc is readonly, please try alloc_mptable instead\n"); |
| 1212 | return 0; |
| 1213 | } |
| 1214 | printk(KERN_INFO "use in-positon replacing\n"); |
| 1215 | } else { |
| 1216 | mpf->mpf_physptr = mpc_new_phys; |
| 1217 | mpc_new = phys_to_virt(mpc_new_phys); |
| 1218 | memcpy(mpc_new, mpc, mpc->mpc_length); |
| 1219 | mpc = mpc_new; |
| 1220 | /* check if we can modify that */ |
| 1221 | if (mpc_new_phys - mpf->mpf_physptr) { |
| 1222 | struct intel_mp_floating *mpf_new; |
| 1223 | /* steal 16 bytes from [0, 1k) */ |
| 1224 | printk(KERN_INFO "mpf new: %x\n", 0x400 - 16); |
| 1225 | mpf_new = phys_to_virt(0x400 - 16); |
| 1226 | memcpy(mpf_new, mpf, 16); |
| 1227 | mpf = mpf_new; |
| 1228 | mpf->mpf_physptr = mpc_new_phys; |
| 1229 | } |
| 1230 | mpf->mpf_checksum = 0; |
| 1231 | mpf->mpf_checksum -= mpf_checksum((unsigned char *)mpf, 16); |
| 1232 | printk(KERN_INFO "mpf_physptr new: %x\n", mpf->mpf_physptr); |
| 1233 | } |
| 1234 | |
| 1235 | /* |
| 1236 | * only replace the one with mp_INT and |
| 1237 | * MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, |
| 1238 | * already in mp_irqs , stored by ... and mp_config_acpi_gsi, |
| 1239 | * may need pci=routeirq for all coverage |
| 1240 | */ |
| 1241 | replace_intsrc_all(mpc, mpc_new_phys, mpc_new_length); |
| 1242 | |
| 1243 | return 0; |
| 1244 | } |
| 1245 | |
| 1246 | late_initcall(update_mp_table); |