From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 1DE422935 for ; Fri, 28 Apr 2017 15:24:29 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Apr 2017 06:24:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,388,1488873600"; d="scan'208";a="93320276" Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159]) by orsmga005.jf.intel.com with ESMTP; 28 Apr 2017 06:24:27 -0700 Received: from irsmsx112.ger.corp.intel.com (10.108.20.5) by IRSMSX104.ger.corp.intel.com (163.33.3.159) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 28 Apr 2017 14:24:26 +0100 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.12]) by irsmsx112.ger.corp.intel.com ([169.254.1.61]) with mapi id 14.03.0319.002; Fri, 28 Apr 2017 14:24:26 +0100 From: "Burakov, Anatoly" To: Andrew Rybchenko , "dev@dpdk.org" CC: Alejandro Lucero Thread-Topic: [PATCH] vfio: set IOMMU type for the container once Thread-Index: AQHSrV10dl7ar1afkkuduWf5wVw1uKHa6qQg Date: Fri, 28 Apr 2017 13:24:25 +0000 Message-ID: References: <1491321976-27290-1-git-send-email-arybchenko@solarflare.com> In-Reply-To: <1491321976-27290-1-git-send-email-arybchenko@solarflare.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_PUBLIC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDk0N2ZjNjYtNDJjMy00ZGQ1LTg4MWUtNmQxODEwYzZiOTYzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX1BVQkxJQyJ9XX1dfSwiU3ViamVjdExhYmVscyI6W10sIlRNQ1ZlcnNpb24iOiIxNi41LjkuMyIsIlRydXN0ZWRMYWJlbEhhc2giOiJjQ0tYV1BjQVwvNTNJaXpZM2hyXC95TXFHdTBPYmt5WXArdDltQUNVeWFwVzg9In0= dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action 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: set IOMMU type for the container once 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: Fri, 28 Apr 2017 13:24:30 -0000 > From: Andrew Rybchenko [mailto:arybchenko@solarflare.com] > Sent: Tuesday, April 4, 2017 5:06 PM > To: dev@dpdk.org > Cc: Burakov, Anatoly ; Alejandro Lucero > > Subject: [PATCH] vfio: set IOMMU type for the container once >=20 > If more than one used PCI device belongs to one IOMMU group, it is still = one > IOMMU group and the container IOMMU type should be set only once. >=20 > Fixes: 94c0776b1bad ("vfio: support hotplug") >=20 > Signed-off-by: Andrew Rybchenko > --- > My testing of the patch is limitted to my configuration with 2 PCI functi= ons > which belong to one IOMMU group. >=20 > lib/librte_eal/linuxapp/eal/eal_vfio.c | 54 ++++++++++++++++++----------= --- > --- > 1 file changed, 29 insertions(+), 25 deletions(-) >=20 > diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c > b/lib/librte_eal/linuxapp/eal/eal_vfio.c > index 6e2e84c..dd59c1c 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c > +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c > @@ -298,33 +298,37 @@ vfio_setup_device(const char *sysfs_base, const > char *dev_addr, > clear_group(vfio_group_fd); > return -1; > } > - } >=20 > - /* > - * pick an IOMMU type and set up DMA mappings for container > - * > - * needs to be done only once, only when first group is assigned to > - * a container and only in primary process. Note this can happen > several > - * times with the hotplug functionality. > - */ > - if (internal_config.process_type =3D=3D RTE_PROC_PRIMARY && > - vfio_cfg.vfio_active_groups =3D=3D 1) { > - /* select an IOMMU type which we will be using */ > - const struct vfio_iommu_type *t =3D > + /* > + * pick an IOMMU type and set up DMA mappings for > container > + * > + * needs to be done only once, only when first group is > + * assigned to a container and only in primary process. > + * Note this can happen several times with the hotplug > + * functionality. > + */ > + if (internal_config.process_type =3D=3D RTE_PROC_PRIMARY && > + vfio_cfg.vfio_active_groups =3D=3D 1) { > + /* select an IOMMU type which we will be using */ > + const struct vfio_iommu_type *t =3D >=20 > vfio_set_iommu_type(vfio_cfg.vfio_container_fd); > - if (!t) { > - RTE_LOG(ERR, EAL, " %s failed to select IOMMU > type\n", dev_addr); > - close(vfio_group_fd); > - clear_group(vfio_group_fd); > - return -1; > - } > - ret =3D t->dma_map_func(vfio_cfg.vfio_container_fd); > - if (ret) { > - RTE_LOG(ERR, EAL, " %s DMA remapping failed, " > - "error %i (%s)\n", dev_addr, errno, > strerror(errno)); > - close(vfio_group_fd); > - clear_group(vfio_group_fd); > - return -1; > + if (!t) { > + RTE_LOG(ERR, EAL, > + " %s failed to select IOMMU type\n", > + dev_addr); > + close(vfio_group_fd); > + clear_group(vfio_group_fd); > + return -1; > + } > + ret =3D t->dma_map_func(vfio_cfg.vfio_container_fd); > + if (ret) { > + RTE_LOG(ERR, EAL, > + " %s DMA remapping failed, error %i > (%s)\n", > + dev_addr, errno, strerror(errno)); > + close(vfio_group_fd); > + clear_group(vfio_group_fd); > + return -1; > + } > } > } >=20 > -- > 2.7.4 Acked-by: Anatoly Burakov