Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'pci/yijing-mps-v8' into next

* pci/yijing-mps-v8:
PCI: Warn if unsafe MPS settings detected
PCI: Fix MPS peer-to-peer DMA comment syntax
PCI: Don't restrict MPS for slots below Root Ports
PCI: Simplify MPS test for Downstream Port
PCI: Remove unnecessary check for pcie_get_mps() failure
PCI: Simplify pcie_bus_configure_settings() interface
PCI: Drop "PCI-E" prefix from Max Payload Size message

+53 -51
+2 -6
arch/powerpc/kernel/pci-common.c
··· 1672 1672 /* Configure PCI Express settings */ 1673 1673 if (bus && !pci_has_flag(PCI_PROBE_ONLY)) { 1674 1674 struct pci_bus *child; 1675 - list_for_each_entry(child, &bus->children, node) { 1676 - struct pci_dev *self = child->self; 1677 - if (!self) 1678 - continue; 1679 - pcie_bus_configure_settings(child, self->pcie_mpss); 1680 - } 1675 + list_for_each_entry(child, &bus->children, node) 1676 + pcie_bus_configure_settings(child); 1681 1677 } 1682 1678 } 1683 1679
+2 -7
arch/tile/kernel/pci_gx.c
··· 508 508 rc_dev_cap.word); 509 509 510 510 /* Configure PCI Express MPS setting. */ 511 - list_for_each_entry(child, &root_bus->children, node) { 512 - struct pci_dev *self = child->self; 513 - if (!self) 514 - continue; 515 - 516 - pcie_bus_configure_settings(child, self->pcie_mpss); 517 - } 511 + list_for_each_entry(child, &root_bus->children, node) 512 + pcie_bus_configure_settings(child); 518 513 519 514 /* 520 515 * Set the mac_config register in trio based on the MPS/MRS of the link.
+2 -7
arch/x86/pci/acpi.c
··· 568 568 */ 569 569 if (bus) { 570 570 struct pci_bus *child; 571 - list_for_each_entry(child, &bus->children, node) { 572 - struct pci_dev *self = child->self; 573 - if (!self) 574 - continue; 575 - 576 - pcie_bus_configure_settings(child, self->pcie_mpss); 577 - } 571 + list_for_each_entry(child, &bus->children, node) 572 + pcie_bus_configure_settings(child); 578 573 } 579 574 580 575 if (bus && node != -1) {
+2 -3
drivers/pci/hotplug/pcihp_slot.c
··· 160 160 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI))) 161 161 return; 162 162 163 - if (dev->bus && dev->bus->self) 164 - pcie_bus_configure_settings(dev->bus, 165 - dev->bus->self->pcie_mpss); 163 + if (dev->bus) 164 + pcie_bus_configure_settings(dev->bus); 166 165 167 166 memset(&hpp, 0, sizeof(hpp)); 168 167 ret = pci_get_hp_params(dev, &hpp);
-3
drivers/pci/pci.c
··· 3939 3939 if (pcie_bus_config == PCIE_BUS_PERFORMANCE) { 3940 3940 int mps = pcie_get_mps(dev); 3941 3941 3942 - if (mps < 0) 3943 - return mps; 3944 3942 if (mps < rq) 3945 3943 rq = mps; 3946 3944 } ··· 3955 3957 * @dev: PCI device to query 3956 3958 * 3957 3959 * Returns maximum payload size in bytes 3958 - * or appropriate error value. 3959 3960 */ 3960 3961 int pcie_get_mps(struct pci_dev *dev) 3961 3962 {
+44 -24
drivers/pci/probe.c
··· 1491 1491 if (!pci_is_pcie(dev)) 1492 1492 return 0; 1493 1493 1494 - /* For PCIE hotplug enabled slots not connected directly to a 1495 - * PCI-E root port, there can be problems when hotplugging 1496 - * devices. This is due to the possibility of hotplugging a 1497 - * device into the fabric with a smaller MPS that the devices 1498 - * currently running have configured. Modifying the MPS on the 1499 - * running devices could cause a fatal bus error due to an 1500 - * incoming frame being larger than the newly configured MPS. 1501 - * To work around this, the MPS for the entire fabric must be 1502 - * set to the minimum size. Any devices hotplugged into this 1503 - * fabric will have the minimum MPS set. If the PCI hotplug 1504 - * slot is directly connected to the root port and there are not 1505 - * other devices on the fabric (which seems to be the most 1506 - * common case), then this is not an issue and MPS discovery 1507 - * will occur as normal. 1494 + /* 1495 + * We don't have a way to change MPS settings on devices that have 1496 + * drivers attached. A hot-added device might support only the minimum 1497 + * MPS setting (MPS=128). Therefore, if the fabric contains a bridge 1498 + * where devices may be hot-added, we limit the fabric MPS to 128 so 1499 + * hot-added devices will work correctly. 1500 + * 1501 + * However, if we hot-add a device to a slot directly below a Root 1502 + * Port, it's impossible for there to be other existing devices below 1503 + * the port. We don't limit the MPS in this case because we can 1504 + * reconfigure MPS on both the Root Port and the hot-added device, 1505 + * and there are no other devices involved. 1506 + * 1507 + * Note that this PCIE_BUS_SAFE path assumes no peer-to-peer DMA. 1508 1508 */ 1509 - if (dev->is_hotplug_bridge && (!list_is_singular(&dev->bus->devices) || 1510 - (dev->bus->self && 1511 - pci_pcie_type(dev->bus->self) != PCI_EXP_TYPE_ROOT_PORT))) 1509 + if (dev->is_hotplug_bridge && 1510 + pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) 1512 1511 *smpss = 0; 1513 1512 1514 1513 if (*smpss > dev->pcie_mpss) ··· 1582 1583 "with pci=pcie_bus_safe.\n"); 1583 1584 } 1584 1585 1586 + static void pcie_bus_detect_mps(struct pci_dev *dev) 1587 + { 1588 + struct pci_dev *bridge = dev->bus->self; 1589 + int mps, p_mps; 1590 + 1591 + if (!bridge) 1592 + return; 1593 + 1594 + mps = pcie_get_mps(dev); 1595 + p_mps = pcie_get_mps(bridge); 1596 + 1597 + if (mps != p_mps) 1598 + 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", 1599 + mps, pci_name(bridge), p_mps); 1600 + } 1601 + 1585 1602 static int pcie_bus_configure_set(struct pci_dev *dev, void *data) 1586 1603 { 1587 1604 int mps, orig_mps; ··· 1605 1590 if (!pci_is_pcie(dev)) 1606 1591 return 0; 1607 1592 1593 + if (pcie_bus_config == PCIE_BUS_TUNE_OFF) { 1594 + pcie_bus_detect_mps(dev); 1595 + return 0; 1596 + } 1597 + 1608 1598 mps = 128 << *(u8 *)data; 1609 1599 orig_mps = pcie_get_mps(dev); 1610 1600 1611 1601 pcie_write_mps(dev, mps); 1612 1602 pcie_write_mrrs(dev); 1613 1603 1614 - dev_info(&dev->dev, "PCI-E Max Payload Size set to %4d/%4d (was %4d), " 1604 + dev_info(&dev->dev, "Max Payload Size set to %4d/%4d (was %4d), " 1615 1605 "Max Read Rq %4d\n", pcie_get_mps(dev), 128 << dev->pcie_mpss, 1616 1606 orig_mps, pcie_get_readrq(dev)); 1617 1607 ··· 1627 1607 * parents then children fashion. If this changes, then this code will not 1628 1608 * work as designed. 1629 1609 */ 1630 - void pcie_bus_configure_settings(struct pci_bus *bus, u8 mpss) 1610 + void pcie_bus_configure_settings(struct pci_bus *bus) 1631 1611 { 1632 1612 u8 smpss; 1613 + 1614 + if (!bus->self) 1615 + return; 1633 1616 1634 1617 if (!pci_is_pcie(bus->self)) 1635 1618 return; 1636 1619 1637 - if (pcie_bus_config == PCIE_BUS_TUNE_OFF) 1638 - return; 1639 - 1640 1620 /* FIXME - Peer to peer DMA is possible, though the endpoint would need 1641 - * to be aware to the MPS of the destination. To work around this, 1621 + * to be aware of the MPS of the destination. To work around this, 1642 1622 * simply force the MPS of the entire system to the smallest possible. 1643 1623 */ 1644 1624 if (pcie_bus_config == PCIE_BUS_PEER2PEER) 1645 1625 smpss = 0; 1646 1626 1647 1627 if (pcie_bus_config == PCIE_BUS_SAFE) { 1648 - smpss = mpss; 1628 + smpss = bus->self->pcie_mpss; 1649 1629 1650 1630 pcie_find_smpss(bus->self, &smpss); 1651 1631 pci_walk_bus(bus, pcie_find_smpss, &smpss);
+1 -1
include/linux/pci.h
··· 675 675 /* these external functions are only available when PCI support is enabled */ 676 676 #ifdef CONFIG_PCI 677 677 678 - void pcie_bus_configure_settings(struct pci_bus *bus, u8 smpss); 678 + void pcie_bus_configure_settings(struct pci_bus *bus); 679 679 680 680 enum pcie_bus_config_types { 681 681 PCIE_BUS_TUNE_OFF,