[dpdk-dev] igb_uio: only check for pci bridge in supported by linux kernel

Message ID 20180416205110.1354-1-ajit.khaparde@broadcom.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK

Commit Message

Ajit Khaparde April 16, 2018, 8:51 p.m. UTC
  From: Scott Branden <scott.branden@broadcom.com>

Starting from Linux v3.16 pci_is_bridge() is in linux/pci.h,
 in previous versions it is in drivers/pci/pci.h which is private header.

Fix build error when calling pci_is_bridge by not calling/supporting
pci_is_bridge with kernel versions before 3.16.

Signed-off-by: Scott Branden <scott.branden@broadcom.com>
Reported-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 kernel/linux/igb_uio/compat.h  | 4 ++++
 kernel/linux/igb_uio/igb_uio.c | 2 ++
 2 files changed, 6 insertions(+)
  

Comments

Ferruh Yigit April 17, 2018, 9:35 a.m. UTC | #1
On 4/16/2018 9:51 PM, Ajit Khaparde wrote:
> From: Scott Branden <scott.branden@broadcom.com>
> 
> Starting from Linux v3.16 pci_is_bridge() is in linux/pci.h,
>  in previous versions it is in drivers/pci/pci.h which is private header.
> 
> Fix build error when calling pci_is_bridge by not calling/supporting
> pci_is_bridge with kernel versions before 3.16.

Thanks for the patch, this is mainly solves the issue, only a few nit-picking:
can you covert title to a fix patch and add a fixes line please? This is to fix
the build error with some kernels.

> 
> Signed-off-by: Scott Branden <scott.branden@broadcom.com>
> Reported-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
>  kernel/linux/igb_uio/compat.h  | 4 ++++
>  kernel/linux/igb_uio/igb_uio.c | 2 ++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/kernel/linux/igb_uio/compat.h b/kernel/linux/igb_uio/compat.h
> index ce456d4bb..b48c4cc91 100644
> --- a/kernel/linux/igb_uio/compat.h
> +++ b/kernel/linux/igb_uio/compat.h
> @@ -132,3 +132,7 @@ static bool pci_check_and_mask_intx(struct pci_dev *pdev)
>  #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
>  #define HAVE_PCI_MSI_MASK_IRQ 1
>  #endif
> +
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
> +#define HAVE_PCI_IS_BRIDGE_API 1
> +#endif

Can you keep check with version order, add this part after "3.3.0" one, I am
aware "4, 8, 0" one breaks the order it seems that has slipped...

> diff --git a/kernel/linux/igb_uio/igb_uio.c b/kernel/linux/igb_uio/igb_uio.c
> index cbc5ab63a..cd9b7e721 100644
> --- a/kernel/linux/igb_uio/igb_uio.c
> +++ b/kernel/linux/igb_uio/igb_uio.c
> @@ -473,10 +473,12 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  	void *map_addr;
>  	int err;
>  
> +#ifdef HAVE_PCI_IS_BRIDGE_API
>  	if (pci_is_bridge(dev)) {
>  		dev_warn(&dev->dev, "Ignoring PCI bridge device\n");
>  		return -ENODEV;
>  	}
> +#endif
>  
>  	udev = kzalloc(sizeof(struct rte_uio_pci_dev), GFP_KERNEL);
>  	if (!udev)
>
  
Iremonger, Bernard April 17, 2018, 12:58 p.m. UTC | #2
Hi Scott, Ajit,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ajit Khaparde
> Sent: Monday, April 16, 2018 9:51 PM
> To: dev@dpdk.org
> Cc: Scott Branden <scott.branden@broadcom.com>
> Subject: [dpdk-dev] [PATCH] igb_uio: only check for pci bridge in supported by
> linux kernel
> 
> From: Scott Branden <scott.branden@broadcom.com>
> 
> Starting from Linux v3.16 pci_is_bridge() is in linux/pci.h,  in previous versions it
> is in drivers/pci/pci.h which is private header.
> 
> Fix build error when calling pci_is_bridge by not calling/supporting pci_is_bridge
> with kernel versions before 3.16.
> 
> Signed-off-by: Scott Branden <scott.branden@broadcom.com>
> Reported-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
>  kernel/linux/igb_uio/compat.h  | 4 ++++  kernel/linux/igb_uio/igb_uio.c | 2 ++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/kernel/linux/igb_uio/compat.h b/kernel/linux/igb_uio/compat.h
> index ce456d4bb..b48c4cc91 100644
> --- a/kernel/linux/igb_uio/compat.h
> +++ b/kernel/linux/igb_uio/compat.h
> @@ -132,3 +132,7 @@ static bool pci_check_and_mask_intx(struct pci_dev
> *pdev)  #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)  #define
> HAVE_PCI_MSI_MASK_IRQ 1  #endif
> +
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0) #define
> +HAVE_PCI_IS_BRIDGE_API 1 #endif
> diff --git a/kernel/linux/igb_uio/igb_uio.c b/kernel/linux/igb_uio/igb_uio.c index
> cbc5ab63a..cd9b7e721 100644
> --- a/kernel/linux/igb_uio/igb_uio.c
> +++ b/kernel/linux/igb_uio/igb_uio.c
> @@ -473,10 +473,12 @@ igbuio_pci_probe(struct pci_dev *dev, const struct
> pci_device_id *id)
>  	void *map_addr;
>  	int err;
> 
> +#ifdef HAVE_PCI_IS_BRIDGE_API
>  	if (pci_is_bridge(dev)) {
>  		dev_warn(&dev->dev, "Ignoring PCI bridge device\n");
>  		return -ENODEV;
>  	}
> +#endif
> 
>  	udev = kzalloc(sizeof(struct rte_uio_pci_dev), GFP_KERNEL);
>  	if (!udev)
> --
> 2.15.1 (Apple Git-101)

