net: stmmac: ensure PTP time register reads are consistent
authorYannick Vignon <yannick.vignon@nxp.com>
Thu, 3 Feb 2022 16:00:25 +0000 (17:00 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 3 Feb 2022 21:54:19 +0000 (13:54 -0800)
commit80d4609008e6d696a279e39ae7458c916fcd44c1
tree11559b54a09d07ee78ec76d9d00f914d3c28713b
parent77b1b8b43ec3c060ecf7e926a92b0f8772171046
net: stmmac: ensure PTP time register reads are consistent

Even if protected from preemption and interrupts, a small time window
remains when the 2 register reads could return inconsistent values,
each time the "seconds" register changes. This could lead to an about
1-second error in the reported time.

Add logic to ensure the "seconds" and "nanoseconds" values are consistent.

Fixes: 92ba6888510c ("stmmac: add the support for PTP hw clock driver")
Signed-off-by: Yannick Vignon <yannick.vignon@nxp.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/r/20220203160025.750632-1-yannick.vignon@oss.nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c