[2/7] misc: pci_endpoint_test: Do not request or allocate IRQs in probe

Message ID 20191230123315.31037-3-kishon@ti.com
State New
Headers show
Series
  • Improvements to pci_endpoint_test driver
Related show

Commit Message

Kishon Vijay Abraham I Dec. 30, 2019, 12:33 p.m.
Allocation of IRQ vectors and requesting IRQ is done as part of
PCITEST_SET_IRQTYPE. Do not request or allocate IRQs in probe for
AM654 and J721E so that the user space test script has better control
of the devices for which the IRQs are configured.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

---
 drivers/misc/pci_endpoint_test.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

-- 
2.17.1

Comments

kbuild test robot Dec. 30, 2019, 3:07 p.m. | #1
Hi Kishon,

I love your patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on pci/next arm-soc/for-next linus/master v5.5-rc4 next-20191220]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Kishon-Vijay-Abraham-I/Improvements-to-pci_endpoint_test-driver/20191230-203402
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git d1eef1c619749b2a57e514a3fa67d9a516ffa919
config: s390-randconfig-a001-20191230 (attached as .config)
compiler: s390-linux-gcc (GCC) 7.5.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.5.0 make.cross ARCH=s390 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

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

   drivers//misc/pci_endpoint_test.c: In function 'pci_endpoint_test_probe':
>> drivers//misc/pci_endpoint_test.c:73:22: error: 'PCI_DEVICE_ID_TI_J721E' undeclared (first use in this function); did you mean 'PCI_DEVICE_ID_TI_7510'?

      ((pdev)->device == PCI_DEVICE_ID_TI_J721E)
                         ^
