Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee13...
[pandora-kernel.git] / arch / x86_64 / kernel / io_apic.c
index 1ccf1b4..0491019 100644 (file)
@@ -48,7 +48,7 @@ int sis_apic_bug; /* not actually supported, dummy for compile */
 
 static int no_timer_check;
 
-int disable_timer_pin_1 __initdata;
+static int disable_timer_pin_1 __initdata;
 
 int timer_over_8254 __initdata = 0;
 
@@ -253,18 +253,17 @@ int ioapic_force;
 static int __init disable_ioapic_setup(char *str)
 {
        skip_ioapic_setup = 1;
-       return 1;
+       return 0;
 }
+early_param("noapic", disable_ioapic_setup);
 
-static int __init enable_ioapic_setup(char *str)
+/* Actually the next is obsolete, but keep it for paranoid reasons -AK */
+static int __init disable_timer_pin_setup(char *arg)
 {
-       ioapic_force = 1;
-       skip_ioapic_setup = 0;
+       disable_timer_pin_1 = 1;
        return 1;
 }
-
-__setup("noapic", disable_ioapic_setup);
-__setup("apic", enable_ioapic_setup);
+__setup("disable_timer_pin_1", disable_timer_pin_setup);
 
 static int __init setup_disable_8254_timer(char *s)
 {
@@ -280,107 +279,6 @@ static int __init setup_enable_8254_timer(char *s)
 __setup("disable_8254_timer", setup_disable_8254_timer);
 __setup("enable_8254_timer", setup_enable_8254_timer);
 
-#include <asm/pci-direct.h>
-#include <linux/pci_ids.h>
-#include <linux/pci.h>
-
-
-#ifdef CONFIG_ACPI
-
-static int nvidia_hpet_detected __initdata;
-
-static int __init nvidia_hpet_check(unsigned long phys, unsigned long size)
-{
-       nvidia_hpet_detected = 1;
-       return 0;
-}
-#endif
-
-/* Temporary Hack. Nvidia and VIA boards currently only work with IO-APIC
-   off. Check for an Nvidia or VIA PCI bridge and turn it off.
-   Use pci direct infrastructure because this runs before the PCI subsystem. 
-
-   Can be overwritten with "apic"
-
-   And another hack to disable the IOMMU on VIA chipsets.
-
-   ... and others. Really should move this somewhere else.
-
-   Kludge-O-Rama. */
-void __init check_ioapic(void) 
-{ 
-       int num,slot,func; 
-       /* Poor man's PCI discovery */
-       for (num = 0; num < 32; num++) { 
-               for (slot = 0; slot < 32; slot++) { 
-                       for (func = 0; func < 8; func++) { 
-                               u32 class;
-                               u32 vendor;
-                               u8 type;
-                               class = read_pci_config(num,slot,func,
-                                                       PCI_CLASS_REVISION);
-                               if (class == 0xffffffff)
-                                       break; 
-
-                               if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
-                                       continue; 
-
-                               vendor = read_pci_config(num, slot, func, 
-                                                        PCI_VENDOR_ID);
-                               vendor &= 0xffff;
-                               switch (vendor) { 
-                               case PCI_VENDOR_ID_VIA:
-#ifdef CONFIG_IOMMU
-                                       if ((end_pfn > MAX_DMA32_PFN ||
-                                            force_iommu) &&
-                                           !iommu_aperture_allowed) {
-                                               printk(KERN_INFO
-    "Looks like a VIA chipset. Disabling IOMMU. Override with \"iommu=allowed\"\n");
-                                               iommu_aperture_disabled = 1;
-                                       }
-#endif
-                                       return;
-                               case PCI_VENDOR_ID_NVIDIA:
-#ifdef CONFIG_ACPI
-                                       /*
-                                        * All timer overrides on Nvidia are
-                                        * wrong unless HPET is enabled.
-                                        */
-                                       nvidia_hpet_detected = 0;
-                                       acpi_table_parse(ACPI_HPET,
-                                                       nvidia_hpet_check);
-                                       if (nvidia_hpet_detected == 0) {
-                                               acpi_skip_timer_override = 1;
-                                               printk(KERN_INFO "Nvidia board "
-                                                   "detected. Ignoring ACPI "
-                                                   "timer override.\n");
-                                       }
-#endif
-                                       /* RED-PEN skip them on mptables too? */
-                                       return;
-
-                               /* This should be actually default, but
-                                  for 2.6.16 let's do it for ATI only where
-                                  it's really needed. */
-                               case PCI_VENDOR_ID_ATI:
-                                       if (timer_over_8254 == 1) {     
-                                               timer_over_8254 = 0;    
-                                       printk(KERN_INFO
-               "ATI board detected. Disabling timer routing over 8254.\n");
-                                       }       
-                                       return;
-                               } 
-
-
-                               /* No multi-function device? */
-                               type = read_pci_config_byte(num,slot,func,
-                                                           PCI_HEADER_TYPE);
-                               if (!(type & 0x80))
-                                       break;
-                       } 
-               }
-       }
-} 
 
 /*
  * Find the IRQ entry number of a certain pin.
@@ -409,7 +307,7 @@ static int __init find_isa_irq_pin(int irq, int type)
        for (i = 0; i < mp_irq_entries; i++) {
                int lbus = mp_irqs[i].mpc_srcbus;
 
-               if (mp_bus_id_to_type[lbus] == MP_BUS_ISA &&
+               if (test_bit(lbus, mp_bus_not_pci) &&
                    (mp_irqs[i].mpc_irqtype == type) &&
                    (mp_irqs[i].mpc_srcbusirq == irq))
 
@@ -425,7 +323,7 @@ static int __init find_isa_irq_apic(int irq, int type)
        for (i = 0; i < mp_irq_entries; i++) {
                int lbus = mp_irqs[i].mpc_srcbus;
 
-               if ((mp_bus_id_to_type[lbus] == MP_BUS_ISA) &&
+               if (test_bit(lbus, mp_bus_not_pci) &&
                    (mp_irqs[i].mpc_irqtype == type) &&
                    (mp_irqs[i].mpc_srcbusirq == irq))
                        break;
@@ -465,7 +363,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin)
                            mp_irqs[i].mpc_dstapic == MP_APIC_ALL)
                                break;
 
-               if ((mp_bus_id_to_type[lbus] == MP_BUS_PCI) &&
+               if (!test_bit(lbus, mp_bus_not_pci) &&
                    !mp_irqs[i].mpc_irqtype &&
                    (bus == lbus) &&
                    (slot == ((mp_irqs[i].mpc_srcbusirq >> 2) & 0x1f))) {
@@ -511,28 +409,11 @@ static int __init MPBIOS_polarity(int idx)
        switch (mp_irqs[idx].mpc_irqflag & 3)
        {
                case 0: /* conforms, ie. bus-type dependent polarity */
-               {
-                       switch (mp_bus_id_to_type[bus])
-                       {
-                               case MP_BUS_ISA: /* ISA pin */
-                               {
-                                       polarity = default_ISA_polarity(idx);
-                                       break;
-                               }
-                               case MP_BUS_PCI: /* PCI pin */
-                               {
-                                       polarity = default_PCI_polarity(idx);
-                                       break;
-                               }
-                               default:
-                               {
-                                       printk(KERN_WARNING "broken BIOS!!\n");
-                                       polarity = 1;
-                                       break;
-                               }
-                       }
+                       if (test_bit(bus, mp_bus_not_pci))
+                               polarity = default_ISA_polarity(idx);
+                       else
+                               polarity = default_PCI_polarity(idx);
                        break;
-               }
                case 1: /* high active */
                {
                        polarity = 0;
@@ -570,28 +451,11 @@ static int MPBIOS_trigger(int idx)
        switch ((mp_irqs[idx].mpc_irqflag>>2) & 3)
        {
                case 0: /* conforms, ie. bus-type dependent */
-               {
-                       switch (mp_bus_id_to_type[bus])
-                       {
-                               case MP_BUS_ISA: /* ISA pin */
-                               {
-                                       trigger = default_ISA_trigger(idx);
-                                       break;
-                               }
-                               case MP_BUS_PCI: /* PCI pin */
-                               {
-                                       trigger = default_PCI_trigger(idx);
-                                       break;
-                               }
-                               default:
-                               {
-                                       printk(KERN_WARNING "broken BIOS!!\n");
-                                       trigger = 1;
-                                       break;
-                               }
-                       }
+                       if (test_bit(bus, mp_bus_not_pci))
+                               trigger = default_ISA_trigger(idx);
+                       else
+                               trigger = default_PCI_trigger(idx);
                        break;
-               }
                case 1: /* edge */
                {
                        trigger = 0;
@@ -697,31 +561,17 @@ static int pin_2_irq(int idx, int apic, int pin)
        if (mp_irqs[idx].mpc_dstirq != pin)
                printk(KERN_ERR "broken BIOS or MPTABLE parser, ayiee!!\n");
 
-       switch (mp_bus_id_to_type[bus])
-       {
-               case MP_BUS_ISA: /* ISA pin */
-               {
-                       irq = mp_irqs[idx].mpc_srcbusirq;
-                       break;
-               }
-               case MP_BUS_PCI: /* PCI pin */
-               {
-                       /*
-                        * PCI IRQs are mapped in order
-                        */
-                       i = irq = 0;
-                       while (i < apic)
-                               irq += nr_ioapic_registers[i++];
-                       irq += pin;
-                       irq = gsi_irq_sharing(irq);
-                       break;
-               }
-               default:
-               {
-                       printk(KERN_ERR "unknown bus type %d.\n",bus); 
-                       irq = 0;
-                       break;
-               }
+       if (test_bit(bus, mp_bus_not_pci)) {
+               irq = mp_irqs[idx].mpc_srcbusirq;
+       } else {
+               /*
+                * PCI IRQs are mapped in order
+                */
+               i = irq = 0;
+               while (i < apic)
+                       irq += nr_ioapic_registers[i++];
+               irq += pin;
+               irq = gsi_irq_sharing(irq);
        }
        BUG_ON(irq >= NR_IRQS);
        return irq;
@@ -1282,72 +1132,6 @@ void disable_IO_APIC(void)
        disconnect_bsp_APIC(ioapic_i8259.pin != -1);
 }
 
-/*
- * function to set the IO-APIC physical IDs based on the
- * values stored in the MPC table.
- *
- * by Matt Domsch <Matt_Domsch@dell.com>  Tue Dec 21 12:25:05 CST 1999
- */
-
-static void __init setup_ioapic_ids_from_mpc (void)
-{
-       union IO_APIC_reg_00 reg_00;
-       int apic;
-       int i;
-       unsigned char old_id;
-       unsigned long flags;
-
-       /*
-        * Set the IOAPIC ID to the value stored in the MPC table.
-        */
-       for (apic = 0; apic < nr_ioapics; apic++) {
-
-               /* Read the register 0 value */
-               spin_lock_irqsave(&ioapic_lock, flags);
-               reg_00.raw = io_apic_read(apic, 0);
-               spin_unlock_irqrestore(&ioapic_lock, flags);
-               
-               old_id = mp_ioapics[apic].mpc_apicid;
-
-
-               printk(KERN_INFO "Using IO-APIC %d\n", mp_ioapics[apic].mpc_apicid);
-
-
-               /*
-                * We need to adjust the IRQ routing table
-                * if the ID changed.
-                */
-               if (old_id != mp_ioapics[apic].mpc_apicid)
-                       for (i = 0; i < mp_irq_entries; i++)
-                               if (mp_irqs[i].mpc_dstapic == old_id)
-                                       mp_irqs[i].mpc_dstapic
-                                               = mp_ioapics[apic].mpc_apicid;
-
-               /*
-                * Read the right value from the MPC table and
-                * write it into the ID register.
-                */
-               apic_printk(APIC_VERBOSE,KERN_INFO "...changing IO-APIC physical APIC ID to %d ...",
-                               mp_ioapics[apic].mpc_apicid);
-
-               reg_00.bits.ID = mp_ioapics[apic].mpc_apicid;
-               spin_lock_irqsave(&ioapic_lock, flags);
-               io_apic_write(apic, 0, reg_00.raw);
-               spin_unlock_irqrestore(&ioapic_lock, flags);
-
-               /*
-                * Sanity check
-                */
-               spin_lock_irqsave(&ioapic_lock, flags);
-               reg_00.raw = io_apic_read(apic, 0);
-               spin_unlock_irqrestore(&ioapic_lock, flags);
-               if (reg_00.bits.ID != mp_ioapics[apic].mpc_apicid)
-                       printk("could not set ID!\n");
-               else
-                       apic_printk(APIC_VERBOSE," ok.\n");
-       }
-}
-
 /*
  * There is a nasty bug in some older SMP boards, their mptable lies
  * about the timer IRQ. We do the following to work around the situation:
@@ -1863,11 +1647,6 @@ void __init setup_IO_APIC(void)
 
        apic_printk(APIC_VERBOSE, "ENABLING IO-APIC IRQs\n");
 
-       /*
-        * Set up the IO-APIC IRQ routing table.
-        */
-       if (!acpi_ioapic)
-               setup_ioapic_ids_from_mpc();
        sync_Arb_IDs();
        setup_IO_APIC_irqs();
        init_IO_APIC_traps();
@@ -1969,19 +1748,6 @@ device_initcall(ioapic_init_sysfs);
 
 #define IO_APIC_MAX_ID         0xFE
 
-int __init io_apic_get_version (int ioapic)
-{
-       union IO_APIC_reg_01    reg_01;
-       unsigned long flags;
-
-       spin_lock_irqsave(&ioapic_lock, flags);
-       reg_01.raw = io_apic_read(ioapic, 1);
-       spin_unlock_irqrestore(&ioapic_lock, flags);
-
-       return reg_01.bits.version;
-}
-
-
 int __init io_apic_get_redir_entries (int ioapic)
 {
        union IO_APIC_reg_01    reg_01;