Skip to content

Commit 7604bc2

Browse files
maciej-w-rozyckibjorn-helgaas
authored andcommitted
PCI: Use pcie_wait_for_link_status() in pcie_wait_for_link_delay()
Remove a DLLLA status bit polling loop from pcie_wait_for_link_delay() and call almost identical code in pcie_wait_for_link_status() instead. This reduces the lower bound on the polling interval from 10ms to 1ms, possibly increasing the CPU load on the system in favour to reducing the wait time. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Maciej W. Rozycki <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 680e9c4 commit 7604bc2

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

drivers/pci/pci.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4928,16 +4928,14 @@ bool pcie_retrain_link(struct pci_dev *pdev, bool use_lt)
49284928
static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,
49294929
int delay)
49304930
{
4931-
int timeout = PCIE_LINK_RETRAIN_TIMEOUT_MS;
49324931
bool ret;
4933-
u16 lnk_status;
49344932

49354933
/*
49364934
* Some controllers might not implement link active reporting. In this
49374935
* case, we wait for 1000 ms + any delay requested by the caller.
49384936
*/
49394937
if (!pdev->link_active_reporting) {
4940-
msleep(timeout + delay);
4938+
msleep(PCIE_LINK_RETRAIN_TIMEOUT_MS + delay);
49414939
return true;
49424940
}
49434941

@@ -4952,20 +4950,11 @@ static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,
49524950
*/
49534951
if (active)
49544952
msleep(20);
4955-
for (;;) {
4956-
pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status);
4957-
ret = !!(lnk_status & PCI_EXP_LNKSTA_DLLLA);
4958-
if (ret == active)
4959-
break;
4960-
if (timeout <= 0)
4961-
break;
4962-
msleep(10);
4963-
timeout -= 10;
4964-
}
4953+
ret = pcie_wait_for_link_status(pdev, false, active);
49654954
if (active && ret)
49664955
msleep(delay);
49674956

4968-
return ret == active;
4957+
return ret;
49694958
}
49704959

49714960
/**

0 commit comments

Comments
 (0)