From d9aa8afb2ed1cf977bc147317686fce30800301a Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Apr 16 2024 08:57:46 +0000 Subject: PCI: Rework pcie_retrain_link() wait loop (git-fixes). --- diff --git a/patches.suse/PCI-Rework-pcie_retrain_link-wait-loop.patch b/patches.suse/PCI-Rework-pcie_retrain_link-wait-loop.patch new file mode 100644 index 0000000..fbb2ed0 --- /dev/null +++ b/patches.suse/PCI-Rework-pcie_retrain_link-wait-loop.patch @@ -0,0 +1,51 @@ +From: =?UTF-8?q?Stefan=20M=C3=A4tje?= +Date: Fri, 29 Mar 2019 18:07:36 +0100 +Subject: PCI: Rework pcie_retrain_link() wait loop +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Git-commit: 658eec837b11fbfab9082ebf8da24d94cefa47c0 +Patch-mainline: 5.2-rc1 +References: git-fixes + +Transform wait code to a "do {} while (time_before())" loop as recommended +by reviewer. No functional change intended. + +Signed-off-by: Stefan Mätje +Signed-off-by: Bjorn Helgaas +Reviewed-by: Andy Shevchenko +Signed-off-by: Jiri Slaby +--- + drivers/pci/pcie/aspm.c | 10 ++++------ + 1 file changed, 4 insertions(+), 6 deletions(-) + +--- a/drivers/pci/pcie/aspm.c ++++ b/drivers/pci/pcie/aspm.c +@@ -201,7 +201,7 @@ static void pcie_clkpm_cap_init(struct p + static bool pcie_retrain_link(struct pcie_link_state *link) + { + struct pci_dev *parent = link->pdev; +- unsigned long start_jiffies; ++ unsigned long end_jiffies; + u16 reg16; + + pcie_capability_read_word(parent, PCI_EXP_LNKCTL, ®16); +@@ -218,15 +218,13 @@ static bool pcie_retrain_link(struct pci + } + + /* Wait for link training end. Break out after waiting for timeout */ +- start_jiffies = jiffies; +- for (;;) { ++ end_jiffies = jiffies + LINK_RETRAIN_TIMEOUT; ++ do { + pcie_capability_read_word(parent, PCI_EXP_LNKSTA, ®16); + if (!(reg16 & PCI_EXP_LNKSTA_LT)) + break; +- if (time_after(jiffies, start_jiffies + LINK_RETRAIN_TIMEOUT)) +- break; + msleep(1); +- } ++ } while (time_before(jiffies, end_jiffies)); + return !(reg16 & PCI_EXP_LNKSTA_LT); + } + diff --git a/series.conf b/series.conf index f2b1ccd..2100871 100644 --- a/series.conf +++ b/series.conf @@ -50480,6 +50480,7 @@ patches.suse/PCI-Init-PCIe-feature-bits-for-managed-host-bridge-a.patch patches.suse/PCI-Factor-out-pcie_retrain_link-function.patch patches.suse/PCI-Work-around-Pericom-PCIe-to-PCI-bridge-Retrain-L.patch + patches.suse/PCI-Rework-pcie_retrain_link-wait-loop.patch patches.suse/PCI-rpadlpar-Fix-leaked-device_node-references-in-ad.patch patches.suse/x86-PCI-Fix-PCI-IRQ-routing-table-memory-leak.patch patches.suse/switchtec-Fix-unintended-mask-of-MRPC-event.patch