diff mbox series

[net-next,7/8] net: stmmac: do not overwrite other flags when writing timestamp control

Message ID 20230616100409.164583-8-alexis.lothore@bootlin.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: stmmac: enable timestamp snapshots for DWMAC1000 | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 17 this patch: 17
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/build_clang fail Errors and warnings before: 21 this patch: 21
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 17 this patch: 17
netdev/checkpatch warning WARNING: line length of 82 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Alexis Lothoré (eBPF Foundation) June 16, 2023, 10:04 a.m. UTC
From: Alexis Lothoré <alexis.lothore@bootlin.com>

On some versions of GMAC IP, for example, DWMAC1000, we may overwrite some
other flags like ATSEN0 when writing Timestamp Control register.
Avoid overwriting those additional flags by setting a read-write-modify
process only on flags of interest

Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 528d2e010926..ba483adf4e1a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -616,6 +616,10 @@  static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p,
  */
 static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
 {
+	u32 reset_mask = PTP_TCR_SNAPTYPSEL_1 | PTP_TCR_TSIPV4ENA |
+			 PTP_TCR_TSIPV6ENA | PTP_TCR_TSEVNTENA |
+			 PTP_TCR_TSMSTRENA | PTP_TCR_TSVER2ENA |
+			 PTP_TCR_TSIPENA | PTP_TCR_TSENALL;
 	struct stmmac_priv *priv = netdev_priv(dev);
 	struct hwtstamp_config config;
 	u32 ptp_v2 = 0;
@@ -783,7 +787,9 @@  static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
 	priv->hwts_rx_en = ((config.rx_filter == HWTSTAMP_FILTER_NONE) ? 0 : 1);
 	priv->hwts_tx_en = config.tx_type == HWTSTAMP_TX_ON;
 
-	priv->systime_flags = STMMAC_HWTS_ACTIVE;
+	priv->systime_flags = stmmac_config_hw_tstamping_get(priv, priv->ptpaddr);
+	priv->systime_flags &= ~reset_mask;
+	priv->systime_flags |= STMMAC_HWTS_ACTIVE;
 
 	if (priv->hwts_tx_en || priv->hwts_rx_en) {
 		priv->systime_flags |= tstamp_all | ptp_v2 |