From 4a0cd5aff28584b5ef97bba7d98a4f4a89554ee6 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Apr 16 2024 08:58:21 +0000 Subject: PCI/ASPM: Factor out pcie_wait_for_retrain() (git-fixes). --- diff --git a/patches.suse/PCI-ASPM-Factor-out-pcie_wait_for_retrain.patch b/patches.suse/PCI-ASPM-Factor-out-pcie_wait_for_retrain.patch new file mode 100644 index 0000000..7a2a339 --- /dev/null +++ b/patches.suse/PCI-ASPM-Factor-out-pcie_wait_for_retrain.patch @@ -0,0 +1,71 @@ +From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= +Date: Tue, 20 Jun 2023 14:49:33 -0500 +Subject: PCI/ASPM: Factor out pcie_wait_for_retrain() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Git-commit: 9c7f136433d26592cb4d9cd00b4e15c33d9797c6 +Patch-mainline: 6.5-rc1 +References: git-fixes + +Factor pcie_wait_for_retrain() out from pcie_retrain_link(). No functional +change intended. + +[bhelgaas: split out from +https://lore.kernel.org/r/20230502083923.34562-1-ilpo.jarvinen@linux.intel.com] +Signed-off-by: Ilpo Järvinen +Signed-off-by: Bjorn Helgaas +Signed-off-by: Jiri Slaby +--- + drivers/pci/pcie/aspm.c | 30 ++++++++++++++++++------------ + 1 file changed, 18 insertions(+), 12 deletions(-) + +--- a/drivers/pci/pcie/aspm.c ++++ b/drivers/pci/pcie/aspm.c +@@ -203,10 +203,26 @@ static void pcie_clkpm_cap_init(struct p + link->clkpm_disable = blacklist ? 1 : 0; + } + ++static int pcie_wait_for_retrain(struct pci_dev *pdev) ++{ ++ unsigned long end_jiffies; ++ u16 reg16; ++ ++ /* Wait for Link Training to be cleared by hardware */ ++ end_jiffies = jiffies + LINK_RETRAIN_TIMEOUT; ++ do { ++ pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, ®16); ++ if (!(reg16 & PCI_EXP_LNKSTA_LT)) ++ return 0; ++ msleep(1); ++ } while (time_before(jiffies, end_jiffies)); ++ ++ return -ETIMEDOUT; ++} ++ + static int pcie_retrain_link(struct pcie_link_state *link) + { + struct pci_dev *parent = link->pdev; +- unsigned long end_jiffies; + u16 reg16; + + pcie_capability_read_word(parent, PCI_EXP_LNKCTL, ®16); +@@ -222,17 +238,7 @@ static int pcie_retrain_link(struct pcie + pcie_capability_write_word(parent, PCI_EXP_LNKCTL, reg16); + } + +- /* Wait for link training end. Break out after waiting for timeout */ +- end_jiffies = jiffies + LINK_RETRAIN_TIMEOUT; +- do { +- pcie_capability_read_word(parent, PCI_EXP_LNKSTA, ®16); +- if (!(reg16 & PCI_EXP_LNKSTA_LT)) +- break; +- msleep(1); +- } while (time_before(jiffies, end_jiffies)); +- if (reg16 & PCI_EXP_LNKSTA_LT) +- return -ETIMEDOUT; +- return 0; ++ return pcie_wait_for_retrain(parent); + } + + /* diff --git a/series.conf b/series.conf index f239076..a792d48 100644 --- a/series.conf +++ b/series.conf @@ -64698,6 +64698,7 @@ patches.suse/scsi-qla2xxx-Remove-unused-nvme_ls_waitq-wait-queue.patch patches.suse/PCI-ASPM-Disable-ASPM-on-MFD-function-removal-to-avo.patch patches.suse/PCI-ASPM-Return-0-or-ETIMEDOUT-from-pcie_retrain_lin.patch + patches.suse/PCI-ASPM-Factor-out-pcie_wait_for_retrain.patch patches.suse/USB-serial-option-add-LARA-R6-01B-PIDs.patch patches.suse/KVM-s390-vsie-fix-the-length-of-APCB-bitmap.patch patches.suse/md-raid0-add-discard-support-for-the-original-layout-e836.patch