On 9/9/2026 12:02 PM, Anatoly Burakov wrote:
The NBL driver currently uses group bind API, but it is using it only to
get group fd and nothing else. In context of NBL driver, this is the only
usage of VFIO API's in the driver, and it is not necessary to use it for
what NBL driver is trying to accomplish.
Use a direct `open()` call instead, and store the group fd in common
structure.
Signed-off-by: Anatoly Burakov <[email protected]>
---
drivers/net/nbl/nbl_common/nbl_userdev.c | 24 ++++++++++++++++-------
drivers/net/nbl/nbl_include/nbl_include.h | 1 +
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/drivers/net/nbl/nbl_common/nbl_userdev.c
b/drivers/net/nbl/nbl_common/nbl_userdev.c
index f1522772f5..b3b6548bb8 100644
--- a/drivers/net/nbl/nbl_common/nbl_userdev.c
+++ b/drivers/net/nbl/nbl_common/nbl_userdev.c
@@ -387,6 +387,15 @@ nbl_userdev_mem_event_callback(enum rte_mem_event type,
const void *addr, size_t
}
}
+static int
+nbl_open_group_fd(int iommu_group_num)
+{
+ char path[PATH_MAX];
+
+ snprintf(path, sizeof(path), DEV_VFIO_GROUP_FMT, iommu_group_num);
+ return open(path, O_RDWR);
+}
+
static int nbl_mdev_map_device(struct nbl_adapter *adapter)
{
const struct rte_pci_device *pci_dev = adapter->pci_dev;
@@ -424,11 +433,16 @@ static int nbl_mdev_map_device(struct nbl_adapter
*adapter)
}
NBL_LOG(DEBUG, "nbl vfio container %d", container);
- vfio_group_fd = dev_vfio_container_group_bind(container,
common->iommu_group_num);
+ /*
+ * This assumes one device per group, as kernel will return -EBUSY on
+ * attempting to open the same group fd for a different device.
+ */
+ vfio_group_fd = nbl_open_group_fd(common->iommu_group_num);
if (vfio_group_fd < 0) {
NBL_LOG(ERR, "nbl vfio group bind failed, %d", vfio_group_fd);
goto free_container;
}
+ common->groupfd = vfio_group_fd;
This is indeed making an assumption that there can be only one device
per group, while original implementation didn't make such an assumption.
I have an implementation that addresses this issue, so a new revision
will be sent. I'll wait for more feedback before respinning.
--
Thanks,
Anatoly