[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250822155908.625553-5-18255117159@163.com>
Date: Fri, 22 Aug 2025 23:59:05 +0800
From: Hans Zhang <18255117159@....com>
To: bhelgaas@...gle.com,
helgaas@...nel.org,
linux-pci@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Hans Zhang <18255117159@....com>
Subject: [PATCH v2 4/7] PCI: brcmstb: Replace msleep(5) with usleep_range() for precise link up checking
The msleep(5) in brcm_pcie_start_link() may sleep longer than intended
due to timer granularity, which can cause unnecessary delays in PCIe link
up detection. Replace it with usleep_range() for a more precise delay of
approximately 5ms.
Signed-off-by: Hans Zhang <18255117159@....com>
---
drivers/pci/controller/pcie-brcmstb.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
index 9afbd02ded35..6e34a052b02e 100644
--- a/drivers/pci/controller/pcie-brcmstb.c
+++ b/drivers/pci/controller/pcie-brcmstb.c
@@ -214,6 +214,8 @@
#define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_PWRDN_MASK 0x1
#define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_PWRDN_SHIFT 0x0
+#define PCIE_LINK_UP_CHECK_US 5000
+
/* Forward declarations */
struct brcm_pcie;
@@ -1365,7 +1367,8 @@ static int brcm_pcie_start_link(struct brcm_pcie *pcie)
* total of 100ms.
*/
for (i = 0; i < 100 && !brcm_pcie_link_up(pcie); i += 5)
- msleep(5);
+ usleep_range(PCIE_LINK_UP_CHECK_US,
+ PCIE_LINK_UP_CHECK_US + 100);
if (!brcm_pcie_link_up(pcie)) {
dev_err(dev, "link down\n");
--
2.25.1
Powered by blists - more mailing lists