aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/probe.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2015-08-20 17:08:27 -0400
committerBjorn Helgaas <bhelgaas@google.com>2015-08-20 17:08:27 -0400
commit9dae3a97297f71e884ed8e7664955bcacb86f010 (patch)
tree457e77855b557bf729d86d8bd53da6f4da8176a3 /drivers/pci/probe.c
parent3a10766d0624c72b978790dba864cf7d6160f89f (diff)
PCI: Move MPS configuration check to pci_configure_device()
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>
Diffstat (limited to 'drivers/pci/probe.c')
-rw-r--r--drivers/pci/probe.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 9ff4df0db0c3..eb32395d5897 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1275,6 +1275,27 @@ int pci_setup_device(struct pci_dev *dev)
1275 return 0; 1275 return 0;
1276} 1276}
1277 1277
1278static void pci_configure_mps(struct pci_dev *dev)
1279{
1280 struct pci_dev *bridge = pci_upstream_bridge(dev);
1281 int mps, p_mps;
1282
1283 if (!pci_is_pcie(dev) || !bridge || !pci_is_pcie(bridge))
1284 return;
1285
1286 mps = pcie_get_mps(dev);
1287 p_mps = pcie_get_mps(bridge);
1288
1289 if (mps == p_mps)
1290 return;
1291
1292 if (pcie_bus_config == PCIE_BUS_TUNE_OFF) {
1293 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",
1294 mps, pci_name(bridge), p_mps);
1295 return;
1296 }
1297}
1298
1278static struct hpp_type0 pci_default_type0 = { 1299static struct hpp_type0 pci_default_type0 = {
1279 .revision = 1, 1300 .revision = 1,
1280 .cache_line_size = 8, 1301 .cache_line_size = 8,
@@ -1396,6 +1417,8 @@ static void pci_configure_device(struct pci_dev *dev)
1396 struct hotplug_params hpp; 1417 struct hotplug_params hpp;
1397 int ret; 1418 int ret;
1398 1419
1420 pci_configure_mps(dev);
1421
1399 memset(&hpp, 0, sizeof(hpp)); 1422 memset(&hpp, 0, sizeof(hpp));
1400 ret = pci_get_hp_params(dev, &hpp); 1423 ret = pci_get_hp_params(dev, &hpp);
1401 if (ret) 1424 if (ret)
@@ -1791,22 +1814,6 @@ static void pcie_write_mrrs(struct pci_dev *dev)
1791 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"); 1814 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");
1792} 1815}
1793 1816
1794static void pcie_bus_detect_mps(struct pci_dev *dev)
1795{
1796 struct pci_dev *bridge = dev->bus->self;
1797 int mps, p_mps;
1798
1799 if (!bridge)
1800 return;
1801
1802 mps = pcie_get_mps(dev);
1803 p_mps = pcie_get_mps(bridge);
1804
1805 if (mps != p_mps)
1806 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",
1807 mps, pci_name(bridge), p_mps);
1808}
1809
1810static int pcie_bus_configure_set(struct pci_dev *dev, void *data) 1817static int pcie_bus_configure_set(struct pci_dev *dev, void *data)
1811{ 1818{
1812 int mps, orig_mps; 1819 int mps, orig_mps;
@@ -1814,10 +1821,8 @@ static int pcie_bus_configure_set(struct pci_dev *dev, void *data)
1814 if (!pci_is_pcie(dev)) 1821 if (!pci_is_pcie(dev))
1815 return 0; 1822 return 0;
1816 1823
1817 if (pcie_bus_config == PCIE_BUS_TUNE_OFF) { 1824 if (pcie_bus_config == PCIE_BUS_TUNE_OFF)
1818 pcie_bus_detect_mps(dev);
1819 return 0; 1825 return 0;
1820 }
1821 1826
1822 mps = 128 << *(u8 *)data; 1827 mps = 128 << *(u8 *)data;
1823 orig_mps = pcie_get_mps(dev); 1828 orig_mps = pcie_get_mps(dev);