Subject: Re: [PATCH] net: cavium: Drop dependency of NET_VENDOR_CAVIUM on PCI

From: kbuild test robot <[email-masked]>
Date: Tue, 17 Jul 2018 09:01:59 +0800

Hi Alexander,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]
[also build test ERROR on v4.18-rc5 next-20180713]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Alexander-Sverdlin/net-cavium-Drop-dependency-of-NET_VENDOR_CAVIUM-on-PCI/20180716-002448
config: s390-defconfig (attached as .config)
compiler: s390x-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=s390 
:::::: branch date: 15 hours ago
:::::: commit date: 15 hours ago

All error/warnings (new ones prefixed by >>):

   drivers/net/ethernet/cavium/common/cavium_ptp.c: In function 'cavium_ptp_probe':
>> drivers/net/ethernet/cavium/common/cavium_ptp.c:235:8: error: implicit declaration of function 'pcim_enable_device'; did you mean 'pci_enable_device'? [-Werror=implicit-function-declaration]
     err = pcim_enable_device(pdev);
           ^~~~~~~~~~~~~~~~~~
           pci_enable_device
   drivers/net/ethernet/cavium/common/cavium_ptp.c: At top level:
>> drivers/net/ethernet/cavium/common/cavium_ptp.c:339:1: warning: data definition has no type or storage class
    module_pci_driver(cavium_ptp_driver);
    ^~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/cavium/common/cavium_ptp.c:339:1: error: type defaults to 'int' in declaration of 'module_pci_driver' [-Werror=implicit-int]
