From patchwork Wed Jun 26 15:12:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 167837 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1073397ilk; Wed, 26 Jun 2019 08:14:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFX9gQBYYc7TX45VR+RDnAFTdDftre8A/iuHe77rs3VNltyAPCCe5nqRVIm/PbinMx4U2t X-Received: by 2002:a63:461c:: with SMTP id t28mr3503875pga.150.1561562049416; Wed, 26 Jun 2019 08:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561562049; cv=none; d=google.com; s=arc-20160816; b=sXJyaW8R9gt1yDkTFGliYKNe3ojRA3j9mqd/TcmYCilCUO32ZhoL5+NVbIOqrqYM25 BiF0XEgLb+jTA8Ig6HBDvO9U3zRTccQpdLHHV/JKPiViVkoSt4lmlnWz/XDba19KNHQG TngxtIF9yVSx2nx4bGUifmMcydcfhkUllpl4WmqS3LtO7qJ7Tk/GNDWVjDMLJLpuGATW lpR2kKGtm1MLs2LEF8nPLuqDjN2NZGLvVPU/JnctInZevPuBqdTbcHItRjZDEt4+c+4l lhSvt1RNQW/9mVh/yYjVjpO+ilibVgsWOi2wf83Aq37YZZjO04BAX0DKkRD4HEAbRhrN gn3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Z9cVj8GabsU/Mxk5ZX3XJd6iX+tTHVUT60WWdrMbjYQ=; b=wAmluCD/swXJNtxAeDl4k2FKNVBj1JjV+Rvm0rdp0TjIbfIc5Fn7k7ZVgu05mvjA5Q goHRpFHyQlJAl8V40ZcfW6H/SQMgTQvijrSqM9Boc4hT5gJYuQu+lr2trWhr9AXRlcyI liBE2xCP1IiFWcvJ1TOO5+dzdK1v9HcR9cWKvWsQFWjNw5rI2Z30mXJQYA5s+/cltW9T 9xOU6Oi9xaOOWrPxU6QDxCAITQbF6yBcseTYII3JeLWilHPy6PpaNsUzp3Trl4huP2Wm Oz734JsxnxWOsaqZ0itYMfaZsxLs9VZy/mdlf9H0pqDM8iCQ4UsJZk15qSuhwUAikyJX 0Mew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w7si15618857pgs.168.2019.06.26.08.14.09; Wed, 26 Jun 2019 08:14:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728452AbfFZPOH (ORCPT + 30 others); Wed, 26 Jun 2019 11:14:07 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:19114 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728430AbfFZPOE (ORCPT ); Wed, 26 Jun 2019 11:14:04 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 7C79BCA769915FB85BF2; Wed, 26 Jun 2019 23:13:57 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.439.0; Wed, 26 Jun 2019 23:13:49 +0800 From: Shameer Kolothum To: , , CC: , , , , , , , Shameer Kolothum Subject: [PATCH v7 6/6] vfio/type1: remove duplicate retrieval of reserved regions Date: Wed, 26 Jun 2019 16:12:48 +0100 Message-ID: <20190626151248.11776-7-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190626151248.11776-1-shameerali.kolothum.thodi@huawei.com> References: <20190626151248.11776-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As we now already have the reserved regions list, just pass that into vfio_iommu_has_sw_msi() fn. Signed-off-by: Shameer Kolothum --- drivers/vfio/vfio_iommu_type1.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) -- 2.17.1 Reviewed-by: Eric Auger diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 450081802dcd..43b1e68ebce9 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -1308,15 +1308,13 @@ static struct vfio_group *find_iommu_group(struct vfio_domain *domain, return NULL; } -static bool vfio_iommu_has_sw_msi(struct iommu_group *group, phys_addr_t *base) +static bool vfio_iommu_has_sw_msi(struct list_head *group_resv_regions, + phys_addr_t *base) { - struct list_head group_resv_regions; - struct iommu_resv_region *region, *next; + struct iommu_resv_region *region; bool ret = false; - INIT_LIST_HEAD(&group_resv_regions); - iommu_get_group_resv_regions(group, &group_resv_regions); - list_for_each_entry(region, &group_resv_regions, list) { + list_for_each_entry(region, group_resv_regions, list) { /* * The presence of any 'real' MSI regions should take * precedence over the software-managed one if the @@ -1332,8 +1330,7 @@ static bool vfio_iommu_has_sw_msi(struct iommu_group *group, phys_addr_t *base) ret = true; } } - list_for_each_entry_safe(region, next, &group_resv_regions, list) - kfree(region); + return ret; } @@ -1774,7 +1771,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, if (ret) goto out_detach; - resv_msi = vfio_iommu_has_sw_msi(iommu_group, &resv_msi_base); + resv_msi = vfio_iommu_has_sw_msi(&group_resv_regions, &resv_msi_base); INIT_LIST_HEAD(&domain->group_list); list_add(&group->next, &domain->group_list);