From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, stephen@networkplumber.org,
bruce.richardson@intel.com, Parav Pandit <parav@nvidia.com>,
Xueming Li <xuemingl@nvidia.com>,
Nipun Gupta <nipun.gupta@amd.com>,
Nikhil Agarwal <nikhil.agarwal@amd.com>,
Hemant Agrawal <hemant.agrawal@nxp.com>,
Sachin Saxena <sachin.saxena@nxp.com>,
Rosen Xu <rosen.xu@altera.com>, Chenbo Xia <chenbox@nvidia.com>,
Tomasz Duszynski <tduszynski@marvell.com>,
Chengwen Feng <fengchengwen@huawei.com>,
Long Li <longli@microsoft.com>, Wei Hu <weh@microsoft.com>
Subject: [PATCH v2 16/23] bus: factorize driver reference
Date: Wed, 6 May 2026 17:51:48 +0200 [thread overview]
Message-ID: <20260506155201.2709810-17-david.marchand@redhat.com> (raw)
In-Reply-To: <20260506155201.2709810-1-david.marchand@redhat.com>
Before this patch, setting the driver in the device object and error
rollback were the responsibility of each bus probe_device function.
This patch centralizes it in the EAL's local_dev_probe function.
The dev->driver field is now set before calling bus->probe_device,
ensuring that drivers can rely on it being set during probe.
On error, dev->driver is cleared only if the device was not previously
probed, to handle buses that support multiple probes
(RTE_PCI_DRV_PROBE_AGAIN).
As a consequence, each bus implementation no longer needs to set/clear
dev->driver and dev->device.driver.
In PCI bus, a side effect is that detecting a re-probe cannot use
rte_dev_is_probed (which checks dev->driver != NULL) anymore.
Switch to checking if intr_handle was allocated instead.
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
drivers/bus/auxiliary/auxiliary_common.c | 2 --
drivers/bus/cdx/cdx.c | 2 --
drivers/bus/dpaa/dpaa_bus.c | 6 ++----
drivers/bus/fslmc/fslmc_bus.c | 1 -
drivers/bus/ifpga/ifpga_bus.c | 2 --
drivers/bus/pci/pci_common.c | 6 ++----
drivers/bus/platform/platform.c | 8 +-------
drivers/bus/uacce/uacce.c | 1 -
drivers/bus/vmbus/vmbus_common.c | 2 --
lib/eal/common/eal_common_bus.c | 7 +++++++
lib/eal/common/eal_common_dev.c | 12 ++++++++++++
11 files changed, 24 insertions(+), 25 deletions(-)
diff --git a/drivers/bus/auxiliary/auxiliary_common.c b/drivers/bus/auxiliary/auxiliary_common.c
index 206b69bbd4..ba8c35ebbe 100644
--- a/drivers/bus/auxiliary/auxiliary_common.c
+++ b/drivers/bus/auxiliary/auxiliary_common.c
@@ -120,8 +120,6 @@ auxiliary_probe_device(struct rte_driver *drv, struct rte_device *dev)
aux_dev->driver = NULL;
rte_intr_instance_free(aux_dev->intr_handle);
aux_dev->intr_handle = NULL;
- } else {
- aux_dev->device.driver = &aux_drv->driver;
}
return ret;
diff --git a/drivers/bus/cdx/cdx.c b/drivers/bus/cdx/cdx.c
index e1405d1372..c6a4da7692 100644
--- a/drivers/bus/cdx/cdx.c
+++ b/drivers/bus/cdx/cdx.c
@@ -332,8 +332,6 @@ cdx_probe_device(struct rte_driver *drv, struct rte_device *dev)
CDX_BUS_ERR("Probe CDX driver: %s device: %s failed: %d",
cdx_drv->driver.name, dev_name, ret);
goto error_probe;
- } else {
- cdx_dev->device.driver = &cdx_drv->driver;
}
cdx_dev->driver = cdx_drv;
diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index 7f4a85a91d..b7d0caaf61 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -800,12 +800,10 @@ dpaa_bus_probe_device(struct rte_driver *drv, struct rte_device *dev)
int ret;
ret = dpaa_drv->probe(dpaa_drv, dpaa_dev);
- if (ret != 0) {
+ if (ret != 0)
DPAA_BUS_ERR("unable to probe: %s", dpaa_dev->name);
- } else {
+ else
dpaa_dev->driver = dpaa_drv;
- dpaa_dev->device.driver = &dpaa_drv->driver;
- }
return ret;
}
diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 29ef3b58cf..ae69bd0da2 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -524,7 +524,6 @@ fslmc_bus_probe_device(struct rte_driver *driver, struct rte_device *rte_dev)
DPAA2_BUS_ERR("Unable to probe");
} else {
dev->driver = drv;
- dev->device.driver = &drv->driver;
DPAA2_BUS_INFO("%s Plugged", dev->device.name);
}
diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index b2eb4f4413..a79a287fbe 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -281,8 +281,6 @@ ifpga_probe_device(struct rte_driver *drv, struct rte_device *dev)
ret = afu_drv->probe(afu_dev);
if (ret)
afu_dev->driver = NULL;
- else
- afu_dev->device.driver = &afu_drv->driver;
return ret;
}
diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index a507360ef6..5c37c5e543 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -203,7 +203,7 @@ pci_probe_device(struct rte_driver *drv, struct rte_device *dev)
if (pci_dev->device.numa_node < 0 && rte_socket_count() > 1)
PCI_LOG(INFO, "Device %s is not NUMA-aware", pci_dev->name);
- already_probed = rte_dev_is_probed(&pci_dev->device);
+ already_probed = (pci_dev->intr_handle != NULL);
if (already_probed && !(pci_drv->drv_flags & RTE_PCI_DRV_PROBE_AGAIN)) {
PCI_LOG(DEBUG, "Device %s is already probed", pci_dev->device.name);
return -EEXIST;
@@ -251,7 +251,7 @@ pci_probe_device(struct rte_driver *drv, struct rte_device *dev)
* to use driver flags for adjusting configuration.
*/
pci_dev->driver = pci_drv;
- if (pci_dev->driver->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
+ if (pci_drv->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
ret = rte_pci_map_device(pci_dev);
if (ret != 0) {
pci_dev->driver = NULL;
@@ -285,8 +285,6 @@ pci_probe_device(struct rte_driver *drv, struct rte_device *dev)
pci_dev->vfio_req_intr_handle = NULL;
rte_intr_instance_free(pci_dev->intr_handle);
pci_dev->intr_handle = NULL;
- } else {
- pci_dev->device.driver = &pci_drv->driver;
}
return ret;
diff --git a/drivers/bus/platform/platform.c b/drivers/bus/platform/platform.c
index 01c8239cbb..671f36fac9 100644
--- a/drivers/bus/platform/platform.c
+++ b/drivers/bus/platform/platform.c
@@ -329,17 +329,11 @@ device_setup(struct rte_platform_device *pdev)
static int
driver_call_probe(struct rte_platform_driver *pdrv, struct rte_platform_device *pdev)
{
- int ret;
-
if (pdrv->probe != NULL) {
pdev->driver = pdrv;
- ret = pdrv->probe(pdev);
- if (ret)
- return ret;
+ return pdrv->probe(pdev);
}
- pdev->device.driver = &pdrv->driver;
-
return 0;
}
diff --git a/drivers/bus/uacce/uacce.c b/drivers/bus/uacce/uacce.c
index b0deb39185..d4a18b2835 100644
--- a/drivers/bus/uacce/uacce.c
+++ b/drivers/bus/uacce/uacce.c
@@ -365,7 +365,6 @@ uacce_probe_device(struct rte_driver *drv, struct rte_device *dev)
UACCE_BUS_ERR("probe device %s with driver %s failed %d",
dev_name, uacce_drv->driver.name, ret);
} else {
- uacce_dev->device.driver = &uacce_drv->driver;
uacce_dev->driver = uacce_drv;
UACCE_BUS_DEBUG("probe device %s with driver %s success",
dev_name, uacce_drv->driver.name);
diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c
index bd375ae6bb..43652c0487 100644
--- a/drivers/bus/vmbus/vmbus_common.c
+++ b/drivers/bus/vmbus/vmbus_common.c
@@ -119,8 +119,6 @@ vmbus_probe_device(struct rte_driver *drv, struct rte_device *dev)
if (ret != 0) {
vmbus_dev->driver = NULL;
rte_vmbus_unmap_device(vmbus_dev);
- } else {
- vmbus_dev->device.driver = &vmbus_drv->driver;
}
return ret;
diff --git a/lib/eal/common/eal_common_bus.c b/lib/eal/common/eal_common_bus.c
index 94b7be5f5f..ca13ccce5b 100644
--- a/lib/eal/common/eal_common_bus.c
+++ b/lib/eal/common/eal_common_bus.c
@@ -86,6 +86,7 @@ rte_bus_generic_probe(struct rte_bus *bus)
TAILQ_FOREACH(dev, &bus->device_list, next) {
struct rte_driver *drv = NULL;
+ bool was_probed;
int ret;
if (rte_bus_device_is_ignored(bus, dev->name))
@@ -102,7 +103,13 @@ rte_bus_generic_probe(struct rte_bus *bus)
if (drv == NULL)
continue;
+ was_probed = rte_dev_is_probed(dev);
+ if (!was_probed)
+ dev->driver = drv;
ret = bus->probe_device(drv, dev);
+ if (!was_probed && ret != 0)
+ dev->driver = NULL;
+
if (ret > 0)
goto next_driver;
diff --git a/lib/eal/common/eal_common_dev.c b/lib/eal/common/eal_common_dev.c
index 9047a01c4a..48b631532a 100644
--- a/lib/eal/common/eal_common_dev.c
+++ b/lib/eal/common/eal_common_dev.c
@@ -229,7 +229,19 @@ local_dev_probe(const char *devargs, struct rte_device **new_dev)
EAL_LOG(INFO, "Device %s is already probed", dev->name);
ret = -EEXIST;
} else {
+ bool was_probed = rte_dev_is_probed(dev);
+
+ /*
+ * Reference driver structure.
+ * This needs to be before .probe_device as some bus (like PCI) use
+ * driver flags for adjusting configuration.
+ */
+ if (!was_probed)
+ dev->driver = drv;
ret = dev->bus->probe_device(drv, dev);
+ if (!was_probed && ret != 0)
+ dev->driver = NULL;
+
if (ret > 0)
goto next_driver;
}
--
2.53.0
next prev parent reply other threads:[~2026-05-06 15:54 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 11:44 [PATCH 00/23] Consolidate bus driver infrastructure David Marchand
2026-04-29 11:44 ` [PATCH 01/23] bus/ifpga: remove unused AFU lookup helper David Marchand
2026-04-29 11:44 ` [PATCH 02/23] crypto/octeontx: remove check on driver in remove David Marchand
2026-04-29 11:59 ` [EXTERNAL] " Anoob Joseph
2026-04-29 11:44 ` [PATCH 03/23] bus: remove device and driver checks in DMA map/unmap David Marchand
2026-04-29 11:44 ` [PATCH 04/23] drivers/bus: remove device and driver checks in unplug David Marchand
2026-04-29 11:44 ` [PATCH 05/23] drivers/bus: remove device and driver checks in plug David Marchand
2026-04-29 11:44 ` [PATCH 06/23] bus: add bus conversion macros David Marchand
2026-04-29 11:44 ` [PATCH 07/23] bus: factorize driver list David Marchand
2026-04-29 11:44 ` [PATCH 08/23] bus: factorize device list David Marchand
2026-04-29 11:44 ` [PATCH 09/23] bus: consolidate device lookup David Marchand
2026-04-29 11:44 ` [PATCH 10/23] bus: consolidate device iteration David Marchand
2026-04-29 11:44 ` [PATCH 11/23] bus: factorize driver lookup David Marchand
2026-04-29 11:44 ` [PATCH 12/23] bus: refactor device probe David Marchand
2026-04-29 11:44 ` [PATCH 13/23] bus: support multiple probe David Marchand
2026-04-29 11:44 ` [PATCH 14/23] drivers/bus: initialize NXP bus specifics in scan David Marchand
2026-04-29 11:44 ` [PATCH 15/23] bus: implement probe in EAL David Marchand
2026-04-29 11:44 ` [PATCH 16/23] bus: factorize driver reference David Marchand
2026-04-29 11:44 ` [PATCH 17/23] drivers: rely on generic driver David Marchand
2026-04-29 11:44 ` [PATCH 18/23] drivers/bus: remove bus-specific driver references David Marchand
2026-04-29 11:44 ` [PATCH 19/23] dma/idxd: remove specific bus type David Marchand
2026-04-29 11:44 ` [PATCH 20/23] drivers/bus: separate specific bus metadata for NXP drivers David Marchand
2026-04-29 11:44 ` [PATCH 21/23] drivers/bus: remove specific bus types David Marchand
2026-04-29 11:44 ` [PATCH 22/23] eventdev: rename dev field to device David Marchand
2026-04-29 11:44 ` [PATCH 23/23] bus: add class device conversion macro David Marchand
2026-05-06 15:51 ` [PATCH v2 00/23] Consolidate bus driver infrastructure David Marchand
2026-05-06 15:51 ` [PATCH v2 01/23] bus/ifpga: remove unused AFU lookup helper David Marchand
2026-05-06 15:51 ` [PATCH v2 02/23] crypto/octeontx: remove check on driver in remove David Marchand
2026-05-06 15:51 ` [PATCH v2 03/23] bus: remove device and driver checks in DMA map/unmap David Marchand
2026-05-06 15:51 ` [PATCH v2 04/23] drivers/bus: remove device and driver checks in unplug David Marchand
2026-05-06 15:51 ` [PATCH v2 05/23] drivers/bus: remove device and driver checks in plug David Marchand
2026-05-06 15:51 ` [PATCH v2 06/23] bus: add bus conversion macros David Marchand
2026-05-06 15:51 ` [PATCH v2 07/23] bus: factorize driver list David Marchand
2026-05-06 15:51 ` [PATCH v2 08/23] bus: factorize device list David Marchand
2026-05-06 15:51 ` [PATCH v2 09/23] bus: consolidate device lookup David Marchand
2026-05-06 15:51 ` [PATCH v2 10/23] bus: consolidate device iteration David Marchand
2026-05-06 15:51 ` [PATCH v2 11/23] bus: factorize driver lookup David Marchand
2026-05-06 15:51 ` [PATCH v2 12/23] bus: refactor device probe David Marchand
2026-05-06 15:51 ` [PATCH v2 13/23] bus: support multiple probe David Marchand
2026-05-06 15:51 ` [PATCH v2 14/23] drivers/bus: initialize NXP bus specifics in scan David Marchand
2026-05-06 15:51 ` [PATCH v2 15/23] bus: implement probe in EAL David Marchand
2026-05-06 15:51 ` David Marchand [this message]
2026-05-06 15:51 ` [PATCH v2 17/23] drivers: rely on generic driver David Marchand
2026-05-06 15:51 ` [PATCH v2 18/23] drivers/bus: remove bus-specific driver references David Marchand
2026-05-06 15:51 ` [PATCH v2 19/23] dma/idxd: remove specific bus type David Marchand
2026-05-06 15:51 ` [PATCH v2 20/23] drivers/bus: separate specific bus metadata for NXP drivers David Marchand
2026-05-06 15:51 ` [PATCH v2 21/23] drivers/bus: remove specific bus types David Marchand
2026-05-06 15:51 ` [PATCH v2 22/23] eventdev: rename dev field to device David Marchand
2026-05-06 15:51 ` [PATCH v2 23/23] bus: add class device conversion macro David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260506155201.2709810-17-david.marchand@redhat.com \
--to=david.marchand@redhat.com \
--cc=bruce.richardson@intel.com \
--cc=chenbox@nvidia.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=hemant.agrawal@nxp.com \
--cc=longli@microsoft.com \
--cc=nikhil.agarwal@amd.com \
--cc=nipun.gupta@amd.com \
--cc=parav@nvidia.com \
--cc=rosen.xu@altera.com \
--cc=sachin.saxena@nxp.com \
--cc=stephen@networkplumber.org \
--cc=tduszynski@marvell.com \
--cc=thomas@monjalon.net \
--cc=weh@microsoft.com \
--cc=xuemingl@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox