From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by dpdk.org (Postfix) with ESMTP id 668072B84 for ; Thu, 20 Apr 2017 21:32:16 +0200 (CEST) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3KJSwIQ023949 for ; Thu, 20 Apr 2017 15:32:15 -0400 Received: from e23smtp04.au.ibm.com (e23smtp04.au.ibm.com [202.81.31.146]) by mx0a-001b2d01.pphosted.com with ESMTP id 29xyxc9j7h-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 20 Apr 2017 15:32:15 -0400 Received: from localhost by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 21 Apr 2017 05:32:12 +1000 Received: from d23relay10.au.ibm.com (202.81.31.229) by e23smtp04.au.ibm.com (202.81.31.210) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 21 Apr 2017 05:32:09 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3KJW1Lv2359628 for ; Fri, 21 Apr 2017 05:32:09 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v3KJVWeN007156 for ; Fri, 21 Apr 2017 05:31:32 +1000 Received: from [9.79.204.165] ([9.79.204.165]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v3KJVUwm006915; Fri, 21 Apr 2017 05:31:31 +1000 To: Alexey Kardashevskiy , dev@dpdk.org References: <20170420072402.38106-1-aik@ozlabs.ru> <20170420072402.38106-5-aik@ozlabs.ru> Cc: JPF@zurich.ibm.com, Gowrishankar Muthukrishnan From: gowrishankar muthukrishnan Date: Fri, 21 Apr 2017 01:01:18 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170420072402.38106-5-aik@ozlabs.ru> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable x-cbid: 17042019-0012-0000-0000-000002286F1A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042019-0013-0000-0000-0000073E8292 Message-Id: <7f395f01-82e4-f8c6-cf87-af426b43ae53@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-20_17:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=18 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1704200170 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: Thu, 20 Apr 2017 19:32:16 -0000 On Thursday 20 April 2017 12:54 PM, 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 Thanks, verified it for regression seen on current master for mentioned scenario. Regards, Gowrishankar > --- > 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; > + } > } > } >