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 <[email protected]> --- drivers/bus/auxiliary/auxiliary_common.c | 6 ------ drivers/bus/cdx/cdx.c | 5 ----- drivers/bus/dpaa/dpaa_bus.c | 3 --- drivers/bus/fslmc/fslmc_bus.c | 3 --- drivers/bus/ifpga/ifpga_bus.c | 7 ------- drivers/bus/pci/pci_common.c | 1 + drivers/bus/platform/platform.c | 3 --- drivers/bus/uacce/uacce.c | 5 ----- drivers/bus/vdev/vdev.c | 3 --- drivers/bus/vmbus/vmbus_common.c | 6 ------ lib/eal/common/eal_common_dev.c | 3 +++ lib/eal/include/bus_driver.h | 1 + 12 files changed, 5 insertions(+), 41 deletions(-) diff --git a/drivers/bus/auxiliary/auxiliary_common.c b/drivers/bus/auxiliary/auxiliary_common.c index 7824c26f92..c210e303ce 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) { diff --git a/drivers/bus/cdx/cdx.c b/drivers/bus/cdx/cdx.c index c38eae325b..64fb0a8534 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); diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index 14cd64cc32..b0ed61ba39 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -826,9 +826,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..e6db8f5100 100644 --- a/drivers/bus/fslmc/fslmc_bus.c +++ b/drivers/bus/fslmc/fslmc_bus.c @@ -541,9 +541,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..d3f3370bc5 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; 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..3d04ba4d25 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); diff --git a/drivers/bus/uacce/uacce.c b/drivers/bus/uacce/uacce.c index d8e15cd479..3dedc783ce 100644 --- a/drivers/bus/uacce/uacce.c +++ b/drivers/bus/uacce/uacce.c @@ -358,11 +358,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); diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index 5464fe28d4..4da9a2c950 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); diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c index ba923a2669..24b1c24f43 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); 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 55568fe08a..5ab988426c 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

