Subject: Re: [PATCH net v4 3/3] net: stmmac: fix unbalanced ptp clock issue in suspend/resume flow

From: kernel test robot <[email-masked]>
Date: Fri, 15 Jul 2022 06:40:45 +0800

Hi Biao,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Biao-Huang/stmmac-dwmac-mediatek-fix-clock-issue/20220713-181044
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 22b9c41a3fb8ef4624bcda312665937d2ba98aa7
config: x86_64-randconfig-a016 (https://download.01.org/0day-ci/archive/20220715/[email-masked]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 5e61b9c556267086ef9b743a0b57df302eef831b)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/f145c999bcff52c22cc849bf17f2b30c5e991c0a
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Biao-Huang/stmmac-dwmac-mediatek-fix-clock-issue/20220713-181044
        git checkout f145c999bcff52c22cc849bf17f2b30c5e991c0a
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/net/ethernet/stmicro/stmmac/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email-masked]>

All warnings (new ones prefixed by >>):

>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:837:6: warning: unused variable 'ret' [-Wunused-variable]
           int ret;
               ^
   1 warning generated.

vim +/ret +837 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

891434b18ec0a2 Rayagond Kokatanur 2013-03-26  820  
a6da2bbb0005e6 Holger Assmann     2021-11-21  821  /**
a6da2bbb0005e6 Holger Assmann     2021-11-21  822   * stmmac_init_tstamp_counter - init hardware timestamping counter
a6da2bbb0005e6 Holger Assmann     2021-11-21  823   * @priv: driver private structure
a6da2bbb0005e6 Holger Assmann     2021-11-21  824   * @systime_flags: timestamping flags
a6da2bbb0005e6 Holger Assmann     2021-11-21  825   * Description:
a6da2bbb0005e6 Holger Assmann     2021-11-21  826   * Initialize hardware counter for packet timestamping.
a6da2bbb0005e6 Holger Assmann     2021-11-21  827   * This is valid as long as the interface is open and not suspended.
a6da2bbb0005e6 Holger Assmann     2021-11-21  828   * Will be rerun after resuming from suspend, case in which the timestamping
a6da2bbb0005e6 Holger Assmann     2021-11-21  829   * flags updated by stmmac_hwtstamp_set() also need to be restored.
a6da2bbb0005e6 Holger Assmann     2021-11-21  830   */
a6da2bbb0005e6 Holger Assmann     2021-11-21  831  int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags)
a6da2bbb0005e6 Holger Assmann     2021-11-21  832  {
a6da2bbb0005e6 Holger Assmann     2021-11-21  833  	bool xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac;
a6da2bbb0005e6 Holger Assmann     2021-11-21  834  	struct timespec64 now;
a6da2bbb0005e6 Holger Assmann     2021-11-21  835  	u32 sec_inc = 0;
a6da2bbb0005e6 Holger Assmann     2021-11-21  836  	u64 temp = 0;
a6da2bbb0005e6 Holger Assmann     2021-11-21 @837  	int ret;
a6da2bbb0005e6 Holger Assmann     2021-11-21  838  
a6da2bbb0005e6 Holger Assmann     2021-11-21  839  	if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp))
a6da2bbb0005e6 Holger Assmann     2021-11-21  840  		return -EOPNOTSUPP;
a6da2bbb0005e6 Holger Assmann     2021-11-21  841  
a6da2bbb0005e6 Holger Assmann     2021-11-21  842  	stmmac_config_hw_tstamping(priv, priv->ptpaddr, systime_flags);
a6da2bbb0005e6 Holger Assmann     2021-11-21  843  	priv->systime_flags = systime_flags;
a6da2bbb0005e6 Holger Assmann     2021-11-21  844  
a6da2bbb0005e6 Holger Assmann     2021-11-21  845  	/* program Sub Second Increment reg */
a6da2bbb0005e6 Holger Assmann     2021-11-21  846  	stmmac_config_sub_second_increment(priv, priv->ptpaddr,
a6da2bbb0005e6 Holger Assmann     2021-11-21  847  					   priv->plat->clk_ptp_rate,
a6da2bbb0005e6 Holger Assmann     2021-11-21  848  					   xmac, &sec_inc);
a6da2bbb0005e6 Holger Assmann     2021-11-21  849  	temp = div_u64(1000000000ULL, sec_inc);
a6da2bbb0005e6 Holger Assmann     2021-11-21  850  
a6da2bbb0005e6 Holger Assmann     2021-11-21  851  	/* Store sub second increment for later use */
a6da2bbb0005e6 Holger Assmann     2021-11-21  852  	priv->sub_second_inc = sec_inc;
a6da2bbb0005e6 Holger Assmann     2021-11-21  853  
a6da2bbb0005e6 Holger Assmann     2021-11-21  854  	/* calculate default added value:
a6da2bbb0005e6 Holger Assmann     2021-11-21  855  	 * formula is :
a6da2bbb0005e6 Holger Assmann     2021-11-21  856  	 * addend = (2^32)/freq_div_ratio;
a6da2bbb0005e6 Holger Assmann     2021-11-21  857  	 * where, freq_div_ratio = 1e9ns/sec_inc
a6da2bbb0005e6 Holger Assmann     2021-11-21  858  	 */
a6da2bbb0005e6 Holger Assmann     2021-11-21  859  	temp = (u64)(temp << 32);
a6da2bbb0005e6 Holger Assmann     2021-11-21  860  	priv->default_addend = div_u64(temp, priv->plat->clk_ptp_rate);
a6da2bbb0005e6 Holger Assmann     2021-11-21  861  	stmmac_config_addend(priv, priv->ptpaddr, priv->default_addend);
a6da2bbb0005e6 Holger Assmann     2021-11-21  862  
a6da2bbb0005e6 Holger Assmann     2021-11-21  863  	/* initialize system time */
a6da2bbb0005e6 Holger Assmann     2021-11-21  864  	ktime_get_real_ts64(&now);
a6da2bbb0005e6 Holger Assmann     2021-11-21  865  
a6da2bbb0005e6 Holger Assmann     2021-11-21  866  	/* lower 32 bits of tv_sec are safe until y2106 */
a6da2bbb0005e6 Holger Assmann     2021-11-21  867  	stmmac_init_systime(priv, priv->ptpaddr, (u32)now.tv_sec, now.tv_nsec);
a6da2bbb0005e6 Holger Assmann     2021-11-21  868  
a6da2bbb0005e6 Holger Assmann     2021-11-21  869  	return 0;
a6da2bbb0005e6 Holger Assmann     2021-11-21  870  }
a6da2bbb0005e6 Holger Assmann     2021-11-21  871  EXPORT_SYMBOL_GPL(stmmac_init_tstamp_counter);
a6da2bbb0005e6 Holger Assmann     2021-11-21  872  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp