• Lars-Peter Clausen's avatar
    net: macb: ptp: Switch to gettimex64() interface · e51bb5c2
    Lars-Peter Clausen authored
    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: default avatarLars-Peter Clausen <lars@metafoo.de>
    Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    e51bb5c2
macb_ptp.c 13.5 KB