[PATCH v5 15/25] bus: support multiple probe

David Marchand david.marchand at redhat.com
Sat May 30 09:51:45 CEST 2026


Add infrastructure to declare support for multiple probe attempts
on the same device. This prepares for the introduction of
generic probe_device operation.

The PCI bus enables this feature to support drivers with
RTE_PCI_DRV_PROBE_AGAIN flag.

Signed-off-by: David Marchand <david.marchand at redhat.com>
Acked-by: Bruce Richardson <bruce.richardson at intel.com>
---
Changes since v4:
- fixed (transient, fixed in a later patch) regression on multiple scan,

---
 drivers/bus/auxiliary/auxiliary_common.c | 12 ++++++------
 drivers/bus/cdx/cdx.c                    | 10 +++++-----
 drivers/bus/dpaa/dpaa_bus.c              |  6 +++---
 drivers/bus/fslmc/fslmc_bus.c            |  6 +++---
 drivers/bus/ifpga/ifpga_bus.c            | 13 ++++++-------
 drivers/bus/pci/pci_common.c             |  1 +
 drivers/bus/platform/platform.c          |  8 +++++---
 drivers/bus/uacce/uacce.c                | 10 +++++-----
 drivers/bus/vdev/vdev.c                  |  5 ++---
 drivers/bus/vmbus/vmbus_common.c         | 11 +++++------
 lib/eal/common/eal_common_dev.c          |  3 +++
 lib/eal/include/bus_driver.h             |  1 +
 12 files changed, 45 insertions(+), 41 deletions(-)

diff --git a/drivers/bus/auxiliary/auxiliary_common.c b/drivers/bus/auxiliary/auxiliary_common.c
index 7824c26f92..1ca38e95a2 100644
--- a/drivers/bus/auxiliary/auxiliary_common.c
+++ b/drivers/bus/auxiliary/auxiliary_common.c
@@ -94,12 +94,6 @@ auxiliary_probe_device(struct rte_driver *drv, struct rte_device *dev)
 	if (aux_dev->device.numa_node < 0 && rte_socket_count() > 1)
 		AUXILIARY_LOG(INFO, "Device %s is not NUMA-aware", aux_dev->name);
 
