From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id EED6D2B8C; Tue, 25 Sep 2018 09:56:24 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Sep 2018 00:56:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,301,1534834800"; d="scan'208";a="86318481" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga003.jf.intel.com with ESMTP; 25 Sep 2018 00:56:23 -0700 Received: from fmsmsx126.amr.corp.intel.com (10.18.125.43) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 25 Sep 2018 00:56:23 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX126.amr.corp.intel.com (10.18.125.43) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 25 Sep 2018 00:56:23 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.220]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.245]) with mapi id 14.03.0319.002; Tue, 25 Sep 2018 15:56:20 +0800 From: "Wang, Xiao W" To: "Stojaczyk, Dariusz" , "dev@dpdk.org" CC: Alejandro Lucero , "Burakov, Anatoly" , "stable@dpdk.org" Thread-Topic: [PATCH 1/2] eal/vfio: check if we already have the group fd open Thread-Index: AQHUTo1IIiOdIKkVcUqFVyxfNpjHeKUArRZg Date: Tue, 25 Sep 2018 07:56:19 +0000 Message-ID: References: <20180917134643.103871-1-dariusz.stojaczyk@intel.com> In-Reply-To: <20180917134643.103871-1-dariusz.stojaczyk@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDQ2ZjJlNTQtOGI4OC00ODlhLWExYTYtOWJjN2YwZTVkNjM0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiVHJ1cERhcm1zUlp2anhcL1MyRnAxbTB4MTFLSzFKRHVPYlNBRkIzZXllQWdFXC9BSlJkMWpZaXBDbjJLZVNZNHRXIn0= dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 1/2] eal/vfio: check if we already have the group fd open X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Sep 2018 07:56:25 -0000 Hi, > -----Original Message----- > From: Stojaczyk, Dariusz > Sent: Monday, September 17, 2018 9:47 PM > To: dev@dpdk.org > Cc: Alejandro Lucero ; Burakov, Anatoly > ; stable@dpdk.org; Stojaczyk, Dariusz > ; Wang, Xiao W > Subject: [PATCH 1/2] eal/vfio: check if we already have the group fd open >=20 > From: Dariusz Stojaczyk >=20 > Always attempt to find already opened fd for an iommu > group as subsequent attempts to open it will fail. >=20 > 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. >=20 > Fixes: ea2dc1066870 ("vfio: add multi container support") > Cc: xiao.w.wang@intel.com >=20 > Signed-off-by: Dariusz Stojaczyk > --- > lib/librte_eal/linuxapp/eal/eal_vfio.c | 5 +++++ > 1 file changed, 5 insertions(+) >=20 > 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; > } >=20 > + /* check if we already have the group descriptor open */ > + for (i =3D 0; i < VFIO_MAX_GROUPS; i++) > + if (vfio_cfg->vfio_groups[i].group_num =3D=3D iommu_group_num) > + return vfio_cfg->vfio_groups[i].fd; > + > /* Check room for new group */ > if (vfio_cfg->vfio_active_groups =3D=3D VFIO_MAX_GROUPS) { > RTE_LOG(ERR, EAL, "Maximum number of VFIO groups > reached!\n"); > -- > 2.17.1 Acked-by: Xiao Wang BRs, Xiao