From 8ca3fa5c517b0513c5f5f15164e27db8b87c1ccf Mon Sep 17 00:00:00 2001 From: Rakesh Goyal Date: Tue, 10 Oct 2023 08:15:55 +0000 Subject: [PATCH] nvethernet: Skip PHC update if no config change Issue: Restarting of PTP daemon updates the current system time in MAC registers. Fix: Configure PTP registers only if PTP daemon sends updated configuration. If the configuration is same continue with earlier registers update. System time will be set in the MAC registers at the time of ptp_early_init and the 1st ptp daemon ioctl to set HW configuration. Bug 4259584 Change-Id: Ied0eec498cfd4283b71797abf3b272d19998064f Signed-off-by: Rakesh Goyal Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2994409 (cherry picked from commit e774e69777d92a7136ec6c61571e677bfbde6ebf) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3010369 Reviewed-by: Srinivas Ramachandran GVS: Gerrit_Virtual_Submit --- drivers/net/ethernet/nvidia/nvethernet/ether_linux.c | 3 +++ drivers/net/ethernet/nvidia/nvethernet/ether_linux.h | 2 ++ drivers/net/ethernet/nvidia/nvethernet/ptp.c | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c index 23006a1f..97bdf7de 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c @@ -3035,6 +3035,8 @@ static int ether_close(struct net_device *ndev) /* Reset MAC loopback variable */ pdata->mac_loopback_mode = OSI_DISABLE; + memset(&pdata->ptp_config, 0, sizeof(sizeof(struct hwtstamp_config))); + return 0; } @@ -6973,6 +6975,7 @@ static int ether_suspend_noirq(struct device *dev) if (osi_core->mac == OSI_MAC_HW_MGBE) pm_runtime_put_sync(pdata->dev); + memset(&pdata->ptp_config, 0, sizeof(sizeof(struct hwtstamp_config))); return 0; } diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h index 83f302d1..6d024725 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h @@ -666,6 +666,8 @@ struct ether_priv_data { struct tasklet_struct lane_restart_task; /** xtra sw error counters */ struct ether_xtra_stat_counters xstats; + /** PTP configuration passed by aplication */ + struct hwtstamp_config ptp_config; }; /** diff --git a/drivers/net/ethernet/nvidia/nvethernet/ptp.c b/drivers/net/ethernet/nvidia/nvethernet/ptp.c index 0472350c..2d66548d 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ptp.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ptp.c @@ -423,6 +423,10 @@ int ether_handle_hwtstamp_ioctl(struct ether_priv_data *pdata, return -EINVAL; } + if (memcmp(&config, &pdata->ptp_config, sizeof(struct hwtstamp_config)) == 0) { + goto skip; + } + switch (config.tx_type) { case HWTSTAMP_TX_OFF: pdata->hwts_tx_en = OSI_DISABLE; @@ -607,6 +611,8 @@ int ether_handle_hwtstamp_ioctl(struct ether_priv_data *pdata, #endif /* !OSI_STRIPPED_LIB */ } + memcpy(&pdata->ptp_config, &config, sizeof(struct hwtstamp_config)); +skip: return (copy_to_user(ifr->ifr_data, &config, sizeof(struct hwtstamp_config))) ? -EFAULT : 0; }