]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/6.6.26/net-phy-micrel-lan8814-fix-when-enabling-disabling-1-step-timestamping.patch
Linux 6.6.26
[thirdparty/kernel/stable-queue.git] / releases / 6.6.26 / net-phy-micrel-lan8814-fix-when-enabling-disabling-1-step-timestamping.patch
CommitLineData
36724c58
GKH
1From de99e1ea3a35f23ff83a31d6b08f43d27b2c6345 Mon Sep 17 00:00:00 2001
2From: Horatiu Vultur <horatiu.vultur@microchip.com>
3Date: Tue, 2 Apr 2024 09:16:34 +0200
4Subject: net: phy: micrel: lan8814: Fix when enabling/disabling 1-step timestamping
5
6From: Horatiu Vultur <horatiu.vultur@microchip.com>
7
8commit de99e1ea3a35f23ff83a31d6b08f43d27b2c6345 upstream.
9
10There are 2 issues with the blamed commit.
111. When the phy is initialized, it would enable the disabled of UDPv4
12 checksums. The UDPv6 checksum is already enabled by default. So when
13 1-step is configured then it would clear these flags.
142. After the 1-step is configured, then if 2-step is configured then the
15 1-step would be still configured because it is not clearing the flag.
16 So the sync frames will still have origin timestamps set.
17
18Fix this by reading first the value of the register and then
19just change bit 12 as this one determines if the timestamp needs to
20be inserted in the frame, without changing any other bits.
21
22Fixes: ece19502834d ("net: phy: micrel: 1588 support for LAN8814 phy")
23Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
24Reviewed-by: Divya Koppera <divya.koppera@microchip.com>
25Link: https://lore.kernel.org/r/20240402071634.2483524-1-horatiu.vultur@microchip.com
26Signed-off-by: Jakub Kicinski <kuba@kernel.org>
27Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28---
29 drivers/net/phy/micrel.c | 10 ++++++++--
30 1 file changed, 8 insertions(+), 2 deletions(-)
31
32--- a/drivers/net/phy/micrel.c
33+++ b/drivers/net/phy/micrel.c
34@@ -2388,6 +2388,7 @@ static int lan8814_hwtstamp(struct mii_t
35 struct hwtstamp_config config;
36 int txcfg = 0, rxcfg = 0;
37 int pkt_ts_enable;
38+ int tx_mod;
39
40 if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
41 return -EFAULT;
42@@ -2437,9 +2438,14 @@ static int lan8814_hwtstamp(struct mii_t
43 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_RX_TIMESTAMP_EN, pkt_ts_enable);
44 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_TIMESTAMP_EN, pkt_ts_enable);
45
46- if (ptp_priv->hwts_tx_type == HWTSTAMP_TX_ONESTEP_SYNC)
47+ tx_mod = lanphy_read_page_reg(ptp_priv->phydev, 5, PTP_TX_MOD);
48+ if (ptp_priv->hwts_tx_type == HWTSTAMP_TX_ONESTEP_SYNC) {
49 lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_MOD,
50- PTP_TX_MOD_TX_PTP_SYNC_TS_INSERT_);
51+ tx_mod | PTP_TX_MOD_TX_PTP_SYNC_TS_INSERT_);
52+ } else if (ptp_priv->hwts_tx_type == HWTSTAMP_TX_ON) {
53+ lanphy_write_page_reg(ptp_priv->phydev, 5, PTP_TX_MOD,
54+ tx_mod & ~PTP_TX_MOD_TX_PTP_SYNC_TS_INSERT_);
55+ }
56
57 if (config.rx_filter != HWTSTAMP_FILTER_NONE)
58 lan8814_config_ts_intr(ptp_priv->phydev, true);