>> drivers/net/ethernet/cavium/common/cavium_ptp.c:339:1: warning: parameter names (without types) in function declaration
   drivers/net/ethernet/cavium/common/cavium_ptp.c:332:26: warning: 'cavium_ptp_driver' defined but not used [-Wunused-variable]
    static struct pci_driver cavium_ptp_driver = {
                             ^~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

# https://github.com/0day-ci/linux/commit/c862aa8f427828f2c08fdc96494152690a2ec5d0
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout c862aa8f427828f2c08fdc96494152690a2ec5d0
vim +235 drivers/net/ethernet/cavium/common/cavium_ptp.c

8c56df37 Radoslaw Biernacki 2018-01-15  216  
8c56df37 Radoslaw Biernacki 2018-01-15  217  static int cavium_ptp_probe(struct pci_dev *pdev,
8c56df37 Radoslaw Biernacki 2018-01-15  218  			    const struct pci_device_id *ent)
8c56df37 Radoslaw Biernacki 2018-01-15  219  {
8c56df37 Radoslaw Biernacki 2018-01-15  220  	struct device *dev = &pdev->dev;
8c56df37 Radoslaw Biernacki 2018-01-15  221  	struct cavium_ptp *clock;
8c56df37 Radoslaw Biernacki 2018-01-15  222  	struct cyclecounter *cc;
8c56df37 Radoslaw Biernacki 2018-01-15  223  	u64 clock_cfg;
8c56df37 Radoslaw Biernacki 2018-01-15  224  	u64 clock_comp;
8c56df37 Radoslaw Biernacki 2018-01-15  225  	int err;
8c56df37 Radoslaw Biernacki 2018-01-15  226  
8c56df37 Radoslaw Biernacki 2018-01-15  227  	clock = devm_kzalloc(dev, sizeof(*clock), GFP_KERNEL);
8c56df37 Radoslaw Biernacki 2018-01-15  228  	if (!clock) {
8c56df37 Radoslaw Biernacki 2018-01-15  229  		err = -ENOMEM;
8c56df37 Radoslaw Biernacki 2018-01-15  230  		goto error;
8c56df37 Radoslaw Biernacki 2018-01-15  231  	}
8c56df37 Radoslaw Biernacki 2018-01-15  232  
8c56df37 Radoslaw Biernacki 2018-01-15  233  	clock->pdev = pdev;
8c56df37 Radoslaw Biernacki 2018-01-15  234  
8c56df37 Radoslaw Biernacki 2018-01-15 @235  	err = pcim_enable_device(pdev);
8c56df37 Radoslaw Biernacki 2018-01-15  236  	if (err)
8c56df37 Radoslaw Biernacki 2018-01-15  237  		goto error_free;
8c56df37 Radoslaw Biernacki 2018-01-15  238  
8c56df37 Radoslaw Biernacki 2018-01-15  239  	err = pcim_iomap_regions(pdev, 1 << PCI_PTP_BAR_NO, pci_name(pdev));
8c56df37 Radoslaw Biernacki 2018-01-15  240  	if (err)
8c56df37 Radoslaw Biernacki 2018-01-15  241  		goto error_free;
8c56df37 Radoslaw Biernacki 2018-01-15  242  
8c56df37 Radoslaw Biernacki 2018-01-15  243  	clock->reg_base = pcim_iomap_table(pdev)[PCI_PTP_BAR_NO];
8c56df37 Radoslaw Biernacki 2018-01-15  244  
8c56df37 Radoslaw Biernacki 2018-01-15  245  	spin_lock_init(&clock->spin_lock);
8c56df37 Radoslaw Biernacki 2018-01-15  246  
8c56df37 Radoslaw Biernacki 2018-01-15  247  	cc = &clock->cycle_counter;
8c56df37 Radoslaw Biernacki 2018-01-15  248  	cc->read = cavium_ptp_cc_read;
8c56df37 Radoslaw Biernacki 2018-01-15  249  	cc->mask = CYCLECOUNTER_MASK(64);
8c56df37 Radoslaw Biernacki 2018-01-15  250  	cc->mult = 1;
8c56df37 Radoslaw Biernacki 2018-01-15  251  	cc->shift = 0;
8c56df37 Radoslaw Biernacki 2018-01-15  252  
8c56df37 Radoslaw Biernacki 2018-01-15  253  	timecounter_init(&clock->time_counter, &clock->cycle_counter,
8c56df37 Radoslaw Biernacki 2018-01-15  254  			 ktime_to_ns(ktime_get_real()));
8c56df37 Radoslaw Biernacki 2018-01-15  255  
8c56df37 Radoslaw Biernacki 2018-01-15  256  	clock->clock_rate = ptp_cavium_clock_get();
8c56df37 Radoslaw Biernacki 2018-01-15  257  
8c56df37 Radoslaw Biernacki 2018-01-15  258  	clock->ptp_info = (struct ptp_clock_info) {
8c56df37 Radoslaw Biernacki 2018-01-15  259  		.owner		= THIS_MODULE,
8c56df37 Radoslaw Biernacki 2018-01-15  260  		.name		= "ThunderX PTP",
8c56df37 Radoslaw Biernacki 2018-01-15  261  		.max_adj	= 1000000000ull,
8c56df37 Radoslaw Biernacki 2018-01-15  262  		.n_ext_ts	= 0,
8c56df37 Radoslaw Biernacki 2018-01-15  263  		.n_pins		= 0,
8c56df37 Radoslaw Biernacki 2018-01-15  264  		.pps		= 0,
8c56df37 Radoslaw Biernacki 2018-01-15  265  		.adjfine	= cavium_ptp_adjfine,
8c56df37 Radoslaw Biernacki 2018-01-15  266  		.adjtime	= cavium_ptp_adjtime,
8c56df37 Radoslaw Biernacki 2018-01-15  267  		.gettime64	= cavium_ptp_gettime,
8c56df37 Radoslaw Biernacki 2018-01-15  268  		.settime64	= cavium_ptp_settime,
8c56df37 Radoslaw Biernacki 2018-01-15  269  		.enable		= cavium_ptp_enable,
8c56df37 Radoslaw Biernacki 2018-01-15  270  	};
8c56df37 Radoslaw Biernacki 2018-01-15  271  
8c56df37 Radoslaw Biernacki 2018-01-15  272  	clock_cfg = readq(clock->reg_base + PTP_CLOCK_CFG);
8c56df37 Radoslaw Biernacki 2018-01-15  273  	clock_cfg |= PTP_CLOCK_CFG_PTP_EN;
8c56df37 Radoslaw Biernacki 2018-01-15  274  	writeq(clock_cfg, clock->reg_base + PTP_CLOCK_CFG);
8c56df37 Radoslaw Biernacki 2018-01-15  275  
8c56df37 Radoslaw Biernacki 2018-01-15  276  	clock_comp = ((u64)1000000000ull << 32) / clock->clock_rate;
8c56df37 Radoslaw Biernacki 2018-01-15  277  	writeq(clock_comp, clock->reg_base + PTP_CLOCK_COMP);
8c56df37 Radoslaw Biernacki 2018-01-15  278  
8c56df37 Radoslaw Biernacki 2018-01-15  279  	clock->ptp_clock = ptp_clock_register(&clock->ptp_info, dev);
8c56df37 Radoslaw Biernacki 2018-01-15  280  	if (!clock->ptp_clock) {
8c56df37 Radoslaw Biernacki 2018-01-15  281  		err = -ENODEV;
8c56df37 Radoslaw Biernacki 2018-01-15  282  		goto error_stop;
8c56df37 Radoslaw Biernacki 2018-01-15  283  	}
8c56df37 Radoslaw Biernacki 2018-01-15  284  	if (IS_ERR(clock->ptp_clock)) {
8c56df37 Radoslaw Biernacki 2018-01-15  285  		err = PTR_ERR(clock->ptp_clock);
8c56df37 Radoslaw Biernacki 2018-01-15  286  		goto error_stop;
8c56df37 Radoslaw Biernacki 2018-01-15  287  	}
8c56df37 Radoslaw Biernacki 2018-01-15  288  
8c56df37 Radoslaw Biernacki 2018-01-15  289  	pci_set_drvdata(pdev, clock);
8c56df37 Radoslaw Biernacki 2018-01-15  290  	return 0;
8c56df37 Radoslaw Biernacki 2018-01-15  291  
8c56df37 Radoslaw Biernacki 2018-01-15  292  error_stop:
8c56df37 Radoslaw Biernacki 2018-01-15  293  	clock_cfg = readq(clock->reg_base + PTP_CLOCK_CFG);
8c56df37 Radoslaw Biernacki 2018-01-15  294  	clock_cfg &= ~PTP_CLOCK_CFG_PTP_EN;
8c56df37 Radoslaw Biernacki 2018-01-15  295  	writeq(clock_cfg, clock->reg_base + PTP_CLOCK_CFG);
8c56df37 Radoslaw Biernacki 2018-01-15  296  	pcim_iounmap_regions(pdev, 1 << PCI_PTP_BAR_NO);
8c56df37 Radoslaw Biernacki 2018-01-15  297  
8c56df37 Radoslaw Biernacki 2018-01-15  298  error_free:
8c56df37 Radoslaw Biernacki 2018-01-15  299  	devm_kfree(dev, clock);
8c56df37 Radoslaw Biernacki 2018-01-15  300  
8c56df37 Radoslaw Biernacki 2018-01-15  301  error:
8c56df37 Radoslaw Biernacki 2018-01-15  302  	/* For `cavium_ptp_get()` we need to differentiate between the case
8c56df37 Radoslaw Biernacki 2018-01-15  303  	 * when the core has not tried to probe this device and the case when
8c56df37 Radoslaw Biernacki 2018-01-15  304  	 * the probe failed.  In the later case we pretend that the
8c56df37 Radoslaw Biernacki 2018-01-15  305  	 * initialization was successful and keep the error in
8c56df37 Radoslaw Biernacki 2018-01-15  306  	 * `dev->driver_data`.
8c56df37 Radoslaw Biernacki 2018-01-15  307  	 */
8c56df37 Radoslaw Biernacki 2018-01-15  308  	pci_set_drvdata(pdev, ERR_PTR(err));
8c56df37 Radoslaw Biernacki 2018-01-15  309  	return 0;
8c56df37 Radoslaw Biernacki 2018-01-15  310  }
8c56df37 Radoslaw Biernacki 2018-01-15  311  
8c56df37 Radoslaw Biernacki 2018-01-15  312  static void cavium_ptp_remove(struct pci_dev *pdev)
8c56df37 Radoslaw Biernacki 2018-01-15  313  {
8c56df37 Radoslaw Biernacki 2018-01-15  314  	struct cavium_ptp *clock = pci_get_drvdata(pdev);
8c56df37 Radoslaw Biernacki 2018-01-15  315  	u64 clock_cfg;
8c56df37 Radoslaw Biernacki 2018-01-15  316  
8c56df37 Radoslaw Biernacki 2018-01-15  317  	if (IS_ERR_OR_NULL(clock))
8c56df37 Radoslaw Biernacki 2018-01-15  318  		return;
8c56df37 Radoslaw Biernacki 2018-01-15  319  
8c56df37 Radoslaw Biernacki 2018-01-15  320  	ptp_clock_unregister(clock->ptp_clock);
8c56df37 Radoslaw Biernacki 2018-01-15  321  
8c56df37 Radoslaw Biernacki 2018-01-15  322  	clock_cfg = readq(clock->reg_base + PTP_CLOCK_CFG);
8c56df37 Radoslaw Biernacki 2018-01-15  323  	clock_cfg &= ~PTP_CLOCK_CFG_PTP_EN;
8c56df37 Radoslaw Biernacki 2018-01-15  324  	writeq(clock_cfg, clock->reg_base + PTP_CLOCK_CFG);
8c56df37 Radoslaw Biernacki 2018-01-15  325  }
8c56df37 Radoslaw Biernacki 2018-01-15  326  
8c56df37 Radoslaw Biernacki 2018-01-15  327  static const struct pci_device_id cavium_ptp_id_table[] = {
8c56df37 Radoslaw Biernacki 2018-01-15  328  	{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVICE_ID_CAVIUM_PTP) },
8c56df37 Radoslaw Biernacki 2018-01-15  329  	{ 0, }
8c56df37 Radoslaw Biernacki 2018-01-15  330  };
8c56df37 Radoslaw Biernacki 2018-01-15  331  
8c56df37 Radoslaw Biernacki 2018-01-15  332  static struct pci_driver cavium_ptp_driver = {
8c56df37 Radoslaw Biernacki 2018-01-15  333  	.name = DRV_NAME,
8c56df37 Radoslaw Biernacki 2018-01-15  334  	.id_table = cavium_ptp_id_table,
8c56df37 Radoslaw Biernacki 2018-01-15  335  	.probe = cavium_ptp_probe,
8c56df37 Radoslaw Biernacki 2018-01-15  336  	.remove = cavium_ptp_remove,
8c56df37 Radoslaw Biernacki 2018-01-15  337  };
8c56df37 Radoslaw Biernacki 2018-01-15  338  
75498aa1 Wei Yongjun        2018-03-28 @339  module_pci_driver(cavium_ptp_driver);
8c56df37 Radoslaw Biernacki 2018-01-15  340  

:::::: The code at line 235 was first introduced by commit
:::::: 8c56df372bc1371504bf3cc29fbb3c09967cafff net: add support for Cavium PTP coprocessor

:::::: TO: Radoslaw Biernacki <[email-masked]>
:::::: CC: David S. Miller <[email-masked]>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation