]> git.karo-electronics.de Git - karo-tx-linux.git/commit
ENGR00288569: net:fec_ptp: fix the potential issue for storing timestamp
authorFugang Duan <B38611@freescale.com>
Tue, 19 Nov 2013 04:59:18 +0000 (12:59 +0800)
committerFugang Duan <B38611@freescale.com>
Fri, 22 Nov 2013 08:53:06 +0000 (16:53 +0800)
commit430dc3830e80a749666f9eb2aa9feba55823c6eb
tree622259633189cf3813d30112b94ee67b556a5756
parent92a24bffe9b79787e9881ffc6ede7e5e3df308f7
ENGR00288569: net:fec_ptp: fix the potential issue for storing timestamp

The timestamps generated in the i.MX drivers are generated by the
nanoseconds part coming from the 1588 clock. But the number of seconds
are maintained in a private structure of the interface. Those are
updated in a 1588 clock rollover interrupt.

The timestamp is generated right before a rollover of a second and the
timestamp value is constructed afterwards. Therefore the bigger part of
the timestamp is wrong (the second).

commit:54181c1d83e04b18e63c7723ac80f974b760e019
Suggested solution (pseudo-code):
    If( actual-time.nsec < timestamp.nsec )
        Timestamp.sec = fpp->prtc -1;
    Else
        Timestamp.sec = fpp->prtc;

But it is not perfect and there still exist potenitial second sync issue.
So, the patch Suggested solution (pseudo-code):
    If( actual-time.nsec < timestamp.nsec &&
!FEC_IEVENT[TS_TIMER] )
        Timestamp.sec = fpp->prtc -1;
    Else
        Timestamp.sec = fpp->prtc;

Signed-off-by: Fugang Duan <B38611@freescale.com>
drivers/net/ethernet/freescale/fec.h
drivers/net/ethernet/freescale/fec_main.c
drivers/net/ethernet/freescale/fec_ptp.c