]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commitdf176c29a9e03920d11fbfd6a896eff9037c68a8
tree11559b54a09d07ee78ec76d9d00f914d3c28713b
parentcdf091afbc0e949893cc9c9d317e0ce181bfc5a2
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: 67b85cc22875 ("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