This patch fixes the compile error seen on the master branch.
However there are the following checkpatch.pl  warnings:

WARNING: LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged
#40: FILE: kernel/linux/igb_uio/compat.h:136:
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)

WARNING: Comparisons should place the constant on the right side of the test
#40: FILE: kernel/linux/igb_uio/compat.h:136:
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)

total: 0 errors, 2 warnings, 19 lines checked

Regards,

Bernard.
  
Ferruh Yigit April 17, 2018, 1:33 p.m. UTC | #3
On 4/17/2018 1:58 PM, Iremonger, Bernard wrote:
> Hi Scott, Ajit,
> 
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ajit Khaparde
>> Sent: Monday, April 16, 2018 9:51 PM
>> To: dev@dpdk.org
>> Cc: Scott Branden <scott.branden@broadcom.com>
>> Subject: [dpdk-dev] [PATCH] igb_uio: only check for pci bridge in supported by
>> linux kernel
>>
>> From: Scott Branden <scott.branden@broadcom.com>
>>
>> Starting from Linux v3.16 pci_is_bridge() is in linux/pci.h,  in previous versions it
>> is in drivers/pci/pci.h which is private header.
>>
>> Fix build error when calling pci_is_bridge by not calling/supporting pci_is_bridge
>> with kernel versions before 3.16.
>>
>> Signed-off-by: Scott Branden <scott.branden@broadcom.com>
>> Reported-by: Ferruh Yigit <ferruh.yigit@intel.com>

<...>

> This patch fixes the compile error seen on the master branch.
> However there are the following checkpatch.pl  warnings:
> 
> WARNING: LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged
> #40: FILE: kernel/linux/igb_uio/compat.h:136:
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)

We need version check, so we can ignore this warning

> WARNING: Comparisons should place the constant on the right side of the test
> #40: FILE: kernel/linux/igb_uio/compat.h:136:
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)

Other checks are also like this, I believe better to be compatible.

I think we can ignore both warnings for this case.

> 
> total: 0 errors, 2 warnings, 19 lines checked
> 
> Regards,
> 
> Bernard.
>  
>
  
Iremonger, Bernard April 17, 2018, 1:49 p.m. UTC | #4
> -----Original Message-----

> From: Yigit, Ferruh

> Sent: Tuesday, April 17, 2018 2:34 PM

> To: Iremonger, Bernard <bernard.iremonger@intel.com>; Ajit Khaparde

> <ajit.khaparde@broadcom.com>; dev@dpdk.org

> Cc: Scott Branden <scott.branden@broadcom.com>

> Subject: Re: [dpdk-dev] [PATCH] igb_uio: only check for pci bridge in supported

> by linux kernel

> 

> On 4/17/2018 1:58 PM, Iremonger, Bernard wrote:

> > Hi Scott, Ajit,

> >

> >> -----Original Message-----

> >> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ajit Khaparde

> >> Sent: Monday, April 16, 2018 9:51 PM

> >> To: dev@dpdk.org

> >> Cc: Scott Branden <scott.branden@broadcom.com>

> >> Subject: [dpdk-dev] [PATCH] igb_uio: only check for pci bridge in

> >> supported by linux kernel

> >>

> >> From: Scott Branden <scott.branden@broadcom.com>

> >>

> >> Starting from Linux v3.16 pci_is_bridge() is in linux/pci.h,  in

> >> previous versions it is in drivers/pci/pci.h which is private header.

> >>

> >> Fix build error when calling pci_is_bridge by not calling/supporting

> >> pci_is_bridge with kernel versions before 3.16.

> >>

> >> Signed-off-by: Scott Branden <scott.branden@broadcom.com>

> >> Reported-by: Ferruh Yigit <ferruh.yigit@intel.com>

> 


Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
  

Patch

diff --git a/kernel/linux/igb_uio/compat.h b/kernel/linux/igb_uio/compat.h
index ce456d4bb..b48c4cc91 100644
--- a/kernel/linux/igb_uio/compat.h
+++ b/kernel/linux/igb_uio/compat.h
@@ -132,3 +132,7 @@  static bool pci_check_and_mask_intx(struct pci_dev *pdev)
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
 #define HAVE_PCI_MSI_MASK_IRQ 1
 #endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
+#define HAVE_PCI_IS_BRIDGE_API 1
+#endif
diff --git a/kernel/linux/igb_uio/igb_uio.c b/kernel/linux/igb_uio/igb_uio.c
index cbc5ab63a..cd9b7e721 100644
--- a/kernel/linux/igb_uio/igb_uio.c
+++ b/kernel/linux/igb_uio/igb_uio.c
@@ -473,10 +473,12 @@  igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	void *map_addr;
 	int err;
 
+#ifdef HAVE_PCI_IS_BRIDGE_API
 	if (pci_is_bridge(dev)) {
 		dev_warn(&dev->dev, "Ignoring PCI bridge device\n");
 		return -ENODEV;
 	}
+#endif
 
 	udev = kzalloc(sizeof(struct rte_uio_pci_dev), GFP_KERNEL);
 	if (!udev)