From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51143) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4jnN-0007iL-OG for qemu-devel@nongnu.org; Thu, 10 Nov 2016 02:29:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4jnK-0000mj-KP for qemu-devel@nongnu.org; Thu, 10 Nov 2016 02:29:13 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:43974 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c4jnK-0000mI-F8 for qemu-devel@nongnu.org; Thu, 10 Nov 2016 02:29:10 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uAA7OqQ2117355 for ; Thu, 10 Nov 2016 02:29:09 -0500 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 26mk9ub887-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 10 Nov 2016 02:29:09 -0500 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Nov 2016 00:29:08 -0700 Date: Thu, 10 Nov 2016 15:29:03 +0800 From: Dong Jia Shi References: <1478293856-8191-1-git-send-email-kwankhede@nvidia.com> <1478293856-8191-9-git-send-email-kwankhede@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1478293856-8191-9-git-send-email-kwankhede@nvidia.com> Message-Id: <20161110072903.GE4716@bjsdjshi@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v11 08/22] vfio iommu type1: Add find_iommu_group() function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kirti Wankhede Cc: alex.williamson@redhat.com, pbonzini@redhat.com, kraxel@redhat.com, cjia@nvidia.com, qemu-devel@nongnu.org, kvm@vger.kernel.org, kevin.tian@intel.com, jike.song@intel.com, bjsdjshi@linux.vnet.ibm.com, linux-kernel@vger.kernel.org * Kirti Wankhede [2016-11-05 02:40:42 +0530]: Hi Kirti, > Add find_iommu_group() > > Signed-off-by: Kirti Wankhede > Signed-off-by: Neo Jia > Change-Id: I9d372f1ebe9eb01a5a21374b8a2b03f7df73601f > --- > drivers/vfio/vfio_iommu_type1.c | 58 ++++++++++++++++++++++++----------------- > 1 file changed, 34 insertions(+), 24 deletions(-) > > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > index 653386e80e85..422c8d198abb 100644 > --- a/drivers/vfio/vfio_iommu_type1.c > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -748,11 +748,24 @@ static void vfio_test_domain_fgsp(struct vfio_domain *domain) > __free_pages(pages, order); > } > > +static struct vfio_group *find_iommu_group(struct vfio_domain *domain, > + struct iommu_group *iommu_group) nit: broken indentation. > +{ > + struct vfio_group *g; > + > + list_for_each_entry(g, &domain->group_list, next) { > + if (g->iommu_group == iommu_group) > + return g; > + } > + > + return NULL; > +} > + > static int vfio_iommu_type1_attach_group(void *iommu_data, > struct iommu_group *iommu_group) > { > struct vfio_iommu *iommu = iommu_data; > - struct vfio_group *group, *g; > + struct vfio_group *group; > struct vfio_domain *domain, *d; > struct bus_type *bus = NULL; > int ret; > @@ -760,10 +773,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, > mutex_lock(&iommu->lock); > > list_for_each_entry(d, &iommu->domain_list, next) { > - list_for_each_entry(g, &d->group_list, next) { > - if (g->iommu_group != iommu_group) > - continue; > - > + if (find_iommu_group(d, iommu_group)) { > mutex_unlock(&iommu->lock); > return -EINVAL; > } > @@ -882,28 +892,28 @@ static void vfio_iommu_type1_detach_group(void *iommu_data, > > mutex_lock(&iommu->lock); > > + nit: empty line. > list_for_each_entry(domain, &iommu->domain_list, next) { > - list_for_each_entry(group, &domain->group_list, next) { > - if (group->iommu_group != iommu_group) > - continue; > + group = find_iommu_group(domain, iommu_group); > + if (!group) > + continue; [...] Looks good to me! -- Dong Jia