net: macb: ptp: Switch to gettimex64() interface
authorLars-Peter Clausen <lars@metafoo.de>
Wed, 29 Sep 2021 12:07:39 +0000 (14:07 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 30 Sep 2021 12:14:26 +0000 (13:14 +0100)
commite51bb5c2784c30959535ed20bda9754bbf67416a
tree5816c55b71dae30a59dd0645f9c172413944c128
parent2e861e5e97175dfa7b7bc055c45acdc06d2301d3
net: macb: ptp: Switch to gettimex64() interface

The macb PTP support currently implements the `gettime64` callback to allow
to retrieve the hardware clock time. Update the implementation to provide
the `gettimex64` callback instead.

The difference between the two is that with `gettime64` a snapshot of the
system clock is taken before and after invoking the callback. Whereas
`gettimex64` expects the callback itself to take the snapshots.

To get the time from the macb Ethernet core multiple register accesses have
to be done. Only one of which will happen at the time reported by the
function. This leads to a non-symmetric delay and adds a slight offset
between the hardware and system clock time when using the `gettime64`
method. This offset can be a few 100 nanoseconds. Switching to the
`gettimex64` method allows for a more precise correlation of the hardware
and system clocks and results in a lower offset between the two.

On a Xilinx ZynqMP system `phc2sys` reports a delay of 1120 ns before and
300 ns after the patch. With the latter being mostly symmetric.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/cadence/macb_ptp.c