x86, acpi/irq: Fix acpi_sci_ioapic_setup so it has both bus_irq and gsi
[safe/jmp/linux-2.6] / arch / x86 / kernel / acpi / boot.c
index ff1a7b4..0a036dc 100644 (file)
 #include <linux/module.h>
 #include <linux/dmi.h>
 #include <linux/irq.h>
+#include <linux/slab.h>
 #include <linux/bootmem.h>
 #include <linux/ioport.h>
+#include <linux/pci.h>
 
+#include <asm/pci_x86.h>
 #include <asm/pgtable.h>
 #include <asm/io_apic.h>
 #include <asm/apic.h>
 #include <asm/mpspec.h>
 #include <asm/smp.h>
 
-#ifdef CONFIG_X86_LOCAL_APIC
-# include <mach_apic.h>
-#endif
-
 static int __initdata acpi_force = 0;
-
-#ifdef CONFIG_ACPI
-int acpi_disabled = 0;
-#else
-int acpi_disabled = 1;
-#endif
+u32 acpi_rsdt_forced;
+int acpi_disabled;
 EXPORT_SYMBOL(acpi_disabled);
 
 #ifdef CONFIG_X86_64
-
-#include <asm/proto.h>
-#include <asm/genapic.h>
-
-#else                          /* X86 */
-
-#ifdef CONFIG_X86_LOCAL_APIC
-#include <mach_apic.h>
-#include <mach_mpparse.h>
-#endif                         /* CONFIG_X86_LOCAL_APIC */
-
+# include <asm/proto.h>
+# include <asm/numa_64.h>
 #endif                         /* X86 */
 
 #define BAD_MADT_ENTRY(entry, end) (                                       \
@@ -106,21 +92,6 @@ static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
  */
 enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
 
-#ifdef CONFIG_X86_64
-
-/* rely on all ACPI tables being in the direct mapping */
-char *__init __acpi_map_table(unsigned long phys_addr, unsigned long size)
-{
-       if (!phys_addr || !size)
-               return NULL;
-
-       if (phys_addr+size <= (max_pfn_mapped << PAGE_SHIFT) + PAGE_SIZE)
-               return __va(phys_addr);
-
-       return NULL;
-}
-
-#else
 
 /*
  * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
@@ -136,83 +107,19 @@ char *__init __acpi_map_table(unsigned long phys_addr, unsigned long size)
  */
 char *__init __acpi_map_table(unsigned long phys, unsigned long size)
 {
-       unsigned long base, offset, mapped_size;
-       int idx;
-
-       if (phys + size < 8 * 1024 * 1024)
-               return __va(phys);
 
-       offset = phys & (PAGE_SIZE - 1);
-       mapped_size = PAGE_SIZE - offset;
-       set_fixmap(FIX_ACPI_END, phys);
-       base = fix_to_virt(FIX_ACPI_END);
-
-       /*
-        * Most cases can be covered by the below.
-        */
-       idx = FIX_ACPI_END;
-       while (mapped_size < size) {
-               if (--idx < FIX_ACPI_BEGIN)
-                       return NULL;    /* cannot handle this */
-               phys += PAGE_SIZE;
-               set_fixmap(idx, phys);
-               mapped_size += PAGE_SIZE;
-       }
+       if (!phys || !size)
+               return NULL;
 
-       return ((unsigned char *)base + offset);
+       return early_ioremap(phys, size);
 }
-#endif
-
-#ifdef CONFIG_PCI_MMCONFIG
-/* The physical address of the MMCONFIG aperture.  Set from ACPI tables. */
-struct acpi_mcfg_allocation *pci_mmcfg_config;
-int pci_mmcfg_config_num;
-
-int __init acpi_parse_mcfg(struct acpi_table_header *header)
+void __init __acpi_unmap_table(char *map, unsigned long size)
 {
-       struct acpi_table_mcfg *mcfg;
-       unsigned long i;
-       int config_size;
-
-       if (!header)
-               return -EINVAL;
-
-       mcfg = (struct acpi_table_mcfg *)header;
-
-       /* how many config structures do we have */
-       pci_mmcfg_config_num = 0;
-       i = header->length - sizeof(struct acpi_table_mcfg);
-       while (i >= sizeof(struct acpi_mcfg_allocation)) {
-               ++pci_mmcfg_config_num;
-               i -= sizeof(struct acpi_mcfg_allocation);
-       };
-       if (pci_mmcfg_config_num == 0) {
-               printk(KERN_ERR PREFIX "MMCONFIG has no entries\n");
-               return -ENODEV;
-       }
-
-       config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config);
-       pci_mmcfg_config = kmalloc(config_size, GFP_KERNEL);
-       if (!pci_mmcfg_config) {
-               printk(KERN_WARNING PREFIX
-                      "No memory for MCFG config tables\n");
-               return -ENOMEM;
-       }
-
-       memcpy(pci_mmcfg_config, &mcfg[1], config_size);
-       for (i = 0; i < pci_mmcfg_config_num; ++i) {
-               if (pci_mmcfg_config[i].address > 0xFFFFFFFF) {
-                       printk(KERN_ERR PREFIX
-                              "MMCONFIG not in low 4GB of memory\n");
-                       kfree(pci_mmcfg_config);
-                       pci_mmcfg_config_num = 0;
-                       return -ENODEV;
-               }
-       }
+       if (!map || !size)
+               return;
 
-       return 0;
+       early_iounmap(map, size);
 }
-#endif                         /* CONFIG_PCI_MMCONFIG */
 
 #ifdef CONFIG_X86_LOCAL_APIC
 static int __init acpi_parse_madt(struct acpi_table_header *table)
@@ -235,7 +142,8 @@ static int __init acpi_parse_madt(struct acpi_table_header *table)
                       madt->address);
        }
 
-       acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
+       default_acpi_madt_oem_check(madt->header.oem_id,
+                                   madt->header.oem_table_id);
 
        return 0;
 }
@@ -249,15 +157,42 @@ static void __cpuinit acpi_register_lapic(int id, u8 enabled)
                return;
        }
 
-#ifdef CONFIG_X86_32
        if (boot_cpu_physical_apicid != -1U)
                ver = apic_version[boot_cpu_physical_apicid];
-#endif
 
        generic_processor_info(id, ver);
 }
 
 static int __init
+acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
+{
+       struct acpi_madt_local_x2apic *processor = NULL;
+
+       processor = (struct acpi_madt_local_x2apic *)header;
+
+       if (BAD_MADT_ENTRY(processor, end))
+               return -EINVAL;
+
+       acpi_table_print_madt_entry(header);
+
+#ifdef CONFIG_X86_X2APIC
+       /*
+        * We need to register disabled CPU as well to permit
+        * counting disabled CPUs. This allows us to size
+        * cpus_possible_map more accurately, to permit
+        * to not preallocating memory for all NR_CPUS
+        * when we use CPU hotplug.
+        */
+       acpi_register_lapic(processor->local_apic_id,   /* APIC ID */
+                           processor->lapic_flags & ACPI_MADT_ENABLED);
+#else
+       printk(KERN_WARNING PREFIX "x2apic entry ignored\n");
+#endif
+
+       return 0;
+}
+
+static int __init
 acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
 {
        struct acpi_madt_local_apic *processor = NULL;
@@ -317,6 +252,25 @@ acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
 }
 
 static int __init
