Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/alpine.DEB.2.21.2306111611170.64925@angie.orcam.me.uk
Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Maciej W. Rozycki and committed by
Bjorn Helgaas
7604bc29 680e9c47

+3 -14
+3 -14
drivers/pci/pci.c
··· 4928 4928 static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active, 4929 4929 int delay) 4930 4930 { 4931 - int timeout = PCIE_LINK_RETRAIN_TIMEOUT_MS; 4932 4931 bool ret; 4933 - u16 lnk_status; 4934 4932 4935 4933 /* 4936 4934 * Some controllers might not implement link active reporting. In this 4937 4935 * case, we wait for 1000 ms + any delay requested by the caller. 4938 4936 */ 4939 4937 if (!pdev->link_active_reporting) { 4940 - msleep(timeout + delay); 4938 + msleep(PCIE_LINK_RETRAIN_TIMEOUT_MS + delay); 4941 4939 return true; 4942 4940 } 4943 4941 ··· 4950 4952 */ 4951 4953 if (active) 4952 4954 msleep(20); 4953 - for (;;) { 4954 - pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status); 4955 - ret = !!(lnk_status & PCI_EXP_LNKSTA_DLLLA); 4956 - if (ret == active) 4957 - break; 4958 - if (timeout <= 0) 4959 - break; 4960 - msleep(10); 4961 - timeout -= 10; 4962 - } 4955 + ret = pcie_wait_for_link_status(pdev, false, active); 4963 4956 if (active && ret) 4964 4957 msleep(delay); 4965 4958 4966 - return ret == active; 4959 + return ret; 4967 4960 } 4968 4961 4969 4962 /**