Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp929999ybd; Wed, 26 Jun 2019 08:16:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqysaN8ugJ1ZlQHo3s23Pao5t7YVDfjgFiUevhqjMt5CdkCBhJ5pGliHp0hzI50MQPx0ZTVD X-Received: by 2002:a17:902:ba8e:: with SMTP id k14mr6080754pls.256.1561562183878; Wed, 26 Jun 2019 08:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561562183; cv=none; d=google.com; s=arc-20160816; b=p3cv82hz9SkxrYDYxwdW6QfeQ2LJAp/prgIh3ioIbFDTvNQH89YjVRmme4hFWNY13L RUJ34Mp5KXnhXzfzlHOWbNWnvXdnKII261mTjNmoJEO7iPxZnK3AhdAeHnZiY2ZK/zye MuWQnOGBuoB0VpIcEIc26oNidCgFEEEov4MOirCdORXVBtLcYxXKDQ5qBbSMamuabozq P5ohOr/j88VSBHYCZqaJijlnSxGm6nBQtgZRVgZVFhR1vEeFhzzABm5cnZ8/1cjaiIjA rnMmnGNg6eyuRVTcr3APXKwNdnBPsSGcTbeXDmV4SToQPl7opjI/jLZ9Mpx+Y7MqSFZK iClQ== 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 j1si17671429pfr.52.2019.06.26.08.16.07; Wed, 26 Jun 2019 08:16:23 -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 S1728447AbfFZPOH (ORCPT + 99 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 Content-Type: text/plain 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(-) 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); -- 2.17.1