Skip to contentSkip to conversation

igb_uio: bind error if pcie bridge

PATCH Applied Ajit Khaparde 4 participants 12 messages Mar 29, 2018 – Apr 20, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 igb_uio: bind error if pcie bridge

From: Darren Edamura <[email protected]>

Probe function should exit immediately if pcie bridge detected

----
v1->v2: add a log message if the condition is true. v2->v3: rebase against latest dpdk-next-net tree.

---
 kernel/linux/igb_uio/igb_uio.c | 5 +++++
 1 file changed, 5 insertions(+)
kernel/linux/igb_uio/igb_uio.c +5 -0
index 4cae4dd27..cbc5ab63a 100644
@@ -473,6 +473,11 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	void *map_addr;
 	int err;
 
+	if (pci_is_bridge(dev)) {
+		dev_warn(&dev->dev, "Ignoring PCI bridge device\n");
+		return -ENODEV;
+	}
+
 	udev = kzalloc(sizeof(struct rte_uio_pci_dev), GFP_KERNEL);
 	if (!udev)
 		return -ENOMEM;
Signature · 1 line
2.14.3 (Apple Git-98)
#3 lore raw
In reply to Ajit Khaparde
Quoted 20 lines · Ajit Khaparde

From: Darren Edamura <[email protected]>

Probe function should exit immediately if pcie bridge detected

----
v1->v2: add a log message if the condition is true. v2->v3: rebase against latest dpdk-next-net tree.

---
 kernel/linux/igb_uio/igb_uio.c | 5 +++++
 1 file changed, 5 insertions(+)
kernel/linux/igb_uio/igb_uio.c +0 -0
index 4cae4dd27..cbc5ab63a 100644

kernel/linux/igb_uio/igb_uio.c igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) · line 476

Quoted 4 lines
kernel/linux/igb_uio/igb_uio.c +1 -0
@@ -473,6 +473,11 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	void *map_addr;
 	int err;
 
+	if (pci_is_bridge(dev)) {

Hi Ajit,

I acked this patch and it is already applied but there is a build issue for this one.

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 and using this API causing a build error.

Can you please send a fix for this?

It is possible to define a macro in igb_uio/compat.h based on kernel version check. And in igb_uio.c use that macro to enable/disable pci_is_bridge() check. Please don't use version check directly in igb_uio.c

Thanks,
ferruh

Quoted 8 lines
kernel/linux/igb_uio/igb_uio.c +4 -0
+		dev_warn(&dev->dev, "Ignoring PCI bridge device\n");
+		return -ENODEV;
+	}
+
 	udev = kzalloc(sizeof(struct rte_uio_pci_dev), GFP_KERNEL);
 	if (!udev)
 		return -ENOMEM;
#4 lore raw

PATCH 1/1 igb_uio: only check for pci bridge in supported by linux kernel

From: Scott Branden <[email protected]>

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.

---
 kernel/linux/igb_uio/compat.h  | 4 ++++
 kernel/linux/igb_uio/igb_uio.c | 2 ++
 2 files changed, 6 insertions(+)
kernel/linux/igb_uio/compat.h +4 -0
index ce456d4bb..b48c4cc91 100644
@@ -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
kernel/linux/igb_uio/igb_uio.c +2 -0
index cbc5ab63a..cd9b7e721 100644
@@ -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)
Signature · 1 line
2.15.1 (Apple Git-101)
#5 lore raw

Re: [PATCH] igb_uio: only check for pci bridge in supported by linux kernel

Quoted 7 lines · Ajit Khaparde

From: Scott Branden <[email protected]>

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.

Quoted 13 lines
---
 kernel/linux/igb_uio/compat.h  | 4 ++++
 kernel/linux/igb_uio/igb_uio.c | 2 ++
 2 files changed, 6 insertions(+)
kernel/linux/igb_uio/compat.h +0 -0
index ce456d4bb..b48c4cc91 100644

kernel/linux/igb_uio/compat.h static bool pci_check_and_mask_intx(struct pci_dev *pdev) · line 138

Quoted 7 lines
kernel/linux/igb_uio/compat.h +4 -0
@@ -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...

Quoted 18 lines
kernel/linux/igb_uio/igb_uio.c +2 -0
index cbc5ab63a..cd9b7e721 100644
@@ -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)
#6 lore raw

Re: [PATCH] igb_uio: only check for pci bridge in supported by linux kernel

In reply to Ajit Khaparde

Hi Scott, Ajit,

