From patchwork Thu Mar 15 16:35:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 131819 Delivered-To: patch@linaro.org Received: by 10.80.210.197 with SMTP id q5csp1697897edg; Thu, 15 Mar 2018 09:38:36 -0700 (PDT) X-Google-Smtp-Source: AG47ELuzk6e5rR4h5YkzuMa2CbD1xuqvH+vw/F3BP2u2mqfhVCx85MKrg6dNK3f3Mn+7vGvXQb1c X-Received: by 10.99.127.27 with SMTP id a27mr7104354pgd.18.1521131916644; Thu, 15 Mar 2018 09:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521131916; cv=none; d=google.com; s=arc-20160816; b=LRTb1CyXACBmBzNeeI7ByNGNAP1YAa0hZX1zCMi+6K/hGKoeNghfshgWQ9J6stop+2 heL1T6TOqB2mE1kr4Vb/ku0cetXGJlutoL+thEZNh/1a1mU1KK43X94RGxjFBIdTmZV5 dJ7BaPb4fuH5MdcctmzitNqhkeOu8yfh4HKdot9IS/ZOaB6neW9sGyb1f5O8X4xeZiIJ pPb5GHs6mK7ittcqv5WAn+MDEZjc5VmtDjm41meWWXKIT6LxuStUHAghQfMvrND0anK6 HYcZ9rKIAh1cS95ETZOfRpG9yPg+uKXWLKQOXw9Rvosw8kxTfex3PQ11K90KSlca/vf7 nt9Q== 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:arc-authentication-results; bh=8qYA8102MR1n5XzIH3SBzoouueIW1D3HmR00QjMzMgI=; b=fgPghsfHa/1VIXQaJ/YJ/sAB4vDaU4IKYxH71++xj3HgWJ67QYOBvGRk7YqghGyzaj 1Guz33RM/6xyN9NZeZ12RGG89tTjMpMPz/jzK0grvEojXprRQms8Ey4hIv6JaIC7YJ1i UiuB/TJeoavGh52L9WcBi4RoCRgC9RvKSYLCHaiHhVZQn3KPLQIHvdQ+Gl/RCPg2nQlB CE5gZfSD2BxhdShEuxBC//QvvLOE5/+5KdnOPevxMmL0HFJTXwkZnJKl0tOy3/H31bEZ LyMUSXjm/c2IaN300G3jISdP0StVWqSUAKH+A8veP2KH/MHYADrOSWYok67mCvrhq9jF W2dA== 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 x3-v6si4323415plv.81.2018.03.15.09.38.36; Thu, 15 Mar 2018 09:38:36 -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 S1752402AbeCOQi1 (ORCPT + 28 others); Thu, 15 Mar 2018 12:38:27 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:39780 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751829AbeCOQiX (ORCPT ); Thu, 15 Mar 2018 12:38:23 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 8DD0AB058D20B; Fri, 16 Mar 2018 00:38:09 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.361.1; Fri, 16 Mar 2018 00:38:00 +0800 From: Shameer Kolothum To: , , CC: , , , , , , Shameer Kolothum Subject: [PATCH v5 6/7] vfio/type1: remove duplicate retrieval of reserved regions Date: Thu, 15 Mar 2018 16:35:08 +0000 Message-ID: <20180315163509.17740-7-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20180315163509.17740-1-shameerali.kolothum.thodi@huawei.com> References: <20180315163509.17740-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.7.4 diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 90f195d..65c13e7 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -1204,15 +1204,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 @@ -1228,8 +1226,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; } @@ -1564,7 +1561,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);