>> drivers//misc/pci_endpoint_test.c:693:34: note: in expansion of macro 'is_j721e_pci_dev'

     if (!(is_am654_pci_dev(pdev) || is_j721e_pci_dev(pdev))) {
                                     ^~~~~~~~~~~~~~~~
   drivers//misc/pci_endpoint_test.c:73:22: note: each undeclared identifier is reported only once for each function it appears in
      ((pdev)->device == PCI_DEVICE_ID_TI_J721E)
                         ^
>> drivers//misc/pci_endpoint_test.c:693:34: note: in expansion of macro 'is_j721e_pci_dev'

     if (!(is_am654_pci_dev(pdev) || is_j721e_pci_dev(pdev))) {
                                     ^~~~~~~~~~~~~~~~

vim +73 drivers//misc/pci_endpoint_test.c

    68	
    69	#define is_am654_pci_dev(pdev)		\
    70			((pdev)->device == PCI_DEVICE_ID_TI_AM654)
    71	
    72	#define is_j721e_pci_dev(pdev)         \
  > 73			((pdev)->device == PCI_DEVICE_ID_TI_J721E)

    74	

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
kbuild test robot Dec. 30, 2019, 5:10 p.m. | #2
Hi Kishon,

I love your patch! Perhaps something to improve:

[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on pci/next arm-soc/for-next linus/master v5.5-rc4 next-20191220]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Kishon-Vijay-Abraham-I/Improvements-to-pci_endpoint_test-driver/20191230-203402
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git d1eef1c619749b2a57e514a3fa67d9a516ffa919
config: arm-randconfig-a001-20191229 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 7.5.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.5.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:11:0,
                    from include/linux/delay.h:22,
                    from drivers/misc/pci_endpoint_test.c:10:
   drivers/misc/pci_endpoint_test.c: In function 'pci_endpoint_test_probe':
   drivers/misc/pci_endpoint_test.c:73:22: error: 'PCI_DEVICE_ID_TI_J721E' undeclared (first use in this function); did you mean 'PCI_DEVICE_ID_TI_7510'?
      ((pdev)->device == PCI_DEVICE_ID_TI_J721E)
                         ^
   include/linux/compiler.h:58:52: note: in definition of macro '__trace_if_var'
    #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
                                                       ^~~~
>> drivers/misc/pci_endpoint_test.c:693:2: note: in expansion of macro 'if'

     if (!(is_am654_pci_dev(pdev) || is_j721e_pci_dev(pdev))) {
     ^~
   drivers/misc/pci_endpoint_test.c:693:34: note: in expansion of macro 'is_j721e_pci_dev'
     if (!(is_am654_pci_dev(pdev) || is_j721e_pci_dev(pdev))) {
                                     ^~~~~~~~~~~~~~~~
   drivers/misc/pci_endpoint_test.c:73:22: note: each undeclared identifier is reported only once for each function it appears in
      ((pdev)->device == PCI_DEVICE_ID_TI_J721E)
                         ^
   include/linux/compiler.h:58:52: note: in definition of macro '__trace_if_var'
    #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
                                                       ^~~~
>> drivers/misc/pci_endpoint_test.c:693:2: note: in expansion of macro 'if'

     if (!(is_am654_pci_dev(pdev) || is_j721e_pci_dev(pdev))) {
     ^~
   drivers/misc/pci_endpoint_test.c:693:34: note: in expansion of macro 'is_j721e_pci_dev'
     if (!(is_am654_pci_dev(pdev) || is_j721e_pci_dev(pdev))) {
                                     ^~~~~~~~~~~~~~~~

vim +/if +693 drivers/misc/pci_endpoint_test.c

   638	
   639	static int pci_endpoint_test_probe(struct pci_dev *pdev,
   640					   const struct pci_device_id *ent)
   641	{
   642		int err;
   643		int id;
   644		char name[20];
   645		enum pci_barno bar;
   646		void __iomem *base;
   647		struct device *dev = &pdev->dev;
   648		struct pci_endpoint_test *test;
   649		struct pci_endpoint_test_data *data;
   650		enum pci_barno test_reg_bar = BAR_0;
   651		struct miscdevice *misc_device;
   652	
   653		if (pci_is_bridge(pdev))
   654			return -ENODEV;
   655	
   656		test = devm_kzalloc(dev, sizeof(*test), GFP_KERNEL);
   657		if (!test)
   658			return -ENOMEM;
   659	
   660		test->test_reg_bar = 0;
   661		test->alignment = 0;
   662		test->pdev = pdev;
   663		test->irq_type = IRQ_TYPE_UNDEFINED;
   664	
   665		if (no_msi)
   666			irq_type = IRQ_TYPE_LEGACY;
   667	
   668		data = (struct pci_endpoint_test_data *)ent->driver_data;
   669		if (data) {
   670			test_reg_bar = data->test_reg_bar;
   671			test->test_reg_bar = test_reg_bar;
   672			test->alignment = data->alignment;
   673			irq_type = data->irq_type;
   674		}
   675	
   676		init_completion(&test->irq_raised);
   677		mutex_init(&test->mutex);
   678	
   679		err = pci_enable_device(pdev);
   680		if (err) {
   681			dev_err(dev, "Cannot enable PCI device\n");
   682			return err;
   683		}
   684	
   685		err = pci_request_regions(pdev, DRV_MODULE_NAME);
   686		if (err) {
   687			dev_err(dev, "Cannot obtain PCI resources\n");
   688			goto err_disable_pdev;
   689		}
   690	
   691		pci_set_master(pdev);
   692	
 > 693		if (!(is_am654_pci_dev(pdev) || is_j721e_pci_dev(pdev))) {

   694			if (!pci_endpoint_test_alloc_irq_vectors(test, irq_type))
   695				goto err_disable_irq;
   696	
   697			if (!pci_endpoint_test_request_irq(test))
   698				goto err_disable_irq;
   699		}
   700	
   701		for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
   702			if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) {
   703				base = pci_ioremap_bar(pdev, bar);
   704				if (!base) {
   705					dev_err(dev, "Failed to read BAR%d\n", bar);
   706					WARN_ON(bar == test_reg_bar);
   707				}
   708				test->bar[bar] = base;
   709			}
   710		}
   711	
   712		test->base = test->bar[test_reg_bar];
   713		if (!test->base) {
   714			err = -ENOMEM;
   715			dev_err(dev, "Cannot perform PCI test without BAR%d\n",
   716				test_reg_bar);
   717			goto err_iounmap;
   718		}
   719	
   720		pci_set_drvdata(pdev, test);
   721	
   722		id = ida_simple_get(&pci_endpoint_test_ida, 0, 0, GFP_KERNEL);
   723		if (id < 0) {
   724			err = id;
   725			dev_err(dev, "Unable to get id\n");
   726			goto err_iounmap;
   727		}
   728	
   729		snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
   730		misc_device = &test->miscdev;
   731		misc_device->minor = MISC_DYNAMIC_MINOR;
   732		misc_device->name = kstrdup(name, GFP_KERNEL);
   733		if (!misc_device->name) {
   734			err = -ENOMEM;
   735			goto err_ida_remove;
   736		}
   737		misc_device->fops = &pci_endpoint_test_fops,
   738	
   739		err = misc_register(misc_device);
   740		if (err) {
   741			dev_err(dev, "Failed to register device\n");
   742			goto err_kfree_name;
   743		}
   744	
   745		return 0;
   746	
   747	err_kfree_name:
   748		kfree(misc_device->name);
   749	
   750	err_ida_remove:
   751		ida_simple_remove(&pci_endpoint_test_ida, id);
   752	
   753	err_iounmap:
   754		for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
   755			if (test->bar[bar])
   756				pci_iounmap(pdev, test->bar[bar]);
   757		}
   758		pci_endpoint_test_release_irq(test);
   759	
   760	err_disable_irq:
   761		pci_endpoint_test_free_irq_vectors(test);
   762		pci_release_regions(pdev);
   763	
   764	err_disable_pdev:
   765		pci_disable_device(pdev);
   766	
   767		return err;
   768	}
   769	

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
Kishon Vijay Abraham I Dec. 31, 2019, 8:35 a.m. | #3
Hi,

On 30/12/19 10:40 PM, kbuild test robot wrote:
> Hi Kishon,

> 

> I love your patch! Perhaps something to improve:

> 

> [auto build test WARNING on char-misc/char-misc-testing]

> [also build test WARNING on pci/next arm-soc/for-next linus/master v5.5-rc4 next-20191220]

> [if your patch is applied to the wrong git tree, please drop us a note to help

> improve the system. BTW, we also suggest to use '--base' option to specify the

> base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

> 

> url:    https://github.com/0day-ci/linux/commits/Kishon-Vijay-Abraham-I/Improvements-to-pci_endpoint_test-driver/20191230-203402

> base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git d1eef1c619749b2a57e514a3fa67d9a516ffa919

> config: arm-randconfig-a001-20191229 (attached as .config)

> compiler: arm-linux-gnueabi-gcc (GCC) 7.5.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.5.0 make.cross ARCH=arm 

> 

> If you fix the issue, kindly add following tag

> Reported-by: kbuild test robot <lkp@intel.com>

> 

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

> 

>    In file included from include/linux/kernel.h:11:0,

>                     from include/linux/delay.h:22,

>                     from drivers/[1] -> http://lore.kernel.org/r/20191209092147.22901-1-kishon@ti.commisc/pci_endpoint_test.c:10:

>    drivers/misc/pci_endpoint_test.c: In function 'pci_endpoint_test_probe':

>    drivers/misc/pci_endpoint_test.c:73:22: error: 'PCI_DEVICE_ID_TI_J721E' undeclared (first use in this function); did you mean 'PCI_DEVICE_ID_TI_7510'?

>       ((pdev)->device == PCI_DEVICE_ID_TI_J721E)


The patches in this series should be merged only after [1]. With that
this error wouldn't be seen.

[1] -> http://lore.kernel.org/r/20191209092147.22901-1-kishon@ti.com

Thanks
Kishon
Philip Li Dec. 31, 2019, 10:40 a.m. | #4
On Tue, Dec 31, 2019 at 02:05:15PM +0530, Kishon Vijay Abraham I wrote:
> Hi,

> 

> On 30/12/19 10:40 PM, kbuild test robot wrote:

> > Hi Kishon,

> > 

> > I love your patch! Perhaps something to improve:

> > 

> > [auto build test WARNING on char-misc/char-misc-testing]

> > [also build test WARNING on pci/next arm-soc/for-next linus/master v5.5-rc4 next-20191220]

> > [if your patch is applied to the wrong git tree, please drop us a note to help

> > improve the system. BTW, we also suggest to use '--base' option to specify the

> > base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

> > 

> > url:    https://github.com/0day-ci/linux/commits/Kishon-Vijay-Abraham-I/Improvements-to-pci_endpoint_test-driver/20191230-203402

> > base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git d1eef1c619749b2a57e514a3fa67d9a516ffa919

> > config: arm-randconfig-a001-20191229 (attached as .config)

> > compiler: arm-linux-gnueabi-gcc (GCC) 7.5.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.5.0 make.cross ARCH=arm 

> > 

> > If you fix the issue, kindly add following tag

> > Reported-by: kbuild test robot <lkp@intel.com>

> > 

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

> > 

> >    In file included from include/linux/kernel.h:11:0,

> >                     from include/linux/delay.h:22,

> >                     from drivers/[1] -> http://lore.kernel.org/r/20191209092147.22901-1-kishon@ti.commisc/pci_endpoint_test.c:10:

> >    drivers/misc/pci_endpoint_test.c: In function 'pci_endpoint_test_probe':

> >    drivers/misc/pci_endpoint_test.c:73:22: error: 'PCI_DEVICE_ID_TI_J721E' undeclared (first use in this function); did you mean 'PCI_DEVICE_ID_TI_7510'?

> >       ((pdev)->device == PCI_DEVICE_ID_TI_J721E)

> 

> The patches in this series should be merged only after [1]. With that

> this error wouldn't be seen.

thanks Kishon for the info, sorry for the false positive.

> 

> [1] -> http://lore.kernel.org/r/20191209092147.22901-1-kishon@ti.com

> 

> Thanks

> Kishon

> _______________________________________________

> kbuild-all mailing list -- kbuild-all@lists.01.org

> To unsubscribe send an email to kbuild-all-leave@lists.01.org

Patch

diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index 743ff4dcb3f0..04505890eae9 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -70,6 +70,9 @@ 
 #define is_am654_pci_dev(pdev)		\
 		((pdev)->device == PCI_DEVICE_ID_TI_AM654)
 
+#define is_j721e_pci_dev(pdev)         \
+		((pdev)->device == PCI_DEVICE_ID_TI_J721E)
+
 static DEFINE_IDA(pci_endpoint_test_ida);
 
 #define to_endpoint_test(priv) container_of((priv), struct pci_endpoint_test, \
@@ -688,11 +691,13 @@  static int pci_endpoint_test_probe(struct pci_dev *pdev,
 
 	pci_set_master(pdev);
 
-	if (!pci_endpoint_test_alloc_irq_vectors(test, irq_type))
-		goto err_disable_irq;
+	if (!(is_am654_pci_dev(pdev) || is_j721e_pci_dev(pdev))) {
+		if (!pci_endpoint_test_alloc_irq_vectors(test, irq_type))
+			goto err_disable_irq;
 
-	if (!pci_endpoint_test_request_irq(test))
-		goto err_disable_irq;
+		if (!pci_endpoint_test_request_irq(test))
+			goto err_disable_irq;
+	}
 
 	for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
 		if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) {