+acpi_parse_x2apic_nmi(struct acpi_subtable_header *header,
+                     const unsigned long end)
+{
+       struct acpi_madt_local_x2apic_nmi *x2apic_nmi = NULL;
+
+       x2apic_nmi = (struct acpi_madt_local_x2apic_nmi *)header;
+
+       if (BAD_MADT_ENTRY(x2apic_nmi, end))
+               return -EINVAL;
+
+       acpi_table_print_madt_entry(header);
+
+       if (x2apic_nmi->lint != 1)
+               printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
+
+       return 0;
+}
+
+static int __init
 acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end)
 {
        struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
@@ -338,8 +292,6 @@ acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long e
 
 #ifdef CONFIG_X86_IO_APIC
 
-struct mp_ioapic_routing mp_ioapic_routing[MAX_IO_APICS];
-
 static int __init
 acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
 {
@@ -361,7 +313,7 @@ acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
 /*
  * Parse Interrupt Source Override for the ACPI SCI
  */
-static void __init acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
+static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger, u32 gsi)
 {
        if (trigger == 0)       /* compatible SCI trigger is level */
                trigger = 3;
@@ -381,7 +333,7 @@ static void __init acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
         * If GSI is < 16, this will update its flags,
         * else it will create a new mp_irqs[] entry.
         */
-       mp_override_legacy_irq(gsi, polarity, trigger, gsi);
+       mp_override_legacy_irq(bus_irq, polarity, trigger, gsi);
 
        /*
         * stash over-ride to indicate we've been here
@@ -405,9 +357,10 @@ acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
        acpi_table_print_madt_entry(header);
 
        if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
-               acpi_sci_ioapic_setup(intsrc->global_irq,
+               acpi_sci_ioapic_setup(intsrc->source_irq,
                                      intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
-                                     (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2);
+                                     (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
+                                     intsrc->global_irq);
                return 0;
        }
 
@@ -497,6 +450,20 @@ void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
 int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
 {
        *irq = gsi;
+
+#ifdef CONFIG_X86_IO_APIC
+       if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC)
+               setup_IO_APIC_irq_extra(gsi);
+#endif
+
+       return 0;
+}
+
+int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi)
+{
+       if (isa_irq >= 16)
+               return -1;
+       *gsi = isa_irq;
        return 0;
 }
 
@@ -504,7 +471,7 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
  * success: return IRQ number (>=0)
  * failure: return < 0
  */
-int acpi_register_gsi(u32 gsi, int triggering, int polarity)
+int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
 {
        unsigned int irq;
        unsigned int plat_gsi = gsi;
@@ -514,17 +481,18 @@ int acpi_register_gsi(u32 gsi, int triggering, int polarity)
         * Make sure all (legacy) PCI IRQs are set as level-triggered.
         */
        if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
-               if (triggering == ACPI_LEVEL_SENSITIVE)
+               if (trigger == ACPI_LEVEL_SENSITIVE)
                        eisa_set_level_irq(gsi);
        }
 #endif
 
 #ifdef CONFIG_X86_IO_APIC
        if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
-               plat_gsi = mp_register_gsi(gsi, triggering, polarity);
+               plat_gsi = mp_register_gsi(dev, gsi, trigger, polarity);
        }
 #endif
-       acpi_gsi_to_irq(plat_gsi, &irq);
+       irq = plat_gsi;
+
        return irq;
 }
 
@@ -532,15 +500,36 @@ int acpi_register_gsi(u32 gsi, int triggering, int polarity)
  *  ACPI based hotplug support for CPU
  */
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
+#include <acpi/processor.h>
+
+static void acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
+{
+#ifdef CONFIG_ACPI_NUMA
+       int nid;
+
+       nid = acpi_get_node(handle);
+       if (nid == -1 || !node_online(nid))
+               return;
+#ifdef CONFIG_X86_64
+       apicid_to_node[physid] = nid;
+       numa_set_node(cpu, nid);
+#else /* CONFIG_X86_32 */
+       apicid_2_node[physid] = nid;
+       cpu_to_node_map[cpu] = nid;
+#endif
+
+#endif
+}
 
 static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
 {
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        union acpi_object *obj;
        struct acpi_madt_local_apic *lapic;
-       cpumask_t tmp_map, new_map;
+       cpumask_var_t tmp_map, new_map;
        u8 physid;
        int cpu;
+       int retval = -ENOMEM;
 
        if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
                return -EINVAL;
@@ -569,23 +558,40 @@ static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
        buffer.length = ACPI_ALLOCATE_BUFFER;
        buffer.pointer = NULL;
 
-       tmp_map = cpu_present_map;
+       if (!alloc_cpumask_var(&tmp_map, GFP_KERNEL))
+               goto out;
+
+       if (!alloc_cpumask_var(&new_map, GFP_KERNEL))
+               goto free_tmp_map;
+
+       cpumask_copy(tmp_map, cpu_present_mask);
        acpi_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED);
 
        /*
         * If mp_register_lapic successfully generates a new logical cpu
         * number, then the following will get us exactly what was mapped
         */
-       cpus_andnot(new_map, cpu_present_map, tmp_map);
-       if (cpus_empty(new_map)) {
+       cpumask_andnot(new_map, cpu_present_mask, tmp_map);
+       if (cpumask_empty(new_map)) {
                printk ("Unable to map lapic to logical cpu number\n");
-               return -EINVAL;
+               retval = -EINVAL;
+               goto free_new_map;
        }
 
-       cpu = first_cpu(new_map);
+       acpi_processor_set_pdc(handle);
+
+       cpu = cpumask_first(new_map);
+       acpi_map_cpu2node(handle, cpu, physid);
 
        *pcpu = cpu;
-       return 0;
+       retval = 0;
+
+free_new_map:
+       free_cpumask_var(new_map);
+free_tmp_map:
+       free_cpumask_var(tmp_map);
+out:
+       return retval;
 }
 
 /* wrapper to silence section mismatch warning */
@@ -598,7 +604,7 @@ EXPORT_SYMBOL(acpi_map_lsapic);
 int acpi_unmap_lsapic(int cpu)
 {
        per_cpu(x86_cpu_to_apicid, cpu) = -1;
-       cpu_clear(cpu, cpu_present_map);
+       set_cpu_present(cpu, false);
        num_processors--;
 
        return (0);
@@ -660,6 +666,7 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table)
        }
 
        hpet_address = hpet_tbl->address.address;
+       hpet_blockid = hpet_tbl->sequence;
 
        /*
         * Some broken BIOSes advertise HPET at 0x0. We really do not
@@ -773,11 +780,9 @@ static void __init acpi_register_lapic_address(unsigned long address)
 
        set_fixmap_nocache(FIX_APIC_BASE, address);
        if (boot_cpu_physical_apicid == -1U) {
-               boot_cpu_physical_apicid  = GET_APIC_ID(read_apic_id());
-#ifdef CONFIG_X86_32
+               boot_cpu_physical_apicid  = read_apic_id();
                apic_version[boot_cpu_physical_apicid] =
                         GET_APIC_VERSION(apic_read(APIC_LVR));
-#endif
        }
 }
 
@@ -810,6 +815,7 @@ static int __init early_acpi_parse_madt_lapic_addr_ovr(void)
 static int __init acpi_parse_madt_lapic_entries(void)
 {
        int count;
+       int x2count = 0;
 
        if (!cpu_has_apic)
                return -ENODEV;
@@ -833,22 +839,28 @@ static int __init acpi_parse_madt_lapic_entries(void)
        count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
                                      acpi_parse_sapic, MAX_APICS);
 
-       if (!count)
+       if (!count) {
+               x2count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC,
+                                               acpi_parse_x2apic, MAX_APICS);
                count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC,
                                              acpi_parse_lapic, MAX_APICS);
-       if (!count) {
+       }
+       if (!count && !x2count) {
                printk(KERN_ERR PREFIX "No LAPIC entries present\n");
                /* TBD: Cleanup to allow fallback to MPS */
                return -ENODEV;
-       } else if (count < 0) {
+       } else if (count < 0 || x2count < 0) {
                printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
                /* TBD: Cleanup to allow fallback to MPS */
                return count;
        }
 
+       x2count =
+           acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC_NMI,
+                                 acpi_parse_x2apic_nmi, 0);
        count =
            acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0);
