]> git.droids-corp.org - dpdk.git/commitdiff
bus/fslmc: fix VFIO setup
authorRomain Delhomel <romain.delhomel@6wind.com>
Fri, 3 Jun 2022 15:18:30 +0000 (17:18 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 7 Jun 2022 18:49:20 +0000 (20:49 +0200)
At device probe, the fslmc bus driver calls rte_vfio_get_group_fd() to
get a fd associated to a vfio group. This function first checks if the
group is already opened, else it opens /dev/vfio/%u, and increases the
number of active groups in default_vfio_cfg (which references the
default vfio container).

When adding the first group to a vfio_cfg, the caller is supposed to
pick an IOMMU type and set up DMA mappings for container, as it's done
by pci bus, but it is not done here. Instead, a new container is created
and used.

This prevents the pci bus driver, which uses the default_vfio_cfg
container, to configure the container because
default_vfio_cfg->active_group > 1.

This patch fixes the issue by always creating a new container (and its
associated vfio_cfg) and binding the group to it.

Fixes: a69f79300262 ("bus/fslmc: support multi VFIO group")
Cc: stable@dpdk.org
Signed-off-by: Romain Delhomel <romain.delhomel@6wind.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
drivers/bus/fslmc/fslmc_vfio.c

index 1b89a56bbc2a1152bbddda66846c3981d4f8bbee..3d4e71a80a2f8e8dc30c2d18c2b1ce5b5e206b32 100644 (file)
@@ -995,6 +995,7 @@ fslmc_vfio_setup_group(void)
 {
        int groupid;
        int ret;
+       int vfio_container_fd;
        struct vfio_group_status status = { .argsz = sizeof(status) };
 
        /* if already done once */
@@ -1013,8 +1014,15 @@ fslmc_vfio_setup_group(void)
                return 0;
        }
 
+       ret = rte_vfio_container_create();
+       if (ret < 0) {
+               DPAA2_BUS_ERR("Failed to open VFIO container");
+               return ret;
+       }
+       vfio_container_fd = ret;
+
        /* Get the actual group fd */
-       ret = rte_vfio_get_group_fd(groupid);
+       ret = rte_vfio_container_group_bind(vfio_container_fd, groupid);
        if (ret < 0)
                return ret;
        vfio_group.fd = ret;