Skip to content

Commit

Permalink
bus/vdev: fix devargs in secondary process
Browse files Browse the repository at this point in the history
[ upstream commit 6666628362c94a0b567a39a0177539c12c97d999 ]

When a device is created by a secondary process, an empty devargs is
temporarily generated and bound to it. This causes the device to not
be associated with the correct devargs, and the empty devargs are not
released when the resource is freed.

This patch fixes the issue by matching the devargs when inserting a
device in secondary process.

Fixes: dda9873 ("vdev: make virtual bus use its device struct")
Fixes: a160404 ("eal: extract vdev infra")

Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
  • Loading branch information
yemj-odc authored and bluca committed Mar 13, 2024
1 parent 60ca8f9 commit ba82306
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion drivers/bus/vdev/vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,22 @@ alloc_devargs(const char *name, const char *args)
return devargs;
}

static struct rte_devargs *
vdev_devargs_lookup(const char *name)
{
struct rte_devargs *devargs;
char dev_name[32];

RTE_EAL_DEVARGS_FOREACH("vdev", devargs) {
devargs->bus->parse(devargs->name, &dev_name);
if (strcmp(dev_name, name) == 0) {
VDEV_LOG(INFO, "devargs matched %s", dev_name);
return devargs;
}
}
return NULL;
}

static int
insert_vdev(const char *name, const char *args,
struct rte_vdev_device **p_dev,
Expand All @@ -275,7 +291,11 @@ insert_vdev(const char *name, const char *args,
if (name == NULL)
return -EINVAL;

devargs = alloc_devargs(name, args);
if (rte_eal_process_type() == RTE_PROC_PRIMARY)
devargs = alloc_devargs(name, args);
else
devargs = vdev_devargs_lookup(name);

if (!devargs)
return -ENOMEM;

Expand Down

0 comments on commit ba82306

Please sign in to comment.