summaryrefslogtreecommitdiff
path: root/drivers/pci/quirks.c
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@orcam.me.uk>2024-08-09 14:24:56 +0100
committerKrzysztof Wilczyński <kwilczynski@kernel.org>2024-09-09 13:58:38 +0000
commit712e49c967064a3a7a5738c6f65ac540a3f6a1df (patch)
treeb8eb90822d4414a00a6706090dcc906370a87a50 /drivers/pci/quirks.c
parentf68dea13405c94381d08f42dbf0416261622bdad (diff)
downloadlinux-712e49c967064a3a7a5738c6f65ac540a3f6a1df.tar.gz
linux-712e49c967064a3a7a5738c6f65ac540a3f6a1df.tar.bz2
linux-712e49c967064a3a7a5738c6f65ac540a3f6a1df.zip
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: a89c82249c37 ("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+
Diffstat (limited to 'drivers/pci/quirks.c')
-rw-r--r--drivers/pci/quirks.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index ee86793109ff..4d5483e9f63f 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -78,7 +78,8 @@
* again to remove any residual state, ignoring the result as it's supposed
* to fail anyway.
*
- * Return TRUE if the link has been successfully retrained, otherwise FALSE.
+ * Return TRUE if the link has been successfully retrained. Return FALSE
+ * if retraining was not needed or we attempted a retrain and it failed.
*/
bool pcie_failed_link_retrain(struct pci_dev *dev)
{
@@ -87,6 +88,7 @@ bool pcie_failed_link_retrain(struct pci_dev *dev)
{}
};
u16 lnksta, lnkctl2;
+ bool ret = false;
if (!pci_is_pcie(dev) || !pcie_downstream_port(dev) ||
!pcie_cap_has_lnkctl2(dev) || !dev->link_active_reporting)
@@ -104,7 +106,8 @@ bool pcie_failed_link_retrain(struct pci_dev *dev)
lnkctl2 |= PCI_EXP_LNKCTL2_TLS_2_5GT;
pcie_capability_write_word(dev, PCI_EXP_LNKCTL2, lnkctl2);
- if (pcie_retrain_link(dev, false)) {
+ ret = pcie_retrain_link(dev, false) == 0;
+ if (!ret) {
pci_info(dev, "retraining failed\n");
pcie_capability_write_word(dev, PCI_EXP_LNKCTL2,
oldlnkctl2);
@@ -126,13 +129,14 @@ bool pcie_failed_link_retrain(struct pci_dev *dev)
lnkctl2 |= lnkcap & PCI_EXP_LNKCAP_SLS;
pcie_capability_write_word(dev, PCI_EXP_LNKCTL2, lnkctl2);
- if (pcie_retrain_link(dev, false)) {
+ ret = pcie_retrain_link(dev, false) == 0;
+ if (!ret) {
pci_info(dev, "retraining failed\n");
return false;
}
}
- return true;
+ return ret;
}
static ktime_t fixup_debug_start(struct pci_dev *dev,