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