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