On Wed, May 06, 2026 at 05:51:51PM +0200, David Marchand wrote:
> There is nothing that requires a specific bus type.
>
> Signed-off-by: David Marchand <[email protected]>
This patch exposes an underlying issue with the DSA driver. When applied,
attempting to probe the workqueues gives the output:
"EAL: Device wq0.0 is already probed"
For each device. This is because the device is not zeroed in the scan
function, leaving a non-NULL driver pointer. See inline below.
/Bruce
> ---
> drivers/dma/idxd/idxd_bus.c | 38 ++++++++++++++-----------------------
> 1 file changed, 14 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/dma/idxd/idxd_bus.c b/drivers/dma/idxd/idxd_bus.c
> index 93bde69ff9..daf5f48ac1 100644
> --- a/drivers/dma/idxd/idxd_bus.c
> +++ b/drivers/dma/idxd/idxd_bus.c
> @@ -41,34 +41,24 @@ struct rte_dsa_device {
> };
>
> /* forward prototypes */
> -struct dsa_bus;
> static int dsa_scan(void);
> static bool dsa_match(const struct rte_driver *drv, const struct rte_device
> *dev);
> static int dsa_probe_device(struct rte_driver *drv, struct rte_device *dev);
> static enum rte_iova_mode dsa_get_iommu_class(void);
> static int dsa_addr_parse(const char *name, void *addr);
>
> -/**
> - * Structure describing the DSA bus
> - */
> -struct dsa_bus {
> - struct rte_bus bus; /**< Inherit the generic class */
> - struct rte_driver driver; /**< Driver struct for devices to
> point to */
> +struct rte_bus dsa_bus = {
> + .scan = dsa_scan,
> + .probe = rte_bus_generic_probe,
> + .match = dsa_match,
> + .probe_device = dsa_probe_device,
> + .find_device = rte_bus_generic_find_device,
> + .get_iommu_class = dsa_get_iommu_class,
> + .parse = dsa_addr_parse,
> };
>
> -struct dsa_bus dsa_bus = {
> - .bus = {
> - .scan = dsa_scan,
> - .probe = rte_bus_generic_probe,
> - .match = dsa_match,
> - .probe_device = dsa_probe_device,
> - .find_device = rte_bus_generic_find_device,
> - .get_iommu_class = dsa_get_iommu_class,
> - .parse = dsa_addr_parse,
> - },
> - .driver = {
> - .name = "dmadev_idxd",
> - },
> +struct rte_driver dsa_driver = {
> + .name = "dmadev_idxd",
> };
>
> static inline const char *
> @@ -267,7 +257,7 @@ static bool dsa_match(const struct rte_driver *drv, const
> struct rte_device *dev
> {
> const struct rte_dsa_device *dsa_dev = RTE_BUS_DEVICE(dev, *dsa_dev);
>
> - if (drv == &dsa_bus.driver) {
> + if (drv == &dsa_driver) {
> char type[64], name[64];
>
> if (read_wq_string(dsa_dev, "type", type, sizeof(type)) >= 0 &&
> @@ -319,7 +309,7 @@ dsa_scan(void)
> continue;
> }
> strlcpy(dev->wq_name, wq->d_name, sizeof(dev->wq_name));
> - rte_bus_add_device(&dsa_bus.bus, &dev->device);
> + rte_bus_add_device(&dsa_bus, &dev->device);
The issue with the driver is here. Before the strlcpy, and the previous
dsa_addr_parse() call, we just need to add:
memset(dev, 0, sizeof(*dev));
Since malloc does not zero the memory. [Alternatively, we can change malloc
to a zeroing equivalent].
Do you want me to do a separate patch to fix this, or roll the fix change
into this patch?
> devcount++;
>
> read_device_int(dev, "numa_node", &numa_node);
> @@ -357,8 +347,8 @@ dsa_addr_parse(const char *name, void *addr)
> return 0;
> }
>
> -RTE_REGISTER_BUS(dsa, dsa_bus.bus);
> +RTE_REGISTER_BUS(dsa, dsa_bus);
> RTE_INIT(dsa_bus_init)
> {
> - rte_bus_add_driver(&dsa_bus.bus, &dsa_bus.driver);
> + rte_bus_add_driver(&dsa_bus, &dsa_driver);
> }
> --
> 2.53.0
>