Skip to contentSkip to conversation

pci:don't insert an unbound device to pci_device_list in pci_scan_one

PATCH New Rugang Chen 1 participant 2 messages Jun 25, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci:don't insert an unbound device to pci_device_list in pci_scan_one

If a device isn't bound by any uio driver (vfio-pci, igb_uio, uio_pci_generic) and is expected to owned by a kernel space driver, here it's still inserted to pci_device_list.

This may cause application based on dpdk fetch the device by accident and then the device is hanlded by dpdk.

For safe, skip it from pci_device_list as if it's unbound, dpdk won't want to use it.

---
 lib/librte_eal/linuxapp/eal/eal_pci.c | 6 ++++++
 1 file changed, 6 insertions(+)
lib/librte_eal/linuxapp/eal/eal_pci.c +6 -0
index f9c3efd..f63febc 100644
@@ -388,6 +388,12 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 	} else
 		dev->kdrv = RTE_KDRV_NONE;
 
+	/* Ignore device that isn't bound with any uio driver, then application won't
+	 * fetch it from pci_device_list by accident and then dpdk handles it. Kernel
+	 * space driver maybe wants to own it.
+	 */
+	if (dev->kdrv == RTE_KDRV_NONE)
+		return 0;
 	/* device is valid, add in list (sorted) */
 	if (TAILQ_EMPTY(&pci_device_list)) {
 		TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 pci: don't insert an unbound device to pci_device_list in pci_scan_one

If a device isn't bound by any uio driver (vfio-pci, igb_uio, uio_pci_generic) and is expected to owned by a kernel space driver, here it's still inserted to pci_device_list.

This may cause application based on dpdk fetch the device by accident and then the device is hanlded by dpdk.

For safe, skip it from pci_device_list as if it's unbound, dpdk won't want to use it.

---
 lib/librte_eal/linuxapp/eal/eal_pci.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
lib/librte_eal/linuxapp/eal/eal_pci.c +5 -1
index f63febc..432d2e8 100644
@@ -392,8 +392,12 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 	 * fetch it from pci_device_list by accident and then dpdk handles it. Kernel
 	 * space driver maybe wants to own it.
 	 */
-	if (dev->kdrv == RTE_KDRV_NONE)
+	if (dev->kdrv == RTE_KDRV_NONE) {
+		RTE_LOG(WARNING, EAL, "Skip ubound device\n");
+		free(dev);
 		return 0;
+	}
+
 	/* device is valid, add in list (sorted) */
 	if (TAILQ_EMPTY(&pci_device_list)) {
 		TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
Signature · 1 line
2.1.4