diff options
author | Stefan Mätje <stefan.maetje@esd.eu> | 2019-03-29 18:07:36 +0100 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2019-04-06 16:25:53 +0200 |
commit | 658eec837b11fbfab9082ebf8da24d94cefa47c0 (patch) | |
tree | 6652b065e657eb87bb98d8ca017d2fc8fa58c316 /drivers/pci/pcie | |
parent | PCI: Work around Pericom PCIe-to-PCI bridge Retrain Link erratum (diff) | |
download | linux-658eec837b11fbfab9082ebf8da24d94cefa47c0.tar.xz linux-658eec837b11fbfab9082ebf8da24d94cefa47c0.zip |
PCI: Rework pcie_retrain_link() wait loop
Transform wait code to a "do {} while (time_before())" loop as recommended
by reviewer. No functional change intended.
Signed-off-by: Stefan Mätje <stefan.maetje@esd.eu>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'drivers/pci/pcie')
-rw-r--r-- | drivers/pci/pcie/aspm.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 38e7017478b5..fd4cb75088f9 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -199,7 +199,7 @@ static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist) 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); @@ -216,15 +216,13 @@ static bool pcie_retrain_link(struct pcie_link_state *link) } /* 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); } |