]> err.no Git - linux-2.6/blobdiff - drivers/pci/msi.c
[PATCH] blk: Use blk_queue_xxx functions to set parameters
[linux-2.6] / drivers / pci / msi.c
index 22ecd3b058be176a76683a87ae33eb1269ece88a..532f73bb2224af802af190aa0a38ea66242aa188 100644 (file)
@@ -28,10 +28,10 @@ static struct msi_desc* msi_desc[NR_IRQS] = { [0 ... NR_IRQS-1] = NULL };
 static kmem_cache_t* msi_cachep;
 
 static int pci_msi_enable = 1;
-static int last_alloc_vector = 0;
-static int nr_released_vectors = 0;
+static int last_alloc_vector;
+static int nr_released_vectors;
 static int nr_reserved_vectors = NR_HP_RESERVED_VECTORS;
-static int nr_msix_devices = 0;
+static int nr_msix_devices;
 
 #ifndef CONFIG_X86_IO_APIC
 int vector_irq[NR_VECTORS] = { [0 ... NR_VECTORS - 1] = -1};
@@ -91,6 +91,7 @@ static void set_msi_affinity(unsigned int vector, cpumask_t cpu_mask)
 {
        struct msi_desc *entry;
        struct msg_address address;
+       unsigned int irq = vector;
 
        entry = (struct msi_desc *)msi_desc[vector];
        if (!entry || !entry->dev)
@@ -112,6 +113,7 @@ static void set_msi_affinity(unsigned int vector, cpumask_t cpu_mask)
                entry->msi_attrib.current_cpu = cpu_mask_to_apicid(cpu_mask);
                pci_write_config_dword(entry->dev, msi_lower_address_reg(pos),
                        address.lo_address.value);
+               set_native_irq_info(irq, cpu_mask);
                break;
        }
        case PCI_CAP_ID_MSIX:
@@ -125,22 +127,13 @@ static void set_msi_affinity(unsigned int vector, cpumask_t cpu_mask)
                        MSI_TARGET_CPU_SHIFT);
                entry->msi_attrib.current_cpu = cpu_mask_to_apicid(cpu_mask);
                writel(address.lo_address.value, entry->mask_base + offset);
+               set_native_irq_info(irq, cpu_mask);
                break;
        }
        default:
                break;
        }
 }
-
-#ifdef CONFIG_IRQBALANCE
-static inline void move_msi(int vector)
-{
-       if (!cpus_empty(pending_irq_balance_cpumask[vector])) {
-               set_msi_affinity(vector, pending_irq_balance_cpumask[vector]);
-               cpus_clear(pending_irq_balance_cpumask[vector]);
-       }
-}
-#endif /* CONFIG_IRQBALANCE */
 #endif /* CONFIG_SMP */
 
 static void mask_MSI_irq(unsigned int vector)
@@ -170,52 +163,42 @@ static unsigned int startup_msi_irq_wo_maskbit(unsigned int vector)
        return 0;       /* never anything pending */
 }
 
-static void release_msi(unsigned int vector);
-static void shutdown_msi_irq(unsigned int vector)
-{
-       release_msi(vector);
-}
-
-#define shutdown_msi_irq_wo_maskbit    shutdown_msi_irq
-static void enable_msi_irq_wo_maskbit(unsigned int vector) {}
-static void disable_msi_irq_wo_maskbit(unsigned int vector) {}
-static void ack_msi_irq_wo_maskbit(unsigned int vector) {}
-static void end_msi_irq_wo_maskbit(unsigned int vector)
+static unsigned int startup_msi_irq_w_maskbit(unsigned int vector)
 {
-       move_msi(vector);
-       ack_APIC_irq();
+       startup_msi_irq_wo_maskbit(vector);
+       unmask_MSI_irq(vector);
+       return 0;       /* never anything pending */
 }
 
-static unsigned int startup_msi_irq_w_maskbit(unsigned int vector)
+static void shutdown_msi_irq(unsigned int vector)
 {
        struct msi_desc *entry;
        unsigned long flags;
 
        spin_lock_irqsave(&msi_lock, flags);
        entry = msi_desc[vector];
-       if (!entry || !entry->dev) {
-               spin_unlock_irqrestore(&msi_lock, flags);
-               return 0;
-       }
-       entry->msi_attrib.state = 1;    /* Mark it active */
+       if (entry && entry->dev)
+               entry->msi_attrib.state = 0;    /* Mark it not active */
        spin_unlock_irqrestore(&msi_lock, flags);
-
-       unmask_MSI_irq(vector);
-       return 0;       /* never anything pending */
 }
 
-#define shutdown_msi_irq_w_maskbit     shutdown_msi_irq
-#define enable_msi_irq_w_maskbit       unmask_MSI_irq
-#define disable_msi_irq_w_maskbit      mask_MSI_irq
-#define ack_msi_irq_w_maskbit          mask_MSI_irq
+static void end_msi_irq_wo_maskbit(unsigned int vector)
+{
+       move_native_irq(vector);
+       ack_APIC_irq();
+}
 
 static void end_msi_irq_w_maskbit(unsigned int vector)
 {
-       move_msi(vector);
+       move_native_irq(vector);
        unmask_MSI_irq(vector);
        ack_APIC_irq();
 }
 
+static void do_nothing(unsigned int vector)
+{
+}
+
 /*
  * Interrupt Type for MSI-X PCI/PCI-X/PCI-Express Devices,
  * which implement the MSI-X Capability Structure.
@@ -223,10 +206,10 @@ static void end_msi_irq_w_maskbit(unsigned int vector)
 static struct hw_interrupt_type msix_irq_type = {
        .typename       = "PCI-MSI-X",
        .startup        = startup_msi_irq_w_maskbit,
-       .shutdown       = shutdown_msi_irq_w_maskbit,
-       .enable         = enable_msi_irq_w_maskbit,
-       .disable        = disable_msi_irq_w_maskbit,
-       .ack            = ack_msi_irq_w_maskbit,
+       .shutdown       = shutdown_msi_irq,
+       .enable         = unmask_MSI_irq,
+       .disable        = mask_MSI_irq,
+       .ack            = mask_MSI_irq,
        .end            = end_msi_irq_w_maskbit,
        .set_affinity   = set_msi_irq_affinity
 };
@@ -239,10 +222,10 @@ static struct hw_interrupt_type msix_irq_type = {
 static struct hw_interrupt_type msi_irq_w_maskbit_type = {
        .typename       = "PCI-MSI",
        .startup        = startup_msi_irq_w_maskbit,
-       .shutdown       = shutdown_msi_irq_w_maskbit,
-       .enable         = enable_msi_irq_w_maskbit,
-       .disable        = disable_msi_irq_w_maskbit,
-       .ack            = ack_msi_irq_w_maskbit,
+       .shutdown       = shutdown_msi_irq,
+       .enable         = unmask_MSI_irq,
+       .disable        = mask_MSI_irq,
+       .ack            = mask_MSI_irq,
        .end            = end_msi_irq_w_maskbit,
        .set_affinity   = set_msi_irq_affinity
 };
@@ -255,10 +238,10 @@ static struct hw_interrupt_type msi_irq_w_maskbit_type = {
 static struct hw_interrupt_type msi_irq_wo_maskbit_type = {
        .typename       = "PCI-MSI",
        .startup        = startup_msi_irq_wo_maskbit,
-       .shutdown       = shutdown_msi_irq_wo_maskbit,
-       .enable         = enable_msi_irq_wo_maskbit,
-       .disable        = disable_msi_irq_wo_maskbit,
-       .ack            = ack_msi_irq_wo_maskbit,
+       .shutdown       = shutdown_msi_irq,
+       .enable         = do_nothing,
+       .disable        = do_nothing,
+       .ack            = do_nothing,
        .end            = end_msi_irq_wo_maskbit,
        .set_affinity   = set_msi_irq_affinity
 };
@@ -407,7 +390,7 @@ static struct msi_desc* alloc_msi_entry(void)
 {
        struct msi_desc *entry;
 
-       entry = (struct msi_desc*) kmem_cache_alloc(msi_cachep, SLAB_KERNEL);
+       entry = kmem_cache_alloc(msi_cachep, SLAB_KERNEL);
        if (!entry)
                return NULL;
 
@@ -463,7 +446,7 @@ static void enable_msi_mode(struct pci_dev *dev, int pos, int type)
        }
 }
 
-static void disable_msi_mode(struct pci_dev *dev, int pos, int type)
+void disable_msi_mode(struct pci_dev *dev, int pos, int type)
 {
        u16 control;
 
@@ -522,7 +505,7 @@ void pci_scan_msi_device(struct pci_dev *dev)
  * msi_capability_init - configure device's MSI capability structure
  * @dev: pointer to the pci_dev data structure of MSI device function
  *
- * Setup the MSI capability structure of device funtion with a single
+ * Setup the MSI capability structure of device function with a single
  * MSI vector, regardless of device function is capable of handling
  * multiple messages. A return of zero indicates the successful setup
  * of an entry zero with the new MSI vector or non-zero for otherwise.
@@ -599,7 +582,7 @@ static int msi_capability_init(struct pci_dev *dev)
  * msix_capability_init - configure device's MSI-X capability
  * @dev: pointer to the pci_dev data structure of MSI-X device function
  *
- * Setup the MSI-X capability structure of device funtion with a
+ * Setup the MSI-X capability structure of device function with a
  * single MSI-X vector. A return of zero indicates the successful setup of
  * requested MSI-X entries with allocated vectors or non-zero for otherwise.
  **/
@@ -709,6 +692,9 @@ int pci_enable_msi(struct pci_dev* dev)
        if (!pci_msi_enable || !dev)
                return status;
 
+       if (dev->no_msi)
+               return status;
+
        temp = dev->irq;
 
        if ((status = msi_init()) < 0)
@@ -796,18 +782,6 @@ void pci_disable_msi(struct pci_dev* dev)
        }
 }
 
-static void release_msi(unsigned int vector)
-{
-       struct msi_desc *entry;
-       unsigned long flags;
-
-       spin_lock_irqsave(&msi_lock, flags);
-       entry = msi_desc[vector];
-       if (entry && entry->dev)
-               entry->msi_attrib.state = 0;    /* Mark it not active */
-       spin_unlock_irqrestore(&msi_lock, flags);
-}
-
 static int msi_free_vector(struct pci_dev* dev, int vector, int reassign)
 {
        struct msi_desc *entry;
@@ -924,7 +898,7 @@ static int reroute_msix_table(int head, struct msix_entry *entries, int *nvec)
 /**
  * pci_enable_msix - configure device's MSI-X capability structure
  * @dev: pointer to the pci_dev data structure of MSI-X device function
- * @data: pointer to an array of MSI-X entries
+ * @entries: pointer to an array of MSI-X entries
  * @nvec: number of MSI-X vectors requested for allocation by device driver
  *
  * Setup the MSI-X capability structure of device function with the number
@@ -1074,7 +1048,7 @@ void pci_disable_msix(struct pci_dev* dev)
  * msi_remove_pci_irq_vectors - reclaim MSI(X) vectors to unused state
  * @dev: pointer to the pci_dev data structure of MSI(X) device function
  *
- * Being called during hotplug remove, from which the device funciton
+ * Being called during hotplug remove, from which the device function
  * is hot-removed. All previous assigned MSI/MSI-X vectors, if
  * allocated for this device function, are reclaimed to unused state,
  * which may be used later on.