Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp709702pxb; Tue, 3 Nov 2020 10:20:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUVHS4e/1aBdfQ3aMDmfceV914+5AACfJnO3mXA4WOPGWsdLi6aWTqBv4AXQkEg5pHr4Cv X-Received: by 2002:a17:906:c193:: with SMTP id g19mr22211538ejz.393.1604427607563; Tue, 03 Nov 2020 10:20:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604427607; cv=none; d=google.com; s=arc-20160816; b=iSjrnSTY8r1tX9idjP/CFzKOAdCwBCcHyHOwPbuPE2ePUf7+P2zwLXCg5P6pbQjkB7 dzaFrWTPEWq3xruGkqMYe/UBLIwAeoQj0mKJp4QL9sP0qjsQyc437OLJhNe8yC6UZvh6 +NAO1vM+CPpVSjw5HsZJeH+gIKtAkyPHn+5FVvVec22+/ekIQ0rwhU99j4zOX+IYrJct iiAz0+u7PQRhpwJ0j9WXr2y78SOhz4GMuDsPckt3DB41theJ1cv8GtNVmwK24FZZHM6z E1eCrKhvY2IVCu9PDPB1/dlNjQeOsQ+uCrP+Fi55KejzCkuzlqgndlVQVM/Av/Sce2dY mBeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=/BtiNbA7S+imU9r9wm1tSfzmZPhlyYiVJn61vXEcUAk=; b=YVJj8vK/ZWrBVC07YXG+RukU9Ny2F4nwvJoUweh0XCAAlxKEqTthTd2mMtzEeZOtaB AC1OFOqUDIHVDzVyHzwNfwTar1Xe7nqfksMaBAPQssmGIhzfRzbBsHFBWchMGXiVWP1d V5gY0IxLiZ/rfO58beu730HVwMWyocn64llBRBm5YBXcXJH0e04ST2/pXehEPRdQrNah n7zs+NsBXdOh0JKoQnj8/V8UQcZhWplmGsaGXgJZksnKNwSQ91fVzXUOY/s31+VvyodQ xJzmWfeHSQZsd8yr3Qrn3dYRT6niBR3xREzO2w3jynVBVFvnh8lpwZC57BDBIm1hNHOY eKLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fBiyyO+q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a25si3347938edx.171.2020.11.03.10.19.44; Tue, 03 Nov 2020 10:20:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fBiyyO+q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728969AbgKCSSH (ORCPT + 99 others); Tue, 3 Nov 2020 13:18:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:30658 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728312AbgKCSSH (ORCPT ); Tue, 3 Nov 2020 13:18:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604427485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/BtiNbA7S+imU9r9wm1tSfzmZPhlyYiVJn61vXEcUAk=; b=fBiyyO+qfjT8aqNZGL1oCtJTwjCmgeAldb+TDVIPpRUa0aid0iEvfRSdG+93EE/odJ9JZS UTmqH1Xz68ToDyQLT9tTPR1TZibWCxbuw1LiotA8221dGqrQWLVNxlZYHeM/qXERSECuBF yGhitdOXWII6rFRpiFDwPhLuGjWBw64= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-530-FGuLZy7WN2CZnQz0TuOyWw-1; Tue, 03 Nov 2020 13:18:04 -0500 X-MC-Unique: FGuLZy7WN2CZnQz0TuOyWw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B42231868412; Tue, 3 Nov 2020 18:18:02 +0000 (UTC) Received: from w520.home (ovpn-112-213.phx2.redhat.com [10.3.112.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60B3110013C1; Tue, 3 Nov 2020 18:18:02 +0000 (UTC) Date: Tue, 3 Nov 2020 11:18:01 -0700 From: Alex Williamson To: Zenghui Yu Cc: , , , Subject: Re: [PATCH] vfio/type1: Use the new helper to find vfio_group Message-ID: <20201103111801.05d4cee5@w520.home> In-Reply-To: <20201022122417.245-1-yuzenghui@huawei.com> References: <20201022122417.245-1-yuzenghui@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 22 Oct 2020 20:24:17 +0800 Zenghui Yu wrote: > When attaching a new group to the container, let's use the new helper > vfio_iommu_find_iommu_group() to check if it's already attached. There > is no functional change. > > Also take this chance to add a missing blank line. > > Signed-off-by: Zenghui Yu > --- > drivers/vfio/vfio_iommu_type1.c | 17 +++++------------ > 1 file changed, 5 insertions(+), 12 deletions(-) Applied to vfio for-linus branch for v5.10. Thanks, Alex > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > index a05d856ae806..aa586bd684da 100644 > --- a/drivers/vfio/vfio_iommu_type1.c > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -1997,6 +1997,7 @@ static void vfio_iommu_iova_insert_copy(struct vfio_iommu *iommu, > > list_splice_tail(iova_copy, iova); > } > + > static int vfio_iommu_type1_attach_group(void *iommu_data, > struct iommu_group *iommu_group) > { > @@ -2013,18 +2014,10 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, > > mutex_lock(&iommu->lock); > > - list_for_each_entry(d, &iommu->domain_list, next) { > - if (find_iommu_group(d, iommu_group)) { > - mutex_unlock(&iommu->lock); > - return -EINVAL; > - } > - } > - > - if (iommu->external_domain) { > - if (find_iommu_group(iommu->external_domain, iommu_group)) { > - mutex_unlock(&iommu->lock); > - return -EINVAL; > - } > + /* Check for duplicates */ > + if (vfio_iommu_find_iommu_group(iommu, iommu_group)) { > + mutex_unlock(&iommu->lock); > + return -EINVAL; > } > > group = kzalloc(sizeof(*group), GFP_KERNEL);