diff options
author | Vadim Fedorenko <vadim.fedorenko@linux.dev> | 2024-09-05 14:00:28 +0000 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2024-09-06 18:28:07 -0700 |
commit | aa05fe67bcd641378454ca9d15b539125eb0933a (patch) | |
tree | fd8dd3ea35d92731fa137041e90db53cc06a1621 | |
parent | 9a95eedc81deb86af1ac56f2c2bfe8306b27b82a (diff) | |
download | lwn-aa05fe67bcd641378454ca9d15b539125eb0933a.tar.gz lwn-aa05fe67bcd641378454ca9d15b539125eb0933a.zip |
ptp: ocp: Improve PCIe delay estimation
The PCIe bus can be pretty busy during boot and probe function can
see excessive delays. Let's find the minimal value out of several
tests and use it as estimated value.
Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20240905140028.560454-1-vadim.fedorenko@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r-- | drivers/ptp/ptp_ocp.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index e7479b9b90cb..5feecaadde8e 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -1558,22 +1558,24 @@ ptp_ocp_watchdog(struct timer_list *t) static void ptp_ocp_estimate_pci_timing(struct ptp_ocp *bp) { - ktime_t start, end; - ktime_t delay; + ktime_t start, end, delay = U64_MAX; u32 ctrl; + int i; - ctrl = ioread32(&bp->reg->ctrl); - ctrl = OCP_CTRL_READ_TIME_REQ | OCP_CTRL_ENABLE; + for (i = 0; i < 3; i++) { + ctrl = ioread32(&bp->reg->ctrl); + ctrl = OCP_CTRL_READ_TIME_REQ | OCP_CTRL_ENABLE; - iowrite32(ctrl, &bp->reg->ctrl); + iowrite32(ctrl, &bp->reg->ctrl); - start = ktime_get_ns(); + start = ktime_get_raw_ns(); - ctrl = ioread32(&bp->reg->ctrl); + ctrl = ioread32(&bp->reg->ctrl); - end = ktime_get_ns(); + end = ktime_get_raw_ns(); - delay = end - start; + delay = min(delay, end - start); + } bp->ts_window_adjust = (delay >> 5) * 3; } |