Quoted 49 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ajit Khaparde
Sent: Monday, April 16, 2018 9:51 PM
To: [email protected]
Cc: Scott Branden <[email protected]>
Subject: [dpdk-dev] [PATCH] igb_uio: only check for pci bridge in supported by linux kernel

From: Scott Branden <[email protected]>

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.

---
 kernel/linux/igb_uio/compat.h  | 4 ++++  kernel/linux/igb_uio/igb_uio.c | 2 ++
 2 files changed, 6 insertions(+)
kernel/linux/igb_uio/compat.h +0 -0
index ce456d4bb..b48c4cc91 100644
@@ -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

kernel/linux/igb_uio/compat.h +3 -0
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0) #define
+HAVE_PCI_IS_BRIDGE_API 1 #endif
kernel/linux/igb_uio/igb_uio.c index renamed from kernel/linux/igb_uio/igb_uio.c +0 -0

cbc5ab63a..cd9b7e721 100644

kernel/linux/igb_uio/igb_uio.c +2 -0
@@ -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);
Quoted 3 lines

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.

#7 lore raw

Re: [PATCH] igb_uio: only check for pci bridge in supported by linux kernel

Quoted 20 lines · Bernard

Hi Scott, Ajit,

Quoted 18 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ajit Khaparde
Sent: Monday, April 16, 2018 9:51 PM
To: [email protected]
Cc: Scott Branden <[email protected]>
Subject: [dpdk-dev] [PATCH] igb_uio: only check for pci bridge in supported by linux kernel

From: Scott Branden <[email protected]>

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.

<...>

Quoted 6 lines

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

Quoted 3 lines

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.

Quoted 8 lines

total: 0 errors, 2 warnings, 19 lines checked

Regards,

Bernard.

#8 lore raw

Re: [PATCH] igb_uio: only check for pci bridge in supported by linux kernel

Quoted 10 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Tuesday, April 17, 2018 2:34 PM
To: Iremonger, Bernard <[email protected]>; Ajit Khaparde <[email protected]>; [email protected]
Cc: Scott Branden <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] igb_uio: only check for pci bridge in supported by linux kernel

Quoted 22 lines
Quoted 20 lines · Bernard

Hi Scott, Ajit,

Quoted 18 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ajit Khaparde
Sent: Monday, April 16, 2018 9:51 PM
To: [email protected]
Cc: Scott Branden <[email protected]>
Subject: [dpdk-dev] [PATCH] igb_uio: only check for pci bridge in supported by linux kernel

From: Scott Branden <[email protected]>

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.

#9 lore raw

PATCH v2 1/1 igb_uio: only check for pci bridge if supported by linux kernel

From: Scott Branden <[email protected]>

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.

Fixes 6f0841b7701b ("igb_uio: bind error if PCIe bridge")

--
v1->v2: add fixes line in commit message.

---
 kernel/linux/igb_uio/compat.h  | 4 ++++
 kernel/linux/igb_uio/igb_uio.c | 2 ++
 2 files changed, 6 insertions(+)
kernel/linux/igb_uio/compat.h +4 -0
index ce456d4bb..d9f4d29fc 100644
@@ -121,6 +121,10 @@ static bool pci_check_and_mask_intx(struct pci_dev *pdev)
 
 #endif /* < 3.3.0 */
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
+#define HAVE_PCI_IS_BRIDGE_API 1
+#endif
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
 #define HAVE_ALLOC_IRQ_VECTORS 1
 #endif
kernel/linux/igb_uio/igb_uio.c +2 -0
index cbc5ab63a..cd9b7e721 100644
@@ -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)
Signature · 1 line
2.15.1 (Apple Git-101)
Acked-by on v2 1/1
#10 lore raw

Re: [PATCH v2] igb_uio: only check for pci bridge if supported by linux kernel

Quoted 8 lines · Ajit Khaparde

From: Scott Branden <[email protected]>

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.

Quoted 6 lines
Fixes 6f0841b7701b ("igb_uio: bind error if PCIe bridge")
#11 lore raw

Re: [PATCH v2] igb_uio: only check for pci bridge if supported by linux kernel

17/04/2018 20:07, Ferruh Yigit:

Quoted 9 lines · Ajit Khaparde
Quoted 8 lines

From: Scott Branden <[email protected]>

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.

Quoted 8 lines
Quoted 6 lines
Fixes 6f0841b7701b ("igb_uio: bind error if PCIe bridge")

Applied, thanks