]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
PCI: Move MPS configuration check to pci_configure_device()
authorBjorn Helgaas <bhelgaas@google.com>
Thu, 20 Aug 2015 21:08:27 +0000 (16:08 -0500)
committerChuck Anderson <chuck.anderson@oracle.com>
Sun, 22 May 2016 18:07:32 +0000 (11:07 -0700)
Previously we checked for invalid MPS settings, i.e., a device with MPS
different than its upstream bridge, in pcie_bus_detect_mps().  We only did
this if the arch or hotplug driver called pcie_bus_configure_settings(),
and then only if PCIe bus tuning was disabled (PCIE_BUS_TUNE_OFF).

Move the MPS checking code to pci_configure_device(), so we do it in the
pci_device_add() path for every device.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
(cherry picked from commit 9dae3a97297f71e884ed8e7664955bcacb86f010)

Orabug: 23237033

Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
drivers/pci/probe.c

index 6675a7a1b9fc6a113379b9e5ac025b2a3df66ad3..22467a793e3e89b0d8d05dc365351d530e46b96e 100644 (file)
@@ -1239,6 +1239,27 @@ int pci_setup_device(struct pci_dev *dev)
        return 0;
 }
 
+static void pci_configure_mps(struct pci_dev *dev)
+{
+       struct pci_dev *bridge = pci_upstream_bridge(dev);
+       int mps, p_mps;
+
+       if (!pci_is_pcie(dev) || !bridge || !pci_is_pcie(bridge))
+               return;
+
+       mps = pcie_get_mps(dev);
+       p_mps = pcie_get_mps(bridge);
+
+       if (mps == p_mps)
+               return;
+
+       if (pcie_bus_config == PCIE_BUS_TUNE_OFF) {
+               dev_warn(&dev->dev, "Max Payload Size %d, but upstream %s set to %d; if necessary, use \"pci=pcie_bus_safe\" and report a bug\n",
+                        mps, pci_name(bridge), p_mps);
+               return;
+       }
+}
+
 static struct hpp_type0 pci_default_type0 = {
        .revision = 1,
        .cache_line_size = 8,
@@ -1360,6 +1381,8 @@ static void pci_configure_device(struct pci_dev *dev)
        struct hotplug_params hpp;
        int ret;
 
+       pci_configure_mps(dev);
+
        memset(&hpp, 0, sizeof(hpp));
        ret = pci_get_hp_params(dev, &hpp);
        if (ret)
@@ -1755,22 +1778,6 @@ static void pcie_write_mrrs(struct pci_dev *dev)
                dev_err(&dev->dev, "MRRS was unable to be configured with a safe value.  If problems are experienced, try running with pci=pcie_bus_safe\n");
 }
 
-static void pcie_bus_detect_mps(struct pci_dev *dev)
-{
-       struct pci_dev *bridge = dev->bus->self;
-       int mps, p_mps;
-
-       if (!bridge)
-               return;
-
-       mps = pcie_get_mps(dev);
-       p_mps = pcie_get_mps(bridge);
-
-       if (mps != p_mps)
-               dev_warn(&dev->dev, "Max Payload Size %d, but upstream %s set to %d; if necessary, use \"pci=pcie_bus_safe\" and report a bug\n",
-                        mps, pci_name(bridge), p_mps);
-}
-
 static int pcie_bus_configure_set(struct pci_dev *dev, void *data)
 {
        int mps, orig_mps;
@@ -1778,10 +1785,8 @@ static int pcie_bus_configure_set(struct pci_dev *dev, void *data)
        if (!pci_is_pcie(dev))
                return 0;
 
-       if (pcie_bus_config == PCIE_BUS_TUNE_OFF) {
-               pcie_bus_detect_mps(dev);
+       if (pcie_bus_config == PCIE_BUS_TUNE_OFF)
                return 0;
-       }
 
        mps = 128 << *(u8 *)data;
        orig_mps = pcie_get_mps(dev);