[dpdk-dev] vfio: fix device hotplug when several devices per group

Message ID e8d4fc873debad5e0714a166c463850077952265.1523355348.git.anatoly.burakov@intel.com (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

Anatoly Burakov April 10, 2018, 10:23 a.m. UTC
  We only need to perform DMA mapping for first device in first group.
At the time of mapping, we haven't yet added the device into the group,
so the count is expected to be zero.

Fixes: 810bfa64c673 ("vfio: fix index for tracking devices in a group")
Fixes: a9c349e3a100 ("vfio: fix device unplug when several devices per group")
Fixes: 94c0776b1bad ("vfio: support hotplug")
Cc: alejandro.lucero@netronome.com
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/linuxapp/eal/eal_vfio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon April 12, 2018, 11:14 p.m. UTC | #1
10/04/2018 12:23, Anatoly Burakov:
> We only need to perform DMA mapping for first device in first group.
> At the time of mapping, we haven't yet added the device into the group,
> so the count is expected to be zero.
> 
> Fixes: 810bfa64c673 ("vfio: fix index for tracking devices in a group")
> Fixes: a9c349e3a100 ("vfio: fix device unplug when several devices per group")
> Fixes: 94c0776b1bad ("vfio: support hotplug")
> Cc: alejandro.lucero@netronome.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c
index e44ae4d..15250ee 100644
--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c
@@ -332,7 +332,8 @@  rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 		 * functionality.
 		 */
 		if (internal_config.process_type == RTE_PROC_PRIMARY &&
-				vfio_cfg.vfio_active_groups == 1) {
+				vfio_cfg.vfio_active_groups == 1 &&
+				vfio_group_device_count(vfio_group_fd) == 0) {
 			/* select an IOMMU type which we will be using */
 			const struct vfio_iommu_type *t =
 				vfio_set_iommu_type(vfio_cfg.vfio_container_fd);