Skip to content

Commit aa05fe6

Browse files
Vadim Fedorenkokuba-moo
Vadim Fedorenko
authored andcommitted
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9a95eed commit aa05fe6

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

drivers/ptp/ptp_ocp.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,22 +1558,24 @@ ptp_ocp_watchdog(struct timer_list *t)
15581558
static void
15591559
ptp_ocp_estimate_pci_timing(struct ptp_ocp *bp)
15601560
{
1561-
ktime_t start, end;
1562-
ktime_t delay;
1561+
ktime_t start, end, delay = U64_MAX;
15631562
u32 ctrl;
1563+
int i;
15641564

1565-
ctrl = ioread32(&bp->reg->ctrl);
1566-
ctrl = OCP_CTRL_READ_TIME_REQ | OCP_CTRL_ENABLE;
1565+
for (i = 0; i < 3; i++) {
1566+
ctrl = ioread32(&bp->reg->ctrl);
1567+
ctrl = OCP_CTRL_READ_TIME_REQ | OCP_CTRL_ENABLE;
15671568

1568-
iowrite32(ctrl, &bp->reg->ctrl);
1569+
iowrite32(ctrl, &bp->reg->ctrl);
15691570

1570-
start = ktime_get_ns();
1571+
start = ktime_get_raw_ns();
15711572

1572-
ctrl = ioread32(&bp->reg->ctrl);
1573+
ctrl = ioread32(&bp->reg->ctrl);
15731574

1574-
end = ktime_get_ns();
1575+
end = ktime_get_raw_ns();
15751576

1576-
delay = end - start;
1577+
delay = min(delay, end - start);
1578+
}
15771579
bp->ts_window_adjust = (delay >> 5) * 3;
15781580
}
15791581

0 commit comments

Comments
 (0)