From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id B422E1B002; Mon, 17 Sep 2018 15:49:30 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Sep 2018 06:49:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,385,1531810800"; d="scan'208";a="263289802" Received: from violet.igk.intel.com ([10.102.17.58]) by fmsmga005.fm.intel.com with ESMTP; 17 Sep 2018 06:49:27 -0700 From: Darek Stojaczyk To: dev@dpdk.org Cc: Alejandro Lucero , Anatoly Burakov , stable@dpdk.org, Dariusz Stojaczyk , xiao.w.wang@intel.com Date: Mon, 17 Sep 2018 15:46:42 +0200 Message-Id: <20180917134643.103871-1-dariusz.stojaczyk@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-stable] [PATCH 1/2] eal/vfio: check if we already have the group fd open X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Sep 2018 13:49:31 -0000 From: Dariusz Stojaczyk 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: xiao.w.wang@intel.com Signed-off-by: Dariusz Stojaczyk --- lib/librte_eal/linuxapp/eal/eal_vfio.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c index c68dc38e0..bcb869be1 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c @@ -1680,6 +1680,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"); -- 2.17.1