-	if (rte_dev_is_probed(&aux_dev->device)) {
-		AUXILIARY_LOG(DEBUG, "Device %s is already probed on auxiliary bus",
-			aux_dev->device.name);
-		return -EEXIST;
-	}
-
 	iova_mode = rte_eal_iova_mode();
 	if ((aux_drv->drv_flags & RTE_AUXILIARY_DRV_NEED_IOVA_AS_VA) > 0 &&
 	    iova_mode != RTE_IOVA_VA) {
@@ -179,6 +173,12 @@ auxiliary_probe(void)
 		if (drv == NULL)
 			continue;
 
+		if (rte_dev_is_probed(&dev->device)) {
+			AUXILIARY_LOG(DEBUG, "Device %s is already probed on auxiliary bus",
+				dev->device.name);
+			continue;
+		}
+
 		ret = auxiliary_bus.bus.probe_device(drv, &dev->device);
 		if (ret < 0) {
 			if (ret != -EEXIST) {
diff --git a/drivers/bus/cdx/cdx.c b/drivers/bus/cdx/cdx.c
index c38eae325b..92557de8cb 100644
--- a/drivers/bus/cdx/cdx.c
+++ b/drivers/bus/cdx/cdx.c
@@ -315,11 +315,6 @@ cdx_probe_device(struct rte_driver *drv, struct rte_device *dev)
 	const char *dev_name = cdx_dev->name;
 	int ret;
 
-	if (rte_dev_is_probed(&cdx_dev->device)) {
-		CDX_BUS_INFO("Device %s is already probed", dev_name);
-		return -EEXIST;
-	}
-
 	CDX_BUS_DEBUG("  probe device %s using driver: %s", dev_name,
 		cdx_drv->driver.name);
 
@@ -374,6 +369,11 @@ cdx_probe(void)
 		if (drv == NULL)
 			continue;
 
+		if (rte_dev_is_probed(&dev->device)) {
+			CDX_BUS_INFO("Device %s is already probed", dev->name);
+			continue;
+		}
+
 		ret = rte_cdx_bus.bus.probe_device(drv, &dev->device);
 		if (ret < 0) {
 			CDX_BUS_ERR("Requested device %s cannot be used",
diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index 14cd64cc32..fbdd932e79 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -795,6 +795,9 @@ rte_dpaa_bus_probe(void)
 		if (driver == NULL)
 			continue;
 
+		if (rte_dev_is_probed(&dev->device))
+			continue;
+
 		ret = rte_dpaa_bus.bus.probe_device(driver, &dev->device);
 		if (ret < 0)
 			DPAA_BUS_ERR("Failed to probe device %s", dev->name);
@@ -826,9 +829,6 @@ dpaa_bus_probe_device(struct rte_driver *drv, struct rte_device *dev)
 	struct rte_dpaa_driver *dpaa_drv = RTE_BUS_DRIVER(drv, *dpaa_drv);
 	int ret;
 
-	if (rte_dev_is_probed(&dpaa_dev->device))
-		return 0;
-
 	if (rte_bus_device_is_ignored(&rte_dpaa_bus.bus, dpaa_dev->name))
 		return 0;
 
diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index a975e464c1..10de9e9ffe 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -465,6 +465,9 @@ rte_fslmc_probe(void)
 		if (driver == NULL)
 			continue;
 
+		if (rte_dev_is_probed(&dev->device))
+			continue;
+
 		ret = rte_fslmc_bus.bus.probe_device(driver, &dev->device);
 		if (ret < 0)
 			DPAA2_BUS_ERR("Failed to probe device %s", dev->device.name);
@@ -541,9 +544,6 @@ fslmc_bus_probe_device(struct rte_driver *driver, struct rte_device *rte_dev)
 	struct rte_dpaa2_driver *drv = RTE_BUS_DRIVER(driver, *drv);
 	int ret = 0;
 
-	if (rte_dev_is_probed(&dev->device))
-		return 0;
-
 	if (dev->device.devargs &&
 	    dev->device.devargs->policy == RTE_DEV_BLOCKED) {
 		DPAA2_BUS_DEBUG("%s Blocked, skipping",
diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index 92ad3513e0..293a56cb10 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -274,13 +274,6 @@ ifpga_probe_device(struct rte_driver *drv, struct rte_device *dev)
 	struct rte_afu_driver *afu_drv = RTE_BUS_DRIVER(drv, *afu_drv);
 	int ret;
 
-	/* Check if a driver is already loaded */
-	if (rte_dev_is_probed(&afu_dev->device)) {
-		IFPGA_BUS_DEBUG("Device %s is already probed",
-				rte_ifpga_device_name(afu_dev));
-		return -EEXIST;
-	}
-
 	/* reference driver structure */
 	afu_dev->driver = afu_drv;
 
@@ -313,6 +306,12 @@ ifpga_probe(void)
 		if (drv == NULL)
 			continue;
 
+		if (rte_dev_is_probed(&afu_dev->device)) {
+			IFPGA_BUS_DEBUG("Device %s is already probed",
+				rte_ifpga_device_name(afu_dev));
+			continue;
+		}
+
 		ret = rte_ifpga_bus.probe_device(drv, &afu_dev->device);
 		if (ret == -EEXIST)
 			continue;
diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index b57320064e..02542a903a 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -823,6 +823,7 @@ rte_pci_pasid_set_state(const struct rte_pci_device *dev,
 
 struct rte_pci_bus rte_pci_bus = {
 	.bus = {
+		.allow_multi_probe = true,
 		.scan = rte_pci_scan,
 		.probe = pci_probe,
 		.cleanup = pci_cleanup,
diff --git a/drivers/bus/platform/platform.c b/drivers/bus/platform/platform.c
index 22979f31b3..dfdd372327 100644
--- a/drivers/bus/platform/platform.c
+++ b/drivers/bus/platform/platform.c
@@ -331,9 +331,6 @@ driver_call_probe(struct rte_platform_driver *pdrv, struct rte_platform_device *
 {
 	int ret;
 
-	if (rte_dev_is_probed(&pdev->device))
-		return -EBUSY;
-
 	if (pdrv->probe != NULL) {
 		pdev->driver = pdrv;
 		ret = pdrv->probe(pdev);
@@ -418,6 +415,11 @@ platform_bus_probe(void)
 		if (drv == NULL)
 			continue;
 
+		if (rte_dev_is_probed(&pdev->device)) {
+			PLATFORM_LOG_LINE(DEBUG, "device %s already probed", pdev->name);
+			continue;
+		}
+
 		ret = platform_bus.bus.probe_device(drv, &pdev->device);
 		if (ret == -EBUSY) {
 			PLATFORM_LOG_LINE(DEBUG, "device %s already probed", pdev->name);
diff --git a/drivers/bus/uacce/uacce.c b/drivers/bus/uacce/uacce.c
index 2ef1a27635..2bf6355f10 100644
--- a/drivers/bus/uacce/uacce.c
+++ b/drivers/bus/uacce/uacce.c
@@ -359,11 +359,6 @@ uacce_probe_device(struct rte_driver *drv, struct rte_device *dev)
 	const char *dev_name = uacce_dev->name;
 	int ret;
 
-	if (rte_dev_is_probed(&uacce_dev->device)) {
-		UACCE_BUS_INFO("device %s is already probed", dev_name);
-		return -EEXIST;
-	}
-
 	UACCE_BUS_DEBUG("probe device %s using driver %s", dev_name, uacce_drv->driver.name);
 
 	ret = uacce_drv->probe(uacce_drv, uacce_dev);
@@ -397,6 +392,11 @@ uacce_probe(void)
 		if (drv == NULL)
 			continue;
 
+		if (rte_dev_is_probed(&dev->device)) {
+			UACCE_BUS_INFO("device %s is already probed", dev->name);
+			continue;
+		}
+
 		ret = uacce_bus.bus.probe_device(drv, &dev->device);
 		if (ret < 0) {
 			UACCE_BUS_LOG(ERR, "Requested device %s cannot be used",
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index e55be7fb2c..5b4ebc497a 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -190,9 +190,6 @@ vdev_probe_device(struct rte_driver *drv, struct rte_device *dev)
 	enum rte_iova_mode iova_mode;
 	int ret;
 
-	if (rte_dev_is_probed(&vdev_dev->device))
-		return -EEXIST;
-
 	name = rte_vdev_device_name(vdev_dev);
 	VDEV_LOG(DEBUG, "Search driver to probe device %s", name);
 
@@ -328,6 +325,8 @@ rte_vdev_init(const char *name, const char *args)
 		if (drv == NULL) {
 			VDEV_LOG(ERR, "no driver found for %s", name);
 			ret = -1;
+		} else if (rte_dev_is_probed(&dev->device)) {
+			ret = -EEXIST;
 		} else {
 			ret = rte_vdev_bus.probe_device(drv, &dev->device);
 		}
diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c
index ba923a2669..de23bbde02 100644
--- a/drivers/bus/vmbus/vmbus_common.c
+++ b/drivers/bus/vmbus/vmbus_common.c
@@ -91,12 +91,6 @@ vmbus_probe_device(struct rte_driver *drv, struct rte_device *dev)
 	char guid[RTE_UUID_STRLEN];
 	int ret;
 
-	/* Check if a driver is already loaded */
-	if (rte_dev_is_probed(&vmbus_dev->device)) {
-		VMBUS_LOG(DEBUG, "VMBUS driver already loaded");
-		return 0;
-	}
-
 	rte_uuid_unparse(vmbus_dev->device_id, guid, sizeof(guid));
 	VMBUS_LOG(INFO, "VMBUS device %s on NUMA socket %i",
 		  guid, vmbus_dev->device.numa_node);
@@ -161,6 +155,11 @@ rte_vmbus_probe(void)
 		if (drv == NULL)
 			continue;
 
+		if (rte_dev_is_probed(&dev->device)) {
+			VMBUS_LOG(DEBUG, "VMBUS driver already loaded");
+			continue;
+		}
+
 		ret = rte_vmbus_bus.bus.probe_device(drv, &dev->device);
 		if (ret < 0) {
 			VMBUS_LOG(NOTICE,
diff --git a/lib/eal/common/eal_common_dev.c b/lib/eal/common/eal_common_dev.c
index a38c211e5d..9047a01c4a 100644
--- a/lib/eal/common/eal_common_dev.c
+++ b/lib/eal/common/eal_common_dev.c
@@ -225,6 +225,9 @@ local_dev_probe(const char *devargs, struct rte_device **new_dev)
 	drv = rte_bus_find_driver(dev->bus, drv, dev);
 	if (drv == NULL) {
 		ret = -ENOTSUP;
+	} else if (rte_dev_is_probed(dev) && !dev->bus->allow_multi_probe) {
+		EAL_LOG(INFO, "Device %s is already probed", dev->name);
+		ret = -EEXIST;
 	} else {
 		ret = dev->bus->probe_device(drv, dev);
 		if (ret > 0)
diff --git a/lib/eal/include/bus_driver.h b/lib/eal/include/bus_driver.h
index 0db4473bcc..a2fd3bd82d 100644
--- a/lib/eal/include/bus_driver.h
+++ b/lib/eal/include/bus_driver.h
@@ -327,6 +327,7 @@ typedef void *(*rte_bus_dev_iterate_t)(const struct rte_bus *bus,
 struct rte_bus {
 	RTE_TAILQ_ENTRY(rte_bus) next; /**< Next bus object in linked list */
 	const char *name;            /**< Name of the bus */
+	bool allow_multi_probe;      /**< Allow probing devices multiple times */
 	rte_bus_scan_t scan;         /**< Scan for devices attached to bus */
 	rte_bus_probe_t probe;       /**< Probe devices on bus */
 	rte_bus_find_device_t find_device; /**< Find a device on the bus */
-- 
2.53.0



More information about the dev mailing list