summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>2018-09-17 15:46:42 +0200
committerThomas Monjalon <thomas@monjalon.net>2018-10-29 01:58:31 +0100
commitdb9d32b8b73e3fc9e16f8a38e5b7f66a5df0e36a (patch)
tree328d9319b615312530711b26d045c52a26e02b36 /lib
parent630deed612ca382f48a3ef4b65dfc74b7cd09cf9 (diff)
downloaddpdk-db9d32b8b73e3fc9e16f8a38e5b7f66a5df0e36a.zip
dpdk-db9d32b8b73e3fc9e16f8a38e5b7f66a5df0e36a.tar.gz
dpdk-db9d32b8b73e3fc9e16f8a38e5b7f66a5df0e36a.tar.xz
vfio: check if group fd is already open
Always attempt to find already opened fd for an iommu group as subsequent attempts to open it will fail. There's no public API to check if a group was already bound and has a container, so rte_vfio_container_group_bind() shouldn't fail in such case. Fixes: ea2dc1066870 ("vfio: add multi container support") Cc: stable@dpdk.org Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Acked-by: Xiao Wang <xiao.w.wang@intel.com> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/librte_eal/linuxapp/eal/eal_vfio.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c
index ebecde1..04c8f2e 100644
--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c
@@ -1702,6 +1702,11 @@ rte_vfio_container_group_bind(int container_fd, int iommu_group_num)
return -1;
}
+ /* check if we already have the group descriptor open */
+ for (i = 0; i < VFIO_MAX_GROUPS; i++)
+ if (vfio_cfg->vfio_groups[i].group_num == iommu_group_num)
+ return vfio_cfg->vfio_groups[i].fd;
+
/* Check room for new group */
if (vfio_cfg->vfio_active_groups == VFIO_MAX_GROUPS) {
RTE_LOG(ERR, EAL, "Maximum number of VFIO groups reached!\n");