On 6/11/2023 11:53 PM, Miroslav Lichvar wrote:
> On Mon, Jun 12, 2023 at 12:24:19PM +0800, egg car wrote:
>> 5) not only the 4 ports on the same nic, any combination of ptp0~ptp9 results
>> the same.
>>
>>
>> Have gone through the phc2sys codes, find nothing reasonable that explains
>> this issue so far.
>>
>> I can see when the large jitter happens, the measured delay also varies a
>> lot,
>> perhapse it's related to the pcie tranfication process?
>
> Yes, it's related to PCIe delays. The problem is that the kernel
> doesn't provide an ioctl to measure offset between two PHCs, so
> phc2sys has to do it in user space using clock_gettime(), which
> doesn't work very well (large delay, jitter and asymmetry).
>
> For PHC vs system clock measurements there is an optimized path in the
> kernel which for most drivers limits the delay to a single PCIe read.
>
> If you need to synchronize multiple PHCs to each other, it's better to
> use one phc2sys instance to synchronize the system clock to the source
> PHC and then another phc2sys instance to synchronize the rest of PHCs
> to the system clock.
>
In theory the kernel could be extended with an interface to perform the
comparison between two clocks in-kernel without a switch. That would be
a bit better than doing it in user space.
However, on newer platforms its likely going to be better to still use
the PHC + system clock at least on systems which support PCIe PTM, as
this allows capturing the PTP hardware clock time and system clock time
in hardware. I do not think it is possible to have arbitrary clocks go
through PTM.. I suppose you could do something like the following tho:
1) use PTM / getcrosstimestamp to get a hardware cross timestamp of
Clock A + the system time
2) use PTM / getcrosstimestamp to get a hardware cross timestamp of
Clock B + the system time
3) calculate difference between system time A and system time B measurements
4) use that to get a pretty good difference between Clock A and Clock B
time by using this relation:
(offset of A to B) = (offset of A to system) + (offset of B to system) -
((system time from first PTM) - (system time from second PTM))
_______________________________________________
Linuxptp-users mailing list
Linuxptp-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-users