From patchwork Wed Feb 21 12:22:09 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: 129055 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp561478ljc; Wed, 21 Feb 2018 04:23:52 -0800 (PST) X-Google-Smtp-Source: AH8x227p9aovLT8DjRGNNl1cbmFL15oH4ANIAXVhSbkzuz3pLFyyS8RXvTEvMRCEXixCMlYrd8U6 X-Received: by 10.99.45.195 with SMTP id t186mr2622719pgt.127.1519215832027; Wed, 21 Feb 2018 04:23:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519215832; cv=none; d=google.com; s=arc-20160816; b=NCNOgW9/UYUwCeDTC79kuaGc1TN9mKtWgH60ETY+8m6Wz0H+jauo3khBtjZCinXthM IJJAo+jYtXRN5rLaSs3JBLRPJ7yfAPODrpbD18pvFQ7Tj+R9fBZCkjiCnYfo//b5BFY2 8dGdYZOeRtEQDN7vhm9wznHyVd13vE2sSDk/A1AVz38kaFqQfRdxx6WmRVEktF2fAUtk xPkzyL1DX5pbi/Yk+UwNdQP1I8FiOvTpQecKG5xHy5nO3CHhTmKWmRJPS8xpSio+M2Rc PWEkt7KMVoPXeBH7S+Kr1m9NBJJ3jGU515kXxhOaIqxIK1tEm17na9lHJ7NMlGpHBEZM 4PlQ== 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=OrIfLE02AOc44nARBLwJJwAp5/aObvd7TaWoLWlztLE=; b=jTf6dEtYVwFYMy3ta86w94ytnoiyJ9pp6f87x6C1V4pIwtHakISIfHk+eGWNlw8Jcr hnWiqQxN0RMfF7NfWwITqIcIlY4Z5dh1HoiHjP5oqoZCfQt45shldk0tlQkpEt1WQ4bO ib7VI1B0nk1NESJ5ZS0MfoIx6REmc0WQ9CTpLumKxDFCPTKYbb3jshNH+KLwdGE9n5VC WFS9Swed0qhFkVvziBJYzcV/yq+aJPzWDsZFtCVsnJIKnmqagZ+TatEHjnQR5da/OQlq itQtNNSKl6ucJ3QabHK6k+OrJGtpjz9Uc++VwIYJwutDSxSJOM+roipS1x8I6h4sgQuM sMFg== 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 s196si376254pgc.129.2018.02.21.04.23.51; Wed, 21 Feb 2018 04:23:52 -0800 (PST) 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 S1754180AbeBUMXs (ORCPT + 28 others); Wed, 21 Feb 2018 07:23:48 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:49322 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754092AbeBUMXj (ORCPT ); Wed, 21 Feb 2018 07:23:39 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2E54078A571A2; Wed, 21 Feb 2018 20:23:31 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.361.1; Wed, 21 Feb 2018 20:23:25 +0800 From: Shameer Kolothum To: , , CC: , , , , , Shameer Kolothum Subject: [PATCH v4 6/6] vfio/type1: remove duplicate retrieval of reserved regions. Date: Wed, 21 Feb 2018 12:22:09 +0000 Message-ID: <20180221122209.9292-7-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20180221122209.9292-1-shameerali.kolothum.thodi@huawei.com> References: <20180221122209.9292-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 c08adb5..56f68b1 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -1192,15 +1192,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 @@ -1216,8 +1214,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; } @@ -1552,7 +1549,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);