[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250822155908.625553-3-18255117159@163.com>
Date: Fri, 22 Aug 2025 23:59:03 +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 2/7] PCI: Replace msleep(1) with fsleep() for precise link status checking
The msleep(1) in pcie_wait_for_link_status() may sleep longer than
intended due to timer granularity, which can cause unnecessary delays in
link status monitoring. Replace it with fsleep() for a more precise delay
of exactly 1ms.
Signed-off-by: Hans Zhang <18255117159@....com>
---
drivers/pci/pci.c | 2 +-
drivers/pci/pci.h | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index fb4aff520f64..fff49982b2a9 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4683,7 +4683,7 @@ static int pcie_wait_for_link_status(struct pci_dev *pdev,
pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnksta);
if ((lnksta & lnksta_mask) == lnksta_match)
return 0;
- msleep(1);
+ fsleep(PCIE_LINK_STATUS_CHECK_US);
} while (time_before(jiffies, end_jiffies));
return -ETIMEDOUT;
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 471dae45e46a..e9360d8ff81d 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -16,6 +16,7 @@ struct pcie_tlp_log;
#define PCI_VSEC_ID_INTEL_TBT 0x1234 /* Thunderbolt */
#define PCIE_LINK_RETRAIN_TIMEOUT_MS 1000
+#define PCIE_LINK_STATUS_CHECK_US 1000
/*
* Power stable to PERST# inactive.
--
2.25.1
Powered by blists - more mailing lists