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