MSI: Replace pci_msi_quirk with calls to pci_no_msi()
[firefly-linux-kernel-4.4.55.git] / drivers / pci / msi.c
index f9fdc54473c4aed27a7f0e865dae74017c352563..3776531586d105e0b4f4cfc6cda372bea535bc01 100644 (file)
@@ -26,7 +26,7 @@
 
 static DEFINE_SPINLOCK(msi_lock);
 static struct msi_desc* msi_desc[NR_IRQS] = { [0 ... NR_IRQS-1] = NULL };
-static kmem_cache_t* msi_cachep;
+static struct kmem_cache* msi_cachep;
 
 static int pci_msi_enable = 1;
 
@@ -49,8 +49,8 @@ static void msi_set_mask_bit(unsigned int irq, int flag)
        switch (entry->msi_attrib.type) {
        case PCI_CAP_ID_MSI:
                if (entry->msi_attrib.maskbit) {
-                       int             pos;
-                       u32             mask_bits;
+                       int pos;
+                       u32 mask_bits;
 
                        pos = (long)entry->mask_base;
                        pci_read_config_dword(entry->dev, pos, &mask_bits);
@@ -162,6 +162,7 @@ void unmask_msi_irq(unsigned int irq)
 }
 
 static int msi_free_irq(struct pci_dev* dev, int irq);
+
 static int msi_init(void)
 {
        static int status = -ENOMEM;
@@ -169,13 +170,6 @@ static int msi_init(void)
        if (!status)
                return status;
 
-       if (pci_msi_quirk) {
-               pci_msi_enable = 0;
-               printk(KERN_WARNING "PCI: MSI quirk detected. MSI disabled.\n");
-               status = -EINVAL;
-               return status;
-       }
-
        status = msi_cache_init();
        if (status < 0) {
                pci_msi_enable = 0;
@@ -255,10 +249,8 @@ static void enable_msi_mode(struct pci_dev *dev, int pos, int type)
                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 */
-               pci_intx(dev, 0);  /* disable intx */
-       }
+
+       pci_intx(dev, 0);  /* disable intx */
 }
 
 void disable_msi_mode(struct pci_dev *dev, int pos, int type)
@@ -276,10 +268,8 @@ void disable_msi_mode(struct pci_dev *dev, int pos, int type)
                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 */
-               pci_intx(dev, 1);  /* enable intx */
-       }
+
+       pci_intx(dev, 1);  /* enable intx */
 }
 
 static int msi_lookup_irq(struct pci_dev *dev, int type)
@@ -295,7 +285,7 @@ static int msi_lookup_irq(struct pci_dev *dev, int type)
                        continue;
                spin_unlock_irqrestore(&msi_lock, flags);
                /* This pre-assigned MSI irq for this device
-                  already exits. Override dev->irq with this irq */
+                  already exists. Override dev->irq with this irq */
                dev->irq = irq;
                return 0;
        }
@@ -462,7 +452,7 @@ void pci_restore_msix_state(struct pci_dev *dev)
        pci_write_config_word(dev, msi_control_reg(pos), save);
        enable_msi_mode(dev, pos, PCI_CAP_ID_MSIX);
 }
-#endif
+#endif /* CONFIG_PM */
 
 /**
  * msi_capability_init - configure device's MSI capability structure
@@ -627,22 +617,24 @@ static int msix_capability_init(struct pci_dev *dev,
  * pci_msi_supported - check whether MSI may be enabled on device
  * @dev: pointer to the pci_dev data structure of MSI device function
  *
- * MSI must be globally enabled and supported by the device and its root
- * bus. But, the root bus is not easy to find since some architectures
- * have virtual busses on top of the PCI hierarchy (for instance the
- * hypertransport bus), while the actual bus where MSI must be supported
- * is below. So we test the MSI flag on all parent busses and assume
- * that no quirk will ever set the NO_MSI flag on a non-root bus.
+ * Look at global flags, the device itself, and its parent busses
+ * to return 0 if MSI are supported for the device.
  **/
 static
 int pci_msi_supported(struct pci_dev * dev)
 {
        struct pci_bus *bus;
 
+       /* MSI must be globally enabled and supported by the device */
        if (!pci_msi_enable || !dev || dev->no_msi)
                return -EINVAL;
 
-       /* check MSI flags of all parent busses */
+       /* Any bridge which does NOT route MSI transactions from it's
+        * secondary bus to it's primary bus must set NO_MSI flag on
+        * the secondary pci_bus.
+        * We expect only arch-specific PCI host bus controller driver
+        * or quirks for specific PCI bridges to be setting NO_MSI.
+        */
        for (bus = dev->bus; bus; bus = bus->parent)
                if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI)
                        return -EINVAL;