From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id E0CB09E3 for ; Fri, 21 Apr 2017 10:54:21 +0200 (CEST) Received: from pure.maildistiller.com (unknown [10.110.50.29]) by dispatch1-us1.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTP id 668886005A; Fri, 21 Apr 2017 08:54:21 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx4-us3.ppe-hosted.com (unknown [10.110.49.251]) by pure.maildistiller.com (Proofpoint Essentials ESMTP Server) with ESMTPS id E4B6460049; Fri, 21 Apr 2017 08:54:20 +0000 (UTC) Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx4-us3.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id 8719B80078; Fri, 21 Apr 2017 08:54:17 +0000 (UTC) Received: from [192.168.38.17] (84.52.89.52) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Fri, 21 Apr 2017 09:54:12 +0100 To: Alexey Kardashevskiy , References: <20170420072402.38106-1-aik@ozlabs.ru> <20170420072402.38106-5-aik@ozlabs.ru> CC: , Gowrishankar Muthukrishnan From: Andrew Rybchenko Message-ID: <5b5fe4e4-af39-4c27-fb3c-aff0c601b938@solarflare.com> Date: Fri, 21 Apr 2017 11:54:08 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170420072402.38106-5-aik@ozlabs.ru> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [84.52.89.52] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ukex01.SolarFlarecom.com (10.17.10.4) X-TM-AS-Product-Ver: SMEX-11.0.0.1191-8.100.1062-23020.003 X-TM-AS-Result: No--12.095500-0.000000-31 X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-MDID: 1492764861-augSGivGse-a Subject: Re: [dpdk-dev] [PATCH dpdk 4/5] vfio: Do try setting IOMMU type if already set 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, 21 Apr 2017 08:54:22 -0000 On 04/20/2017 10:24 AM, Alexey Kardashevskiy wrote: > The existing code correctly checks if a container is set to a group and > does not try attaching a group to a container for a second/third/... > device from the same IOMMU group. > > However it still tries to set IOMMU type to a container for every device > in a group which produces failure and closes container and group fds. > > This moves vfio_set_iommu_type() and DMA mapping code under: > if (!(group_status.flags & VFIO_GROUP_FLAGS_CONTAINER_SET)) > > Signed-off-by: Alexey Kardashevskiy > --- > lib/librte_eal/linuxapp/eal/eal_vfio.c | 50 +++++++++++++++++----------------- > 1 file changed, 25 insertions(+), 25 deletions(-) > > diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c > index 6e2e84ca7..46f951f4d 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c > +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c > @@ -298,33 +298,33 @@ vfio_setup_device(const char *sysfs_base, const char *dev_addr, > clear_group(vfio_group_fd); > return -1; > } > - } > > - /* > - * 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 == RTE_PROC_PRIMARY && > - vfio_cfg.vfio_active_groups == 1) { > - /* select an IOMMU type which we will be using */ > - const struct vfio_iommu_type *t = > + /* > + * 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 == RTE_PROC_PRIMARY && > + vfio_cfg.vfio_active_groups == 1) { > + /* select an IOMMU type which we will be using */ > + const struct vfio_iommu_type *t = > 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 = 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 = 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; > + } > } > } It looks like a duplicate of the earlier submitted patch http://dpdk.org/ml/archives/dev/2017-April/063077.html Andrew.