From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 24BB1DE0 for ; Thu, 10 Dec 2015 10:57:53 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 10 Dec 2015 01:57:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,407,1444719600"; d="scan'208";a="868712356" Received: from irsmsx151.ger.corp.intel.com ([163.33.192.59]) by orsmga002.jf.intel.com with ESMTP; 10 Dec 2015 01:57:52 -0800 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.96]) by IRSMSX151.ger.corp.intel.com ([169.254.4.95]) with mapi id 14.03.0248.002; Thu, 10 Dec 2015 09:57:51 +0000 From: "Burakov, Anatoly" To: Stephen Hemminger , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] vfio: support iommu group zero Thread-Index: AQHRMqr8BNQ7psdlTUuaLCWY0f/xlp7D/Hog Date: Thu, 10 Dec 2015 09:57:51 +0000 Message-ID: References: <1449683756-13381-1-git-send-email-stephen@networkplumber.org> In-Reply-To: <1449683756-13381-1-git-send-email-stephen@networkplumber.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] vfio: support iommu group zero X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Dec 2015 09:57:54 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen > Hemminger > Sent: Wednesday, December 9, 2015 5:56 PM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH] vfio: support iommu group zero >=20 > The current implementation of VFIO will not with the new no-IOMMU mode > in 4.4 kernel. The original code assumed that IOMMU group zero would > never be used. Group numbers are assigned starting at zero, and up until > now the group numbers came from the hardware which is likely to use group > 0 for system devices that are not used with DPDK. >=20 > The fix is to allow 0 as a valid group and rearrange code to split the re= turn > value from the group value. >=20 > Signed-off-by: Stephen Hemminger > --- > Why was this ignored? It was originally sent on 26 Oct 15 back when IOMMU > discussion was lively. >=20 > lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 22 +++++++++++----------- > 1 file changed, 11 insertions(+), 11 deletions(-) >=20 > diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c > b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c > index 0e6c48a..74f91ba 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c > +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c > @@ -499,14 +499,15 @@ pci_vfio_get_group_fd(int iommu_group_no) } >=20 > /* parse IOMMU group number for a PCI device > - * returns -1 for errors, 0 for non-existent group */ > + * returns 1 on success, -1 for errors, 0 for non-existent group */ > static int > -pci_vfio_get_group_no(const char *pci_addr) > +pci_vfio_get_group_no(const char *pci_addr, int *iommu_group_no) > { > char linkname[PATH_MAX]; > char filename[PATH_MAX]; > char *tok[16], *group_tok, *end; > - int ret, iommu_group_no; > + int ret; >=20 > memset(linkname, 0, sizeof(linkname)); > memset(filename, 0, sizeof(filename)); @@ -533,13 +534,13 @@ > pci_vfio_get_group_no(const char *pci_addr) > errno =3D 0; > group_tok =3D tok[ret - 1]; > end =3D group_tok; > - iommu_group_no =3D strtol(group_tok, &end, 10); > + *iommu_group_no =3D strtol(group_tok, &end, 10); > if ((end !=3D group_tok && *end !=3D '\0') || errno !=3D 0) { > RTE_LOG(ERR, EAL, " %s error parsing IOMMU number!\n", > pci_addr); > return -1; > } >=20 > - return iommu_group_no; > + return 1; > } >=20 > static void > @@ -581,16 +582,15 @@ pci_vfio_map_resource(struct rte_pci_device > *dev) > loc->domain, loc->bus, loc->devid, loc->function); >=20 > /* get group number */ > - iommu_group_no =3D pci_vfio_get_group_no(pci_addr); > - > - /* if 0, group doesn't exist */ > - if (iommu_group_no =3D=3D 0) { > + ret =3D pci_vfio_get_group_no(pci_addr, &iommu_group_no); > + if (ret =3D=3D 0) { > RTE_LOG(WARNING, EAL, " %s not managed by VFIO driver, > skipping\n", > - pci_addr); > + pci_addr); > return 1; > } > + > /* if negative, something failed */ > - else if (iommu_group_no < 0) > + if (ret < 0) > return -1; >=20 > /* get the actual group fd */ > -- > 2.1.4 Sorry, slipped through the cracks somehow. I see no obvious issues with the= patch, however I've never encountered a group 0 while testing VFIO. As per= Alex, that would be more used in the no-iommu scenario, and this break doe= sn't appear to affect anything else even without no-iommu functionality, so= ... Acked-by: Anatoly Burakov