[PATCH] RCU Documentation fix
[powerpc.git] / drivers / pci / msi.c
index 4aea563..36bc7c4 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
-#include <linux/config.h>
 #include <linux/ioport.h>
 #include <linux/smp_lock.h>
 #include <linux/pci.h>
@@ -35,7 +34,6 @@ static int nr_msix_devices;
 
 #ifndef CONFIG_X86_IO_APIC
 int vector_irq[NR_VECTORS] = { [0 ... NR_VECTORS - 1] = -1};
-u8 irq_vector[NR_IRQ_VECTORS];
 #endif
 
 static struct msi_ops *msi_ops;
@@ -383,10 +381,6 @@ static int msi_init(void)
                return status;
        }
 
-#ifndef CONFIG_X86_IO_APIC
-       irq_vector[0] = FIRST_DEVICE_VECTOR;
-#endif
-
        if (last_alloc_vector < 0) {
                pci_msi_enable = 0;
                printk(KERN_WARNING "PCI: No interrupt vectors available for MSI\n");
@@ -434,12 +428,12 @@ static void irq_handler_init(int cap_id, int pos, int mask)
 
        spin_lock_irqsave(&irq_desc[pos].lock, flags);
        if (cap_id == PCI_CAP_ID_MSIX)
-               irq_desc[pos].handler = &msix_irq_type;
+               irq_desc[pos].chip = &msix_irq_type;
        else {
                if (!mask)
-                       irq_desc[pos].handler = &msi_irq_wo_maskbit_type;
+                       irq_desc[pos].chip = &msi_irq_wo_maskbit_type;
                else
-                       irq_desc[pos].handler = &msi_irq_w_maskbit_type;
+                       irq_desc[pos].chip = &msi_irq_w_maskbit_type;
        }
        spin_unlock_irqrestore(&irq_desc[pos].lock, flags);
 }
@@ -453,9 +447,11 @@ static void enable_msi_mode(struct pci_dev *dev, int pos, int type)
                /* Set enabled bits to single MSI & enable MSI_enable bit */
                msi_enable(control, 1);
                pci_write_config_word(dev, msi_control_reg(pos), control);
+               dev->msi_enabled = 1;
        } else {
                msix_enable(control);
                pci_write_config_word(dev, msi_control_reg(pos), control);
+               dev->msix_enabled = 1;
        }
        if (pci_find_capability(dev, PCI_CAP_ID_EXP)) {
                /* PCI Express Endpoint device detected */
@@ -472,9 +468,11 @@ void disable_msi_mode(struct pci_dev *dev, int pos, int type)
                /* Set enabled bits to single MSI & enable MSI_enable bit */
                msi_disable(control);
                pci_write_config_word(dev, msi_control_reg(pos), control);
+               dev->msi_enabled = 0;
        } else {
                msix_disable(control);
                pci_write_config_word(dev, msi_control_reg(pos), control);
+               dev->msix_enabled = 0;
        }
        if (pci_find_capability(dev, PCI_CAP_ID_EXP)) {
                /* PCI Express Endpoint device detected */
@@ -549,7 +547,6 @@ int pci_save_msi_state(struct pci_dev *dev)
                pci_read_config_dword(dev, pos + PCI_MSI_DATA_32, &cap[i++]);
        if (control & PCI_MSI_FLAGS_MASKBIT)
                pci_read_config_dword(dev, pos + PCI_MSI_MASK_BIT, &cap[i++]);
-       disable_msi_mode(dev, pos, PCI_CAP_ID_MSI);
        save_state->cap_nr = PCI_CAP_ID_MSI;
        pci_add_saved_cap(dev, save_state);
        return 0;
@@ -639,7 +636,6 @@ int pci_save_msix_state(struct pci_dev *dev)
        }
        dev->irq = temp;
 
-       disable_msi_mode(dev, pos, PCI_CAP_ID_MSIX);
        save_state->cap_nr = PCI_CAP_ID_MSIX;
        pci_add_saved_cap(dev, save_state);
        return 0;
@@ -940,14 +936,13 @@ int pci_enable_msi(struct pci_dev* dev)
        if (!pos)
                return -EINVAL;
 
-       pci_read_config_word(dev, msi_control_reg(pos), &control);
-       if (control & PCI_MSI_FLAGS_ENABLE)
-               return 0;                       /* Already in MSI mode */
-
        if (!msi_lookup_vector(dev, PCI_CAP_ID_MSI)) {
                /* Lookup Sucess */
                unsigned long flags;
 
+               pci_read_config_word(dev, msi_control_reg(pos), &control);
+               if (control & PCI_MSI_FLAGS_ENABLE)
+                       return 0;       /* Already in MSI mode */
                spin_lock_irqsave(&msi_lock, flags);
                if (!vector_irq[dev->irq]) {
                        msi_desc[dev->irq]->msi_attrib.state = 0;
@@ -1064,33 +1059,8 @@ static int msi_free_vector(struct pci_dev* dev, int vector, int reassign)
                                entry_nr * PCI_MSIX_ENTRY_SIZE +
                                PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
 
-               if (head == vector) {
-                       /*
-                        * Detect last MSI-X vector to be released.
-                        * Release the MSI-X memory-mapped table.
-                        */
-#if 0
-                       int pos, nr_entries;
-                       unsigned long phys_addr;
-                       u32 table_offset;
-                       u16 control;
-                       u8 bir;
-
-                       pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
-                       pci_read_config_word(dev, msi_control_reg(pos),
-                               &control);
-                       nr_entries = multi_msix_capable(control);
-                       pci_read_config_dword(dev, msix_table_offset_reg(pos),
-                               &table_offset);
-                       bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK);
-                       table_offset &= ~PCI_MSIX_FLAGS_BIRMASK;
-                       phys_addr = pci_resource_start(dev, bir) + table_offset;
-/*
- * FIXME!  and what did you want to do with phys_addr?
- */
-#endif
+               if (head == vector)
                        iounmap(base);
-               }
        }
 
        return 0;
@@ -1364,24 +1334,6 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev)
                }
                msi_free_vector(dev, vector, 0);
                if (warning) {
-                       /* Force to release the MSI-X memory-mapped table */
-#if 0
-                       unsigned long phys_addr;
-                       u32 table_offset;
-                       u16 control;
-                       u8 bir;
-
-                       pci_read_config_word(dev, msi_control_reg(pos),
-                               &control);
-                       pci_read_config_dword(dev, msix_table_offset_reg(pos),
-                               &table_offset);
-                       bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK);
-                       table_offset &= ~PCI_MSIX_FLAGS_BIRMASK;
-                       phys_addr = pci_resource_start(dev, bir) + table_offset;
-/*
- * FIXME! and what did you want to do with phys_addr?
- */
-#endif
                        iounmap(base);
                        printk(KERN_WARNING "PCI: %s: msi_remove_pci_irq_vectors() "
                               "called without free_irq() on all MSI-X vectors\n",