Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d0858e7 authored by Fredrik Hallenberg's avatar Fredrik Hallenberg Committed by Greg Kroah-Hartman
Browse files

net: stmmac: Fix TX timestamp calculation




[ Upstream commit 200922c93f008e03ddc804c6dacdf26ca1ba86d7 ]

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: default avatarFredrik Hallenberg <megahallon@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1148fee2
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -38,6 +38,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
@@ -54,10 +55,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;
}