From patchwork Thu Feb 15 09:45:04 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: 128397 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1557689ljc; Thu, 15 Feb 2018 01:47:39 -0800 (PST) X-Google-Smtp-Source: AH8x224Bq6I2yMCSRK+lHN2Ctt+wziHko9qylZS5KT63H9be58ymNEkcscW5aUKX64aZXIE2f7Eh X-Received: by 2002:a17:902:f81:: with SMTP id 1-v6mr1928607plz.265.1518688059615; Thu, 15 Feb 2018 01:47:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518688059; cv=none; d=google.com; s=arc-20160816; b=mKPnMlanbXph1goyxBC9Lf38S5gj21o5oonu30RGyO/+Ey9lQBBVRFJKFwa2NBi7ba hEtVkEFAeqoFf3xa7kO7TKs8kfVkCvcj7MgN2vWwmJVnd0uRtteB12Q1QHzJoupInfls R3ceLhodiHu+Hr8Yv1KlaRMZvM1hjkTPTO+ZQG3uPf4JJ6hktEUQDoLslxWyrhzTR6wR 1pPPVG+0wIN8AyoyiEPsZY5Pe3a0ewyDA8YTXHpJ95jM1GzsYnBu3hSe+iSRowrs2typ IMb4u6myaNydgii/fMxxOh291TKUMSS5YLIu2J5CGL4zOOK21+XsZ6s4iMtxIvb+0f9i mY7Q== 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=rFb2lZ642Ev7TVhHiAiBfpH5yPhYgpfcXgyarl/O550=; b=PWyvoP5nSygoRMxLznF0rx+SYpSZ3txu2iktqCj4X/sjfa5lsO7ZGdXOOi3nGK/ugq 0EImXZQ8OmMW7nTxoOouMvDm+meYUVdTI2t/Fz+xcQZj5/7wzIFPHEMKCvB2xyAh/Twh 6Dnt5Jq8n59B9xJqblErF5jjNaL0/xWApPB0TaVp59oC0ZmlVzgh2g/xQghYm5tXTum6 8GUh3r4fK4pl8ebunoNhz+UTXRoZqE9Xd7HFHFFXY/SEUcnZdfB16/CwCtkmeP1TsyFI JQ4tNNzhfLV8nCPgxElGjSxezzzlWoVKaCzi9K2DqldTYg+KpmcQYs4Q906ymesivRIy kt+A== 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 30-v6si1352272pla.812.2018.02.15.01.47.39; Thu, 15 Feb 2018 01:47:39 -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 S967873AbeBOJrf (ORCPT + 28 others); Thu, 15 Feb 2018 04:47:35 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:59985 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S966863AbeBOJra (ORCPT ); Thu, 15 Feb 2018 04:47:30 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D99188083FC8F; Thu, 15 Feb 2018 17:47:17 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.361.1; Thu, 15 Feb 2018 17:47:10 +0800 From: Shameer Kolothum To: , , CC: , , , , , Shameer Kolothum Subject: [PATCH v3 6/6] vfio/type1: remove duplicate retrieval of reserved regions. Date: Thu, 15 Feb 2018 09:45:04 +0000 Message-ID: <20180215094504.4972-7-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20180215094504.4972-1-shameerali.kolothum.thodi@huawei.com> References: <20180215094504.4972-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 21e575c..ff9818b 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; } @@ -1538,7 +1535,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);