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