From: Vadim Fedorenko <vadim.fedorenko@linux•dev>
To: Jakub Kicinski <kuba@kernel•org>,
Jonathan Lemon <jonathan.lemon@gmail•com>,
Paolo Abeni <pabeni@redhat•com>, David Ahern <dsahern@kernel•org>
Cc: Vadim Fedorenko <vadim.fedorenko@linux•dev>, netdev@vger•kernel.org
Subject: [PATCH net-next] ptp: ocp: Improve PCIe delay estimation
Date: Wed, 4 Sep 2024 13:28:42 +0000 [thread overview]
Message-ID: <20240904132842.559217-1-vadim.fedorenko@linux.dev> (raw)
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>
---
drivers/ptp/ptp_ocp.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index e7479b9b90cb..22b22e605781 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -1561,19 +1561,22 @@ ptp_ocp_estimate_pci_timing(struct ptp_ocp *bp)
ktime_t start, end;
ktime_t delay;
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_ns();
- ctrl = ioread32(&bp->reg->ctrl);
+ ctrl = ioread32(&bp->reg->ctrl);
- end = ktime_get_ns();
+ end = ktime_get_ns();
- delay = end - start;
+ delay = min(delay, end - start);
+ }
bp->ts_window_adjust = (delay >> 5) * 3;
}
--
2.43.0
next reply other threads:[~2024-09-04 13:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-04 13:28 Vadim Fedorenko [this message]
2024-09-04 20:20 ` [PATCH net-next] ptp: ocp: Improve PCIe delay estimation Simon Horman
2024-09-04 22:42 ` Vadim Fedorenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240904132842.559217-1-vadim.fedorenko@linux.dev \
--to=vadim.fedorenko@linux$(echo .)dev \
--cc=dsahern@kernel$(echo .)org \
--cc=jonathan.lemon@gmail$(echo .)com \
--cc=kuba@kernel$(echo .)org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=pabeni@redhat$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox