--- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -125,6 +125,23 @@ ret = pcie_set_target_speed(dev, speed_cap, false); if (ret) goto err; + + /* + * The bus below this port has not been enumerated yet, so + * pcie_set_target_speed() cannot tell whether the link really + * retrained: it skips its "speed did not change" check on an + * empty bus, and the DLLLA wait in pcie_retrain_link() may + * return at once because DLLLA still reports the state from + * before the retrain. Give the LTSSM time to retrain and + * verify that the link survived; if it did not, fall back to + * the original target speed as in the path above. + */ + msleep(100); + pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &lnksta); + if (!(lnksta & PCI_EXP_LNKSTA_DLLLA)) { + pci_info(dev, "link went down after removing the restriction\n"); + goto err; + } } return ret;