-       if (count < 0) {
+       if (count < 0 || x2count < 0) {
                printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
                /* TBD: Cleanup to allow fallback to MPS */
                return count;
@@ -858,6 +870,244 @@ static int __init acpi_parse_madt_lapic_entries(void)
 #endif                         /* CONFIG_X86_LOCAL_APIC */
 
 #ifdef CONFIG_X86_IO_APIC
+#define MP_ISA_BUS             0
+
+#ifdef CONFIG_X86_ES7000
+extern int es7000_plat;
+#endif
+
+int __init acpi_probe_gsi(void)
+{
+       int idx;
+       int gsi;
+       int max_gsi = 0;
+
+       if (acpi_disabled)
+               return 0;
+
+       if (!acpi_ioapic)
+               return 0;
+
+       max_gsi = 0;
+       for (idx = 0; idx < nr_ioapics; idx++) {
+               gsi = mp_gsi_routing[idx].gsi_end;
+
+               if (gsi > max_gsi)
+                       max_gsi = gsi;
+       }
+
+       return max_gsi + 1;
+}
+
+static void assign_to_mp_irq(struct mpc_intsrc *m,
+                                   struct mpc_intsrc *mp_irq)
+{
+       memcpy(mp_irq, m, sizeof(struct mpc_intsrc));
+}
+
+static int mp_irq_cmp(struct mpc_intsrc *mp_irq,
+                               struct mpc_intsrc *m)
+{
+       return memcmp(mp_irq, m, sizeof(struct mpc_intsrc));
+}
+
+static void save_mp_irq(struct mpc_intsrc *m)
+{
+       int i;
+
+       for (i = 0; i < mp_irq_entries; i++) {
+               if (!mp_irq_cmp(&mp_irqs[i], m))
+                       return;
+       }
+
+       assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]);
+       if (++mp_irq_entries == MAX_IRQ_SOURCES)
+               panic("Max # of irq sources exceeded!!\n");
+}
+
+void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
+{
+       int ioapic;
+       int pin;
+       struct mpc_intsrc mp_irq;
+
+       /*
+        * Convert 'gsi' to 'ioapic.pin'.
+        */
+       ioapic = mp_find_ioapic(gsi);
+       if (ioapic < 0)
+               return;
+       pin = mp_find_ioapic_pin(ioapic, gsi);
+
+       /*
+        * TBD: This check is for faulty timer entries, where the override
+        *      erroneously sets the trigger to level, resulting in a HUGE
+        *      increase of timer interrupts!
+        */
+       if ((bus_irq == 0) && (trigger == 3))
+               trigger = 1;
+
+       mp_irq.type = MP_INTSRC;
+       mp_irq.irqtype = mp_INT;
+       mp_irq.irqflag = (trigger << 2) | polarity;
+       mp_irq.srcbus = MP_ISA_BUS;
+       mp_irq.srcbusirq = bus_irq;     /* IRQ */
+       mp_irq.dstapic = mp_ioapics[ioapic].apicid; /* APIC ID */
+       mp_irq.dstirq = pin;    /* INTIN# */
+
+       save_mp_irq(&mp_irq);
+}
+
+void __init mp_config_acpi_legacy_irqs(void)
+{
+       int i;
+       int ioapic;
+       unsigned int dstapic;
+       struct mpc_intsrc mp_irq;
+
+#if defined (CONFIG_MCA) || defined (CONFIG_EISA)
+       /*
+        * Fabricate the legacy ISA bus (bus #31).
+        */
+       mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
+#endif
+       set_bit(MP_ISA_BUS, mp_bus_not_pci);
+       pr_debug("Bus #%d is ISA\n", MP_ISA_BUS);
+
+#ifdef CONFIG_X86_ES7000
+       /*
+        * Older generations of ES7000 have no legacy identity mappings
+        */
+       if (es7000_plat == 1)
+               return;
+#endif
+
+       /*
+        * Locate the IOAPIC that manages the ISA IRQs (0-15).
+        */
+       ioapic = mp_find_ioapic(0);
+       if (ioapic < 0)
+               return;
+       dstapic = mp_ioapics[ioapic].apicid;
+
+       /*
+        * Use the default configuration for the IRQs 0-15.  Unless
+        * overridden by (MADT) interrupt source override entries.
+        */
+       for (i = 0; i < 16; i++) {
+               int idx;
+
+               for (idx = 0; idx < mp_irq_entries; idx++) {
+                       struct mpc_intsrc *irq = mp_irqs + idx;
+
+                       /* Do we already have a mapping for this ISA IRQ? */
+                       if (irq->srcbus == MP_ISA_BUS && irq->srcbusirq == i)
+                               break;
+
+                       /* Do we already have a mapping for this IOAPIC pin */
+                       if (irq->dstapic == dstapic && irq->dstirq == i)
+                               break;
+               }
+
+               if (idx != mp_irq_entries) {
+                       printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i);
+                       continue;       /* IRQ already used */
+               }
+
+               mp_irq.type = MP_INTSRC;
+               mp_irq.irqflag = 0;     /* Conforming */
+               mp_irq.srcbus = MP_ISA_BUS;
+               mp_irq.dstapic = dstapic;
+               mp_irq.irqtype = mp_INT;
+               mp_irq.srcbusirq = i; /* Identity mapped */
+               mp_irq.dstirq = i;
+
+               save_mp_irq(&mp_irq);
+       }
+}
+
+static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
+                       int polarity)
+{
+#ifdef CONFIG_X86_MPPARSE
+       struct mpc_intsrc mp_irq;
+       struct pci_dev *pdev;
+       unsigned char number;
+       unsigned int devfn;
+       int ioapic;
+       u8 pin;
+
+       if (!acpi_ioapic)
+               return 0;
+       if (!dev)
+               return 0;
+       if (dev->bus != &pci_bus_type)
+               return 0;
+
+       pdev = to_pci_dev(dev);
+       number = pdev->bus->number;
+       devfn = pdev->devfn;
+       pin = pdev->pin;
+       /* print the entry should happen on mptable identically */
+       mp_irq.type = MP_INTSRC;
+       mp_irq.irqtype = mp_INT;
+       mp_irq.irqflag = (trigger == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
+                               (polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
+       mp_irq.srcbus = number;
+       mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
+       ioapic = mp_find_ioapic(gsi);
+       mp_irq.dstapic = mp_ioapics[ioapic].apicid;
+       mp_irq.dstirq = mp_find_ioapic_pin(ioapic, gsi);
+
+       save_mp_irq(&mp_irq);
+#endif
+       return 0;
+}
+
+int mp_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
+{
+       int ioapic;
+       int ioapic_pin;
+       struct io_apic_irq_attr irq_attr;
+
+       if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
+               return gsi;
+
+       /* Don't set up the ACPI SCI because it's already set up */
+       if (acpi_gbl_FADT.sci_interrupt == gsi)
+               return gsi;
+
+       ioapic = mp_find_ioapic(gsi);
+       if (ioapic < 0) {
+               printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi);
+               return gsi;
+       }
+
+       ioapic_pin = mp_find_ioapic_pin(ioapic, gsi);
+
+#ifdef CONFIG_X86_32
+       if (ioapic_renumber_irq)
+               gsi = ioapic_renumber_irq(ioapic, gsi);
+#endif
+
+       if (ioapic_pin > MP_MAX_IOAPIC_PIN) {
+               printk(KERN_ERR "Invalid reference to IOAPIC pin "
+                      "%d-%d\n", mp_ioapics[ioapic].apicid,
+                      ioapic_pin);
+               return gsi;
+       }
+
+       if (enable_update_mptable)
+               mp_config_acpi_gsi(dev, gsi, trigger, polarity);
+
+       set_io_apic_irq_attr(&irq_attr, ioapic, ioapic_pin,
+                            trigger == ACPI_EDGE_SENSITIVE ? 0 : 1,
+                            polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
+       io_apic_set_pci_routing(dev, gsi, &irq_attr);
+
+       return gsi;
+}
+
 /*
  * Parse IOAPIC related entries in MADT
  * returns 0 on success, < 0 on error
@@ -872,9 +1122,8 @@ static int __init acpi_parse_madt_ioapic_entries(void)
         * If MPS is present, it will handle them,
         * otherwise the system will stay in PIC mode
         */
-       if (acpi_disabled || acpi_noirq) {
+       if (acpi_disabled || acpi_noirq)
                return -ENODEV;
-       }
 
        if (!cpu_has_apic)
                return -ENODEV;
@@ -901,7 +1150,7 @@ static int __init acpi_parse_madt_ioapic_entries(void)
 
        count =
            acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, acpi_parse_int_src_ovr,
-                                 NR_IRQ_VECTORS);
+                                 nr_irqs);
        if (count < 0) {
                printk(KERN_ERR PREFIX
                       "Error parsing interrupt source overrides entry\n");
@@ -914,14 +1163,15 @@ static int __init acpi_parse_madt_ioapic_entries(void)
         * pretend we got one so we can set the SCI flags.
         */
        if (!acpi_sci_override_gsi)
-               acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0);
+               acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0,
+                                     acpi_gbl_FADT.sci_interrupt);
 
-       /* Fill in identity legacy mapings where no override */
+       /* Fill in identity legacy mappings where no override */
        mp_config_acpi_legacy_irqs();
 
        count =
            acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src,
-                                 NR_IRQ_VECTORS);
+                                 nr_irqs);
        if (count < 0) {
                printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
                /* TBD: Cleanup to allow fallback to MPS */
@@ -978,20 +1228,15 @@ static void __init acpi_process_madt(void)
                if (!error) {
                        acpi_lapic = 1;
 
-#ifdef CONFIG_X86_GENERICARCH
-                       generic_bigsmp_probe();
-#endif
                        /*
                         * Parse MADT IO-APIC entries
                         */
                        error = acpi_parse_madt_ioapic_entries();
                        if (!error) {
                                acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
-                               acpi_irq_balance_set(NULL);
                                acpi_ioapic = 1;
 
                                smp_found_config = 1;
-                               setup_apic_routing();
                        }
                }
                if (error == -EINVAL) {
@@ -1002,13 +1247,33 @@ static void __init acpi_process_madt(void)
                               "Invalid BIOS MADT, disabling ACPI\n");
                        disable_acpi();
                }
+       } else {
+               /*
+                * ACPI found no MADT, and so ACPI wants UP PIC mode.
+                * In the event an MPS table was found, forget it.
+                * Boot with "acpi=off" to use MPS on such a system.
+                */
+               if (smp_found_config) {
+                       printk(KERN_WARNING PREFIX
+                               "No APIC-table, disabling MPS\n");
+                       smp_found_config = 0;
+               }
        }
+
+       /*
+        * ACPI supports both logical (e.g. Hyper-Threading) and physical
+        * processors, where MPS only supports physical.
+        */
+       if (acpi_lapic && acpi_ioapic)
+               printk(KERN_INFO "Using ACPI (MADT) for SMP configuration "
+                      "information\n");
+       else if (acpi_lapic)
+               printk(KERN_INFO "Using ACPI for processor (LAPIC) "
+                      "configuration information\n");
 #endif
        return;
 }
 
-#ifdef __i386__
-
 static int __init disable_acpi_irq(const struct dmi_system_id *d)
 {
        if (!acpi_force) {
@@ -1042,25 +1307,26 @@ static int __init dmi_disable_acpi(const struct dmi_system_id *d)
 }
 
 /*
- * Limit ACPI to CPU enumeration for HT
+ * Force ignoring BIOS IRQ0 pin2 override
  */
-static int __init force_acpi_ht(const struct dmi_system_id *d)
+static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
 {
-       if (!acpi_force) {
-               printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
-                      d->ident);
-               disable_acpi();
-               acpi_ht = 1;
-       } else {
-               printk(KERN_NOTICE
-                      "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
+       /*
+        * The ati_ixp4x0_rev() early PCI quirk should have set
+        * the acpi_skip_timer_override flag already:
+        */
+       if (!acpi_skip_timer_override) {
+               WARN(1, KERN_ERR "ati_ixp4x0 quirk not complete.\n");
+               pr_notice("%s detected: Ignoring BIOS IRQ0 pin2 override\n",
+                       d->ident);
+               acpi_skip_timer_override = 1;
        }
        return 0;
 }
 
 /*
  * If your system is blacklisted here, but you find that acpi=force
- * works for you, please contact acpi-devel@sourceforge.net
+ * works for you, please contact linux-acpi@vger.kernel.org
  */
 static struct dmi_system_id __initdata acpi_dmi_table[] = {
        /*
@@ -1076,98 +1342,6 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
         },
 
        /*
-        * Boxes that need acpi=ht
-        */
-       {
-        .callback = force_acpi_ht,
-        .ident = "FSC Primergy T850",
-        .matches = {
-                    DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
-                    DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
-                    },
-        },
-       {
-        .callback = force_acpi_ht,
-        .ident = "HP VISUALIZE NT Workstation",
-        .matches = {
-                    DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
-                    DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
-                    },
-        },
-       {
-        .callback = force_acpi_ht,
-        .ident = "Compaq Workstation W8000",
-        .matches = {
-                    DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
-                    DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
-                    },
-        },
-       {
-        .callback = force_acpi_ht,
-        .ident = "ASUS P4B266",
-        .matches = {
-                    DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
-                    DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
-                    },
-        },
-       {
-        .callback = force_acpi_ht,
-        .ident = "ASUS P2B-DS",
-        .matches = {
-                    DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
-                    DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
-                    },
-        },
-       {
-        .callback = force_acpi_ht,
-        .ident = "ASUS CUR-DLS",
-        .matches = {
-                    DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
-                    DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
-                    },
-        },
-       {
-        .callback = force_acpi_ht,
-        .ident = "ABIT i440BX-W83977",
-        .matches = {
-                    DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
-                    DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
-                    },
-        },
-       {
-        .callback = force_acpi_ht,
-        .ident = "IBM Bladecenter",
-        .matches = {
-                    DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
-                    DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
-                    },
-        },
-       {
-        .callback = force_acpi_ht,
-        .ident = "IBM eServer xSeries 360",
-        .matches = {
-                    DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
-                    DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
-                    },
-        },
-       {
-        .callback = force_acpi_ht,
-        .ident = "IBM eserver xSeries 330",
-        .matches = {
-                    DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
-                    DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
-                    },
-        },
-       {
-        .callback = force_acpi_ht,
-        .ident = "IBM eserver xSeries 440",
-        .matches = {
-                    DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
-                    DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
-                    },
-        },
-
-       /*
         * Boxes that need ACPI PCI IRQ routing disabled
         */
        {
@@ -1228,7 +1402,52 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
        {}
 };
 
-#endif                         /* __i386__ */
+/* second table for DMI checks that should run after early-quirks */
+static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
+       /*
+        * HP laptops which use a DSDT reporting as HP/SB400/10000,
+        * which includes some code which overrides all temperature
+        * trip points to 16C if the INTIN2 input of the I/O APIC
+        * is enabled.  This input is incorrectly designated the
+        * ISA IRQ 0 via an interrupt source override even though
+        * it is wired to the output of the master 8259A and INTIN0
+        * is not connected at all.  Force ignoring BIOS IRQ0 pin2
+        * override in that cases.
+        */
+       {
+        .callback = dmi_ignore_irq0_timer_override,
+        .ident = "HP nx6115 laptop",
+        .matches = {
+                    DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
+                    DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"),
+                    },
+        },
+       {
+        .callback = dmi_ignore_irq0_timer_override,
+        .ident = "HP NX6125 laptop",
+        .matches = {
+                    DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
+                    DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"),
+                    },
+        },
+       {
+        .callback = dmi_ignore_irq0_timer_override,
+        .ident = "HP NX6325 laptop",
+        .matches = {
+                    DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
+                    DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
+                    },
+        },
+       {
+        .callback = dmi_ignore_irq0_timer_override,
+        .ident = "HP 6715b laptop",
+        .matches = {
+                    DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
+                    DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"),
+                    },
+        },
+       {}
+};
 
 /*
  * acpi_boot_table_init() and acpi_boot_init()
@@ -1247,34 +1466,25 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
  *     if acpi_blacklisted() acpi_disabled = 1;
  *     acpi_irq_model=...
  *     ...
- *
- * return value: (currently ignored)
- *     0: success
- *     !0: failure
  */
 
-int __init acpi_boot_table_init(void)
+void __init acpi_boot_table_init(void)
 {
-       int error;
-
-#ifdef __i386__
        dmi_check_system(acpi_dmi_table);
-#endif
 
        /*
         * If acpi_disabled, bail out
         * One exception: acpi=ht continues far enough to enumerate LAPICs
         */
        if (acpi_disabled && !acpi_ht)
-               return 1;
+               return
 
        /*
         * Initialize the ACPI boot-time table parser.
         */
-       error = acpi_table_init();
-       if (error) {
+       if (acpi_table_init()) {
                disable_acpi();
-               return error;
+               return;
        }
 
        acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
@@ -1282,18 +1492,15 @@ int __init acpi_boot_table_init(void)
        /*
         * blacklist may disable ACPI entirely
         */
-       error = acpi_blacklisted();
-       if (error) {
+       if (acpi_blacklisted()) {
                if (acpi_force) {
                        printk(KERN_WARNING PREFIX "acpi=force override\n");
                } else {
                        printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
                        disable_acpi();
-                       return error;
+                       return;
                }
        }
-
-       return 0;
 }
 
 int __init early_acpi_boot_init(void)
@@ -1315,6 +1522,9 @@ int __init early_acpi_boot_init(void)
 
 int __init acpi_boot_init(void)
 {
+       /* those are executed after early-quirks are executed */
+       dmi_check_system(acpi_dmi_table_late);
+
        /*
         * If acpi_disabled, bail out
         * One exception: acpi=ht continues far enough to enumerate LAPICs
@@ -1336,6 +1546,9 @@ int __init acpi_boot_init(void)
 
        acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
 
+       if (!acpi_noirq)
+               x86_init.pci.init = pci_acpi_init;
+
        return 0;
 }
 
@@ -1360,10 +1573,16 @@ static int __init parse_acpi(char *arg)
        }
        /* Limit ACPI just to boot-time to enable HT */
        else if (strcmp(arg, "ht") == 0) {
-               if (!acpi_force)
+               if (!acpi_force) {
+                       printk(KERN_WARNING "acpi=ht will be removed in Linux-2.6.35\n");
                        disable_acpi();
+               }
                acpi_ht = 1;
        }
+       /* acpi=rsdt use RSDT instead of XSDT */
+       else if (strcmp(arg, "rsdt") == 0) {
+               acpi_rsdt_forced = 1;
+       }
        /* "acpi=noirq" disables ACPI interrupt routing */
        else if (strcmp(arg, "noirq") == 0) {
                acpi_noirq_set();
@@ -1384,6 +1603,20 @@ static int __init parse_pci(char *arg)
 }
 early_param("pci", parse_pci);
 
+int __init acpi_mps_check(void)
+{
+#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE)
+/* mptable code is not built-in*/
+       if (acpi_disabled || acpi_noirq) {
+               printk(KERN_WARNING "MPS support code is not built-in.\n"
+                      "Using acpi=off or acpi=noirq or pci=noacpi "
+                      "may have problem\n");
+               return 1;
+       }
+#endif
+       return 0;
+}
+
 #ifdef CONFIG_X86_IO_APIC
 static int __init parse_acpi_skip_timer_override(char *arg)
 {