Merge branch 'pci/hotplug'
authorBjorn Helgaas <bhelgaas@google.com>
Tue, 4 May 2021 15:43:22 +0000 (10:43 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 4 May 2021 15:43:22 +0000 (10:43 -0500)
- Fix acpiphp reference count leak (Feilong Lin)

* pci/hotplug:
  PCI: acpiphp: Fix whitespace issue
  PCI: shpchp: Remove unused shpc_writeb()
  PCI: cpqphp: Use DEFINE_SPINLOCK() for int15_lock
  ACPI / hotplug / PCI: Fix reference count leak in enable_slot()

arch/arm/mach-iop32x/n2100.c
drivers/net/ethernet/realtek/r8169_main.c
drivers/pci/pci.c
drivers/pci/pcie/rcec.c
drivers/pci/probe.c
drivers/pci/quirks.c
include/linux/pci.h

index 78b9a5e..bf99e71 100644 (file)
@@ -116,16 +116,16 @@ static struct hw_pci n2100_pci __initdata = {
 };
 
 /*
- * Both r8169 chips on the n2100 exhibit PCI parity problems.  Set
- * the ->broken_parity_status flag for both ports so that the r8169
- * driver knows it should ignore error interrupts.
+ * Both r8169 chips on the n2100 exhibit PCI parity problems.  Turn
+ * off parity reporting for both ports so we don't get error interrupts
+ * for them.
  */
 static void n2100_fixup_r8169(struct pci_dev *dev)
 {
        if (dev->bus->number == 0 &&
            (dev->devfn == PCI_DEVFN(1, 0) ||
             dev->devfn == PCI_DEVFN(2, 0)))
-               dev->broken_parity_status = 1;
+               pci_disable_parity(dev);
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REALTEK, PCI_ANY_ID, n2100_fixup_r8169);
 
index f704da3..a6aff0d 100644 (file)
@@ -4358,20 +4358,6 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev)
        if (net_ratelimit())
                netdev_err(dev, "PCI error (cmd = 0x%04x, status_errs = 0x%04x)\n",
                           pci_cmd, pci_status_errs);
-       /*
-        * The recovery sequence below admits a very elaborated explanation:
-        * - it seems to work;
-        * - I did not see what else could be done;
-        * - it makes iop3xx happy.
-        *
-        * Feel free to adjust to your needs.
-        */
-       if (pdev->broken_parity_status)
-               pci_cmd &= ~PCI_COMMAND_PARITY;
-       else
-               pci_cmd |= PCI_COMMAND_SERR | PCI_COMMAND_PARITY;
-
-       pci_write_config_word(pdev, PCI_COMMAND, pci_cmd);
 
        rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING);
 }
index 16a1721..b1845e5 100644 (file)
@@ -4453,6 +4453,23 @@ void pci_clear_mwi(struct pci_dev *dev)
 }
 EXPORT_SYMBOL(pci_clear_mwi);
 
+/**
+ * pci_disable_parity - disable parity checking for device
+ * @dev: the PCI device to operate on
+ *
+ * Disable parity checking for device @dev
+ */
+void pci_disable_parity(struct pci_dev *dev)
+{
+       u16 cmd;
+
+       pci_read_config_word(dev, PCI_COMMAND, &cmd);
+       if (cmd & PCI_COMMAND_PARITY) {
+               cmd &= ~PCI_COMMAND_PARITY;
+               pci_write_config_word(dev, PCI_COMMAND, cmd);
+       }
+}
+
 /**
  * pci_intx - enables/disables PCI INTx for device dev
  * @pdev: the PCI device to operate on
index 2c5c552..d0bcd14 100644 (file)
@@ -32,7 +32,7 @@ static bool rcec_assoc_rciep(struct pci_dev *rcec, struct pci_dev *rciep)
 
        /* Same bus, so check bitmap */
        for_each_set_bit(devn, &bitmap, 32)
-               if (devn == rciep->devfn)
+               if (devn == PCI_SLOT(rciep->devfn))
                        return true;
 
        return false;
index 953f15a..be51670 100644 (file)
@@ -2353,6 +2353,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
        pci_set_of_node(dev);
 
        if (pci_setup_device(dev)) {
+               pci_release_of_node(dev);
                pci_bus_put(dev->bus);
                kfree(dev);
                return NULL;
index 653660e..6aa9df4 100644 (file)
@@ -206,16 +206,11 @@ DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_ANY_ID, PCI_ANY_ID,
                                PCI_CLASS_BRIDGE_HOST, 8, quirk_mmio_always_on);
 
 /*
- * The Mellanox Tavor device gives false positive parity errors.  Mark this
- * device with a broken_parity_status to allow PCI scanning code to "skip"
- * this now blacklisted device.
+ * The Mellanox Tavor device gives false positive parity errors.  Disable
+ * parity error reporting.
  */
-static void quirk_mellanox_tavor(struct pci_dev *dev)
-{
-       dev->broken_parity_status = 1;  /* This device gives false positives */
-}
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_TAVOR, quirk_mellanox_tavor);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_TAVOR_BRIDGE, quirk_mellanox_tavor);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_TAVOR, pci_disable_parity);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_TAVOR_BRIDGE, pci_disable_parity);
 
 /*
  * Deal with broken BIOSes that neglect to enable passive release,
index 86c799c..4eaa773 100644 (file)
@@ -1201,6 +1201,7 @@ int __must_check pci_set_mwi(struct pci_dev *dev);
 int __must_check pcim_set_mwi(struct pci_dev *dev);
 int pci_try_set_mwi(struct pci_dev *dev);
 void pci_clear_mwi(struct pci_dev *dev);
+void pci_disable_parity(struct pci_dev *dev);
 void pci_intx(struct pci_dev *dev, int enable);
 bool pci_check_and_mask_intx(struct pci_dev *dev);
 bool pci_check_and_unmask_intx(struct pci_dev *dev);