Netdev List
 help / color / mirror / Atom feed
* [PATCH 1/2] net: stmmac: Fix TX timestamp calculation
@ 2017-12-18 22:33 Fredrik Hallenberg
  2017-12-18 22:34 ` [PATCH 2/2] net: stmmac: Fix bad RX timestamp extraction Fredrik Hallenberg
  2017-12-19 19:12 ` [PATCH 1/2] net: stmmac: Fix TX timestamp calculation David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Fredrik Hallenberg @ 2017-12-18 22:33 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: Jose Abreu, David S . Miller, Giuseppe Cavallaro,
	Alexandre Torgue, Fredrik Hallenberg

When using GMAC4 the value written in PTP_SSIR should be shifted however
the shifted value is also used in subsequent calculations which results
in a bad timestamp value.

Signed-off-by: Fredrik Hallenberg <megahallon@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
index 721b61655..08c19ebd5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
@@ -34,6 +34,7 @@ static u32 stmmac_config_sub_second_increment(void __iomem *ioaddr,
 {
 	u32 value = readl(ioaddr + PTP_TCR);
 	unsigned long data;
+	u32 reg_value;
 
 	/* For GMAC3.x, 4.x versions, convert the ptp_clock to nano second
 	 *	formula = (1/ptp_clock) * 1000000000
@@ -50,10 +51,11 @@ static u32 stmmac_config_sub_second_increment(void __iomem *ioaddr,
 
 	data &= PTP_SSIR_SSINC_MASK;
 
+	reg_value = data;
 	if (gmac4)
-		data = data << GMAC4_PTP_SSIR_SSINC_SHIFT;
+		reg_value <<= GMAC4_PTP_SSIR_SSINC_SHIFT;
 
-	writel(data, ioaddr + PTP_SSIR);
+	writel(reg_value, ioaddr + PTP_SSIR);
 
 	return data;
 }
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-19 19:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-18 22:33 [PATCH 1/2] net: stmmac: Fix TX timestamp calculation Fredrik Hallenberg
2017-12-18 22:34 ` [PATCH 2/2] net: stmmac: Fix bad RX timestamp extraction Fredrik Hallenberg
2017-12-19 19:12   ` David Miller
2017-12-19 19:12 ` [PATCH 1/2] net: stmmac: Fix TX timestamp calculation David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox