2 * Intel Multiprocessor Specification 1.1 and 1.4
3 * compliant MP-table parsing routines.
5 * (c) 1995 Alan Cox, Building #3 <alan@redhat.com>
6 * (c) 1998, 1999, 2000 Ingo Molnar <mingo@redhat.com>
9 * Erich Boleyn : MP v1.4 and additional changes.
10 * Alan Cox : Added EBDA scanning
11 * Ingo Molnar : various cleanups and rewrites
12 * Maciej W. Rozycki: Bits for default MP configurations
13 * Paul Diefenbaugh: Added full ACPI support
17 #include <linux/init.h>
18 #include <linux/delay.h>
19 #include <linux/bootmem.h>
20 #include <linux/smp_lock.h>
21 #include <linux/kernel_stat.h>
22 #include <linux/mc146818rtc.h>
23 #include <linux/acpi.h>
24 #include <linux/module.h>
28 #include <asm/mpspec.h>
29 #include <asm/pgalloc.h>
30 #include <asm/io_apic.h>
31 #include <asm/proto.h>
34 /* Have we found an MP table */
36 unsigned int __initdata maxcpus = NR_CPUS;
41 * Various Linux-internal data structures created from the
44 DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
45 int mp_bus_id_to_pci_bus [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 };
47 static int mp_current_pci_id = 0;
48 /* I/O APIC entries */
49 struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
51 /* # of MP IRQ source entries */
52 struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
54 /* MP IRQ source entries */
58 unsigned long mp_lapic_addr = 0;
62 /* Processor that is doing the boot up */
63 unsigned int boot_cpu_id = -1U;
64 /* Internal processor count */
65 unsigned int num_processors __initdata = 0;
67 unsigned disabled_cpus __initdata;
69 /* Bitmask of physically existing CPUs */
70 physid_mask_t phys_cpu_present_map = PHYSID_MASK_NONE;
72 u8 bios_cpu_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };
76 * Intel MP BIOS table parsing routines:
80 * Checksum an MP configuration block.
83 static int __init mpf_checksum(unsigned char *mp, int len)
93 static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
97 char *bootup_cpu = "";
99 if (!(m->mpc_cpuflag & CPU_ENABLED)) {
103 if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
104 bootup_cpu = " (Bootup-CPU)";
105 boot_cpu_id = m->mpc_apicid;
108 printk(KERN_INFO "Processor #%d%s\n", m->mpc_apicid, bootup_cpu);
110 if (num_processors >= NR_CPUS) {
111 printk(KERN_WARNING "WARNING: NR_CPUS limit of %i reached."
112 " Processor ignored.\n", NR_CPUS);
117 cpus_complement(tmp_map, cpu_present_map);
118 cpu = first_cpu(tmp_map);
120 physid_set(m->mpc_apicid, phys_cpu_present_map);
121 if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
123 * bios_cpu_apicid is required to have processors listed
124 * in same order as logical cpu numbers. Hence the first
125 * entry is BSP, and so on.
129 bios_cpu_apicid[cpu] = m->mpc_apicid;
130 x86_cpu_to_apicid[cpu] = m->mpc_apicid;
132 cpu_set(cpu, cpu_possible_map);
133 cpu_set(cpu, cpu_present_map);
136 static void __init MP_bus_info (struct mpc_config_bus *m)
140 memcpy(str, m->mpc_bustype, 6);
142 Dprintk("Bus #%d is %s\n", m->mpc_busid, str);
144 if (strncmp(str, "ISA", 3) == 0) {
145 set_bit(m->mpc_busid, mp_bus_not_pci);
146 } else if (strncmp(str, "PCI", 3) == 0) {
147 clear_bit(m->mpc_busid, mp_bus_not_pci);
148 mp_bus_id_to_pci_bus[m->mpc_busid] = mp_current_pci_id;
151 printk(KERN_ERR "Unknown bustype %s\n", str);
155 static int bad_ioapic(unsigned long address)
157 if (nr_ioapics >= MAX_IO_APICS) {
158 printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
159 "(found %d)\n", MAX_IO_APICS, nr_ioapics);
160 panic("Recompile kernel with bigger MAX_IO_APICS!\n");
163 printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address"
164 " found in table, skipping!\n");
170 static void __init MP_ioapic_info (struct mpc_config_ioapic *m)
172 if (!(m->mpc_flags & MPC_APIC_USABLE))
175 printk("I/O APIC #%d at 0x%X.\n",
176 m->mpc_apicid, m->mpc_apicaddr);
178 if (bad_ioapic(m->mpc_apicaddr))
181 mp_ioapics[nr_ioapics] = *m;
185 static void __init MP_intsrc_info (struct mpc_config_intsrc *m)
187 mp_irqs [mp_irq_entries] = *m;
188 Dprintk("Int: type %d, pol %d, trig %d, bus %d,"
189 " IRQ %02x, APIC ID %x, APIC INT %02x\n",
190 m->mpc_irqtype, m->mpc_irqflag & 3,
191 (m->mpc_irqflag >> 2) & 3, m->mpc_srcbus,
192 m->mpc_srcbusirq, m->mpc_dstapic, m->mpc_dstirq);
193 if (++mp_irq_entries >= MAX_IRQ_SOURCES)
194 panic("Max # of irq sources exceeded!!\n");
197 static void __init MP_lintsrc_info (struct mpc_config_lintsrc *m)
199 Dprintk("Lint: type %d, pol %d, trig %d, bus %d,"
200 " IRQ %02x, APIC ID %x, APIC LINT %02x\n",
201 m->mpc_irqtype, m->mpc_irqflag & 3,
202 (m->mpc_irqflag >> 2) &3, m->mpc_srcbusid,
203 m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint);
210 static int __init smp_read_mpc(struct mp_config_table *mpc)
213 int count=sizeof(*mpc);
214 unsigned char *mpt=((unsigned char *)mpc)+count;
216 if (memcmp(mpc->mpc_signature,MPC_SIGNATURE,4)) {
217 printk("MPTABLE: bad signature [%c%c%c%c]!\n",
218 mpc->mpc_signature[0],
219 mpc->mpc_signature[1],
220 mpc->mpc_signature[2],
221 mpc->mpc_signature[3]);
224 if (mpf_checksum((unsigned char *)mpc,mpc->mpc_length)) {
225 printk("MPTABLE: checksum error!\n");
228 if (mpc->mpc_spec!=0x01 && mpc->mpc_spec!=0x04) {
229 printk(KERN_ERR "MPTABLE: bad table version (%d)!!\n",
233 if (!mpc->mpc_lapic) {
234 printk(KERN_ERR "MPTABLE: null local APIC address!\n");
237 memcpy(str,mpc->mpc_oem,8);
239 printk(KERN_INFO "MPTABLE: OEM ID: %s ",str);
241 memcpy(str,mpc->mpc_productid,12);
243 printk("MPTABLE: Product ID: %s ",str);
245 printk("MPTABLE: APIC at: 0x%X\n",mpc->mpc_lapic);
247 /* save the local APIC address, it might be non-default */
249 mp_lapic_addr = mpc->mpc_lapic;
252 * Now process the configuration blocks.
254 while (count < mpc->mpc_length) {
258 struct mpc_config_processor *m=
259 (struct mpc_config_processor *)mpt;
261 MP_processor_info(m);
268 struct mpc_config_bus *m=
269 (struct mpc_config_bus *)mpt;
277 struct mpc_config_ioapic *m=
278 (struct mpc_config_ioapic *)mpt;
286 struct mpc_config_intsrc *m=
287 (struct mpc_config_intsrc *)mpt;
296 struct mpc_config_lintsrc *m=
297 (struct mpc_config_lintsrc *)mpt;
305 clustered_apic_check();
307 printk(KERN_ERR "MPTABLE: no processors registered!\n");
308 return num_processors;
311 static int __init ELCR_trigger(unsigned int irq)
315 port = 0x4d0 + (irq >> 3);
316 return (inb(port) >> (irq & 7)) & 1;
319 static void __init construct_default_ioirq_mptable(int mpc_default_type)
321 struct mpc_config_intsrc intsrc;
323 int ELCR_fallback = 0;
325 intsrc.mpc_type = MP_INTSRC;
326 intsrc.mpc_irqflag = 0; /* conforming */
327 intsrc.mpc_srcbus = 0;
328 intsrc.mpc_dstapic = mp_ioapics[0].mpc_apicid;
330 intsrc.mpc_irqtype = mp_INT;
333 * If true, we have an ISA/PCI system with no IRQ entries
334 * in the MP table. To prevent the PCI interrupts from being set up
335 * incorrectly, we try to use the ELCR. The sanity check to see if
336 * there is good ELCR data is very simple - IRQ0, 1, 2 and 13 can
337 * never be level sensitive, so we simply see if the ELCR agrees.
338 * If it does, we assume it's valid.
340 if (mpc_default_type == 5) {
341 printk(KERN_INFO "ISA/PCI bus type with no IRQ information... falling back to ELCR\n");
343 if (ELCR_trigger(0) || ELCR_trigger(1) || ELCR_trigger(2) || ELCR_trigger(13))
344 printk(KERN_ERR "ELCR contains invalid data... not using ELCR\n");
346 printk(KERN_INFO "Using ELCR to identify PCI interrupts\n");
351 for (i = 0; i < 16; i++) {
352 switch (mpc_default_type) {
354 if (i == 0 || i == 13)
355 continue; /* IRQ0 & IRQ13 not connected */
359 continue; /* IRQ2 is never connected */
364 * If the ELCR indicates a level-sensitive interrupt, we
365 * copy that information over to the MP table in the
366 * irqflag field (level sensitive, active high polarity).
369 intsrc.mpc_irqflag = 13;
371 intsrc.mpc_irqflag = 0;
374 intsrc.mpc_srcbusirq = i;
375 intsrc.mpc_dstirq = i ? i : 2; /* IRQ0 to INTIN2 */
376 MP_intsrc_info(&intsrc);
379 intsrc.mpc_irqtype = mp_ExtINT;
380 intsrc.mpc_srcbusirq = 0;
381 intsrc.mpc_dstirq = 0; /* 8259A to INTIN0 */
382 MP_intsrc_info(&intsrc);
385 static inline void __init construct_default_ISA_mptable(int mpc_default_type)
387 struct mpc_config_processor processor;
388 struct mpc_config_bus bus;
389 struct mpc_config_ioapic ioapic;
390 struct mpc_config_lintsrc lintsrc;
391 int linttypes[2] = { mp_ExtINT, mp_NMI };
395 * local APIC has default address
397 mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
400 * 2 CPUs, numbered 0 & 1.
402 processor.mpc_type = MP_PROCESSOR;
403 processor.mpc_apicver = 0;
404 processor.mpc_cpuflag = CPU_ENABLED;
405 processor.mpc_cpufeature = 0;
406 processor.mpc_featureflag = 0;
407 processor.mpc_reserved[0] = 0;
408 processor.mpc_reserved[1] = 0;
409 for (i = 0; i < 2; i++) {
410 processor.mpc_apicid = i;
411 MP_processor_info(&processor);
414 bus.mpc_type = MP_BUS;
416 switch (mpc_default_type) {
418 printk(KERN_ERR "???\nUnknown standard configuration %d\n",
423 memcpy(bus.mpc_bustype, "ISA ", 6);
427 if (mpc_default_type > 4) {
429 memcpy(bus.mpc_bustype, "PCI ", 6);
433 ioapic.mpc_type = MP_IOAPIC;
434 ioapic.mpc_apicid = 2;
435 ioapic.mpc_apicver = 0;
436 ioapic.mpc_flags = MPC_APIC_USABLE;
437 ioapic.mpc_apicaddr = 0xFEC00000;
438 MP_ioapic_info(&ioapic);
441 * We set up most of the low 16 IO-APIC pins according to MPS rules.
443 construct_default_ioirq_mptable(mpc_default_type);
445 lintsrc.mpc_type = MP_LINTSRC;
446 lintsrc.mpc_irqflag = 0; /* conforming */
447 lintsrc.mpc_srcbusid = 0;
448 lintsrc.mpc_srcbusirq = 0;
449 lintsrc.mpc_destapic = MP_APIC_ALL;
450 for (i = 0; i < 2; i++) {
451 lintsrc.mpc_irqtype = linttypes[i];
452 lintsrc.mpc_destapiclint = i;
453 MP_lintsrc_info(&lintsrc);
457 static struct intel_mp_floating *mpf_found;
460 * Scan the memory blocks for an SMP configuration block.
462 void __init get_smp_config (void)
464 struct intel_mp_floating *mpf = mpf_found;
467 * ACPI supports both logical (e.g. Hyper-Threading) and physical
468 * processors, where MPS only supports physical.
470 if (acpi_lapic && acpi_ioapic) {
471 printk(KERN_INFO "Using ACPI (MADT) for SMP configuration information\n");
475 printk(KERN_INFO "Using ACPI for processor (LAPIC) configuration information\n");
477 printk("Intel MultiProcessor Specification v1.%d\n", mpf->mpf_specification);
480 * Now see if we need to read further.
482 if (mpf->mpf_feature1 != 0) {
484 printk(KERN_INFO "Default MP configuration #%d\n", mpf->mpf_feature1);
485 construct_default_ISA_mptable(mpf->mpf_feature1);
487 } else if (mpf->mpf_physptr) {
490 * Read the physical hardware table. Anything here will
491 * override the defaults.
493 if (!smp_read_mpc(phys_to_virt(mpf->mpf_physptr))) {
494 smp_found_config = 0;
495 printk(KERN_ERR "BIOS bug, MP table errors detected!...\n");
496 printk(KERN_ERR "... disabling SMP support. (tell your hw vendor)\n");
500 * If there are no explicit MP IRQ entries, then we are
501 * broken. We set up most of the low 16 IO-APIC pins to
502 * ISA defaults and hope it will work.
504 if (!mp_irq_entries) {
505 struct mpc_config_bus bus;
507 printk(KERN_ERR "BIOS bug, no explicit IRQ entries, using default mptable. (tell your hw vendor)\n");
509 bus.mpc_type = MP_BUS;
511 memcpy(bus.mpc_bustype, "ISA ", 6);
514 construct_default_ioirq_mptable(0);
520 printk(KERN_INFO "Processors: %d\n", num_processors);
522 * Only use the first configuration found.
526 static int __init smp_scan_config (unsigned long base, unsigned long length)
528 extern void __bad_mpf_size(void);
529 unsigned int *bp = phys_to_virt(base);
530 struct intel_mp_floating *mpf;
532 Dprintk("Scan SMP from %p for %ld bytes.\n", bp,length);
533 if (sizeof(*mpf) != 16)
537 mpf = (struct intel_mp_floating *)bp;
538 if ((*bp == SMP_MAGIC_IDENT) &&
539 (mpf->mpf_length == 1) &&
540 !mpf_checksum((unsigned char *)bp, 16) &&
541 ((mpf->mpf_specification == 1)
542 || (mpf->mpf_specification == 4)) ) {
544 smp_found_config = 1;
545 reserve_bootmem_generic(virt_to_phys(mpf), PAGE_SIZE);
546 if (mpf->mpf_physptr)
547 reserve_bootmem_generic(mpf->mpf_physptr, PAGE_SIZE);
557 void __init find_smp_config(void)
559 unsigned int address;
562 * FIXME: Linux assumes you have 640K of base ram..
563 * this continues the error...
565 * 1) Scan the bottom 1K for a signature
566 * 2) Scan the top 1K of base RAM
567 * 3) Scan the 64K of bios
569 if (smp_scan_config(0x0,0x400) ||
570 smp_scan_config(639*0x400,0x400) ||
571 smp_scan_config(0xF0000,0x10000))
574 * If it is an SMP machine we should know now.
576 * there is a real-mode segmented pointer pointing to the
577 * 4K EBDA area at 0x40E, calculate and scan it here.
579 * NOTE! There are Linux loaders that will corrupt the EBDA
580 * area, and as such this kind of SMP config may be less
581 * trustworthy, simply because the SMP table may have been
582 * stomped on during early boot. These loaders are buggy and
586 address = *(unsigned short *)phys_to_virt(0x40E);
588 if (smp_scan_config(address, 0x1000))
591 /* If we have come this far, we did not find an MP table */
592 printk(KERN_INFO "No mptable found.\n");
595 /* --------------------------------------------------------------------------
596 ACPI-based MP Configuration
597 -------------------------------------------------------------------------- */
601 void __init mp_register_lapic_address(u64 address)
603 mp_lapic_addr = (unsigned long) address;
604 set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr);
605 if (boot_cpu_id == -1U)
606 boot_cpu_id = GET_APIC_ID(apic_read(APIC_ID));
609 void __cpuinit mp_register_lapic (u8 id, u8 enabled)
611 struct mpc_config_processor processor;
614 if (id == boot_cpu_id)
617 processor.mpc_type = MP_PROCESSOR;
618 processor.mpc_apicid = id;
619 processor.mpc_apicver = 0;
620 processor.mpc_cpuflag = (enabled ? CPU_ENABLED : 0);
621 processor.mpc_cpuflag |= (boot_cpu ? CPU_BOOTPROCESSOR : 0);
622 processor.mpc_cpufeature = 0;
623 processor.mpc_featureflag = 0;
624 processor.mpc_reserved[0] = 0;
625 processor.mpc_reserved[1] = 0;
627 MP_processor_info(&processor);
631 #define MP_MAX_IOAPIC_PIN 127
633 static struct mp_ioapic_routing {
637 u32 pin_programmed[4];
638 } mp_ioapic_routing[MAX_IO_APICS];
640 static int mp_find_ioapic(int gsi)
644 /* Find the IOAPIC that manages this GSI. */
645 for (i = 0; i < nr_ioapics; i++) {
646 if ((gsi >= mp_ioapic_routing[i].gsi_start)
647 && (gsi <= mp_ioapic_routing[i].gsi_end))
651 printk(KERN_ERR "ERROR: Unable to locate IOAPIC for GSI %d\n", gsi);
655 void __init mp_register_ioapic(u8 id, u32 address, u32 gsi_base)
659 if (bad_ioapic(address))
664 mp_ioapics[idx].mpc_type = MP_IOAPIC;
665 mp_ioapics[idx].mpc_flags = MPC_APIC_USABLE;
666 mp_ioapics[idx].mpc_apicaddr = address;
668 set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
669 mp_ioapics[idx].mpc_apicid = id;
670 mp_ioapics[idx].mpc_apicver = 0;
673 * Build basic IRQ lookup table to facilitate gsi->io_apic lookups
674 * and to prevent reprogramming of IOAPIC pins (PCI IRQs).
676 mp_ioapic_routing[idx].apic_id = mp_ioapics[idx].mpc_apicid;
677 mp_ioapic_routing[idx].gsi_start = gsi_base;
678 mp_ioapic_routing[idx].gsi_end = gsi_base +
679 io_apic_get_redir_entries(idx);
681 printk(KERN_INFO "IOAPIC[%d]: apic_id %d, address 0x%x, "
682 "GSI %d-%d\n", idx, mp_ioapics[idx].mpc_apicid,
683 mp_ioapics[idx].mpc_apicaddr,
684 mp_ioapic_routing[idx].gsi_start,
685 mp_ioapic_routing[idx].gsi_end);
689 mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
691 struct mpc_config_intsrc intsrc;
696 * Convert 'gsi' to 'ioapic.pin'.
698 ioapic = mp_find_ioapic(gsi);
701 pin = gsi - mp_ioapic_routing[ioapic].gsi_start;
704 * TBD: This check is for faulty timer entries, where the override
705 * erroneously sets the trigger to level, resulting in a HUGE
706 * increase of timer interrupts!
708 if ((bus_irq == 0) && (trigger == 3))
711 intsrc.mpc_type = MP_INTSRC;
712 intsrc.mpc_irqtype = mp_INT;
713 intsrc.mpc_irqflag = (trigger << 2) | polarity;
714 intsrc.mpc_srcbus = MP_ISA_BUS;
715 intsrc.mpc_srcbusirq = bus_irq; /* IRQ */
716 intsrc.mpc_dstapic = mp_ioapics[ioapic].mpc_apicid; /* APIC ID */
717 intsrc.mpc_dstirq = pin; /* INTIN# */
719 Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, %d-%d\n",
720 intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3,
721 (intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus,
722 intsrc.mpc_srcbusirq, intsrc.mpc_dstapic, intsrc.mpc_dstirq);
724 mp_irqs[mp_irq_entries] = intsrc;
725 if (++mp_irq_entries == MAX_IRQ_SOURCES)
726 panic("Max # of irq sources exceeded!\n");
729 void __init mp_config_acpi_legacy_irqs(void)
731 struct mpc_config_intsrc intsrc;
736 * Fabricate the legacy ISA bus (bus #31).
738 set_bit(MP_ISA_BUS, mp_bus_not_pci);
741 * Locate the IOAPIC that manages the ISA IRQs (0-15).
743 ioapic = mp_find_ioapic(0);
747 intsrc.mpc_type = MP_INTSRC;
748 intsrc.mpc_irqflag = 0; /* Conforming */
749 intsrc.mpc_srcbus = MP_ISA_BUS;
750 intsrc.mpc_dstapic = mp_ioapics[ioapic].mpc_apicid;
753 * Use the default configuration for the IRQs 0-15. Unless
754 * overridden by (MADT) interrupt source override entries.
756 for (i = 0; i < 16; i++) {
759 for (idx = 0; idx < mp_irq_entries; idx++) {
760 struct mpc_config_intsrc *irq = mp_irqs + idx;
762 /* Do we already have a mapping for this ISA IRQ? */
763 if (irq->mpc_srcbus == MP_ISA_BUS && irq->mpc_srcbusirq == i)
766 /* Do we already have a mapping for this IOAPIC pin */
767 if ((irq->mpc_dstapic == intsrc.mpc_dstapic) &&
768 (irq->mpc_dstirq == i))
772 if (idx != mp_irq_entries) {
773 printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i);
774 continue; /* IRQ already used */
777 intsrc.mpc_irqtype = mp_INT;
778 intsrc.mpc_srcbusirq = i; /* Identity mapped */
779 intsrc.mpc_dstirq = i;
781 Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, "
782 "%d-%d\n", intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3,
783 (intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus,
784 intsrc.mpc_srcbusirq, intsrc.mpc_dstapic,
787 mp_irqs[mp_irq_entries] = intsrc;
788 if (++mp_irq_entries == MAX_IRQ_SOURCES)
789 panic("Max # of irq sources exceeded!\n");
793 #define MAX_GSI_NUM 4096
795 int mp_register_gsi(u32 gsi, int triggering, int polarity)
800 static int pci_irq = 16;
802 * Mapping between Global System Interrupts, which
803 * represent all possible interrupts, to the IRQs
804 * assigned to actual devices.
806 static int gsi_to_irq[MAX_GSI_NUM];
808 if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
811 /* Don't set up the ACPI SCI because it's already set up */
812 if (acpi_fadt.sci_int == gsi)
815 ioapic = mp_find_ioapic(gsi);
817 printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi);
821 ioapic_pin = gsi - mp_ioapic_routing[ioapic].gsi_start;
824 * Avoid pin reprogramming. PRTs typically include entries
825 * with redundant pin->gsi mappings (but unique PCI devices);
826 * we only program the IOAPIC on the first.
828 bit = ioapic_pin % 32;
829 idx = (ioapic_pin < 32) ? 0 : (ioapic_pin / 32);
831 printk(KERN_ERR "Invalid reference to IOAPIC pin "
832 "%d-%d\n", mp_ioapic_routing[ioapic].apic_id,
836 if ((1<<bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) {
837 Dprintk(KERN_DEBUG "Pin %d-%d already programmed\n",
838 mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
839 return gsi_to_irq[gsi];
842 mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit);
844 if (triggering == ACPI_LEVEL_SENSITIVE) {
846 * For PCI devices assign IRQs in order, avoiding gaps
847 * due to unused I/O APIC pins.
850 if (gsi < MAX_GSI_NUM) {
852 * Retain the VIA chipset work-around (gsi > 15), but
853 * avoid a problem where the 8254 timer (IRQ0) is setup
854 * via an override (so it's not on pin 0 of the ioapic),
855 * and at the same time, the pin 0 interrupt is a PCI
856 * type. The gsi > 15 test could cause these two pins
857 * to be shared as IRQ0, and they are not shareable.
858 * So test for this condition, and if necessary, avoid
861 if (gsi > 15 || (gsi == 0 && !timer_uses_ioapic_pin_0))
864 * Don't assign IRQ used by ACPI SCI
866 if (gsi == acpi_fadt.sci_int)
868 gsi_to_irq[irq] = gsi;
870 printk(KERN_ERR "GSI %u is too high\n", gsi);
875 io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
876 triggering == ACPI_EDGE_SENSITIVE ? 0 : 1,
877 polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
880 #endif /*CONFIG_ACPI*/