Skip to content

Commit 712e49c

Browse files
maciej-w-rozyckikwilczynski
authored andcommitted
PCI: Correct error reporting with PCIe failed link retraining
Only return successful completion status from pcie_failed_link_retrain() if retraining has actually been done, preventing excessive delays from being triggered at call sites in a hope that communication will finally be established with the downstream device where in fact nothing has been done about the link in question that would justify such a hope. Fixes: a89c822 ("PCI: Work around PCIe link training failures") Link: https://lore.kernel.org/r/alpine.DEB.2.21.2408091133260.61955@angie.orcam.me.uk Reported-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/aa2d1c4e-9961-d54a-00c7-ddf8e858a9b0@linux.intel.com/ Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Cc: <stable@vger.kernel.org> # v6.5+
1 parent f68dea1 commit 712e49c

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

drivers/pci/quirks.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
* again to remove any residual state, ignoring the result as it's supposed
7979
* to fail anyway.
8080
*
81-
* Return TRUE if the link has been successfully retrained, otherwise FALSE.
81+
* Return TRUE if the link has been successfully retrained. Return FALSE
82+
* if retraining was not needed or we attempted a retrain and it failed.
8283
*/
8384
bool pcie_failed_link_retrain(struct pci_dev *dev)
8485
{
@@ -87,6 +88,7 @@ bool pcie_failed_link_retrain(struct pci_dev *dev)
8788
{}
8889
};
8990
u16 lnksta, lnkctl2;
91+
bool ret = false;
9092

9193
if (!pci_is_pcie(dev) || !pcie_downstream_port(dev) ||
9294
!pcie_cap_has_lnkctl2(dev) || !dev->link_active_reporting)
@@ -104,7 +106,8 @@ bool pcie_failed_link_retrain(struct pci_dev *dev)
104106
lnkctl2 |= PCI_EXP_LNKCTL2_TLS_2_5GT;
105107
pcie_capability_write_word(dev, PCI_EXP_LNKCTL2, lnkctl2);
106108

107-
if (pcie_retrain_link(dev, false)) {
109+
ret = pcie_retrain_link(dev, false) == 0;
110+
if (!ret) {
108111
pci_info(dev, "retraining failed\n");
109112
pcie_capability_write_word(dev, PCI_EXP_LNKCTL2,
110113
oldlnkctl2);
@@ -126,13 +129,14 @@ bool pcie_failed_link_retrain(struct pci_dev *dev)
126129
lnkctl2 |= lnkcap & PCI_EXP_LNKCAP_SLS;
127130
pcie_capability_write_word(dev, PCI_EXP_LNKCTL2, lnkctl2);
128131

129-
if (pcie_retrain_link(dev, false)) {
132+
ret = pcie_retrain_link(dev, false) == 0;
133+
if (!ret) {
130134
pci_info(dev, "retraining failed\n");
131135
return false;
132136
}
133137
}
134138

135-
return true;
139+
return ret;
136140
}
137141

138142
static ktime_t fixup_debug_start(struct pci_dev *dev,

0 commit comments

Comments
 (0)