netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2] ptp: ocp: Improve PCIe delay estimation
@ 2024-09-05 14:00 Vadim Fedorenko
  2024-09-07  2:10 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Vadim Fedorenko @ 2024-09-05 14:00 UTC (permalink / raw)
  To: Jakub Kicinski, Jonathan Lemon, Paolo Abeni, David Ahern,
	Simon Horman
  Cc: Vadim Fedorenko, netdev

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>
---
v1 -> v2:
- init delay with the highest possible value
- use monotonic raw clock to calculate delay
---
 drivers/ptp/ptp_ocp.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index ee2ced88ab34..6ea44c86f2ec 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -1552,22 +1552,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;
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next v2] ptp: ocp: Improve PCIe delay estimation
  2024-09-05 14:00 [PATCH net-next v2] ptp: ocp: Improve PCIe delay estimation Vadim Fedorenko
@ 2024-09-07  2:10 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-09-07  2:10 UTC (permalink / raw)
  To: Vadim Fedorenko; +Cc: kuba, jonathan.lemon, pabeni, dsahern, horms, netdev

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu,  5 Sep 2024 14:00:28 +0000 you wrote:
> 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>
> ---
> v1 -> v2:
> - init delay with the highest possible value
> - use monotonic raw clock to calculate delay
> 
> [...]

Here is the summary with links:
  - [net-next,v2] ptp: ocp: Improve PCIe delay estimation
    https://git.kernel.org/netdev/net-next/c/aa05fe67bcd6

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-07  2:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-05 14:00 [PATCH net-next v2] ptp: ocp: Improve PCIe delay estimation Vadim Fedorenko
2024-09-07  2:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).