PCI: Export PCIe link retrain timeout
authorMaciej W. Rozycki <macro@orcam.me.uk>
Sun, 11 Jun 2023 17:19:19 +0000 (18:19 +0100)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 20 Jun 2023 15:58:53 +0000 (10:58 -0500)
Convert LINK_RETRAIN_TIMEOUT from jiffies to milliseconds, accordingly
rename to PCIE_LINK_RETRAIN_TIMEOUT_MS, and make available via "pci.h" for
the PCI core to use.  Use in pcie_wait_for_link_delay().

Link: https://lore.kernel.org/r/alpine.DEB.2.21.2305310030280.59226@angie.orcam.me.uk
Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pci.c
drivers/pci/pci.h
drivers/pci/pcie/aspm.c

index 5ede93222bc12756ca5d129f208ca29322507b0d..71645d568986cfb0b37f6d00122411019b2fe0dc 100644 (file)
@@ -4867,7 +4867,7 @@ static int pci_pm_reset(struct pci_dev *dev, bool probe)
 static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,
                                     int delay)
 {
-       int timeout = 1000;
+       int timeout = PCIE_LINK_RETRAIN_TIMEOUT_MS;
        bool ret;
        u16 lnk_status;
 
index 2475098f65182dd2b5cf4aeb41d209034a1a78ae..d5fe253114f29c5cc236750c89ad3515c411f18a 100644 (file)
@@ -11,6 +11,8 @@
 
 #define PCI_VSEC_ID_INTEL_TBT  0x1234  /* Thunderbolt */
 
+#define PCIE_LINK_RETRAIN_TIMEOUT_MS   1000
+
 extern const unsigned char pcie_link_speed[];
 extern bool pci_early_dump;
 
index eaaacf24e16cc60b86fc8ad65bf6d0362f34d6ff..721e5c787cf3f19f672482097fe55173582f5d11 100644 (file)
@@ -90,8 +90,6 @@ static const char *policy_str[] = {
        [POLICY_POWER_SUPERSAVE] = "powersupersave"
 };
 
-#define LINK_RETRAIN_TIMEOUT HZ
-
 /*
  * The L1 PM substate capability is only implemented in function 0 in a
  * multi function device.
@@ -198,14 +196,14 @@ static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist)
  * @pdev: Device whose link to wait for.
  *
  * Return TRUE if successful, or FALSE if training has not completed
- * within LINK_RETRAIN_TIMEOUT jiffies.
+ * within PCIE_LINK_RETRAIN_TIMEOUT_MS milliseconds.
  */
 static bool pcie_wait_for_link_status(struct pci_dev *pdev)
 {
        unsigned long end_jiffies;
        u16 lnksta;
 
-       end_jiffies = jiffies + LINK_RETRAIN_TIMEOUT;
+       end_jiffies = jiffies + msecs_to_jiffies(PCIE_LINK_RETRAIN_TIMEOUT_MS);
        do {
                pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnksta);
                if (!(lnksta & PCI_EXP_LNKSTA_LT))