From patchwork Tue Jul 23 16:06:37 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: 169551 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp9072523ilk; Tue, 23 Jul 2019 09:09:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGr4e/wRaZ3XnMv4Y/eTTdnqOoUYUw3Jy9YDbah0o3gSyxCDtfCQngcVxIC6KTF+BxUTZj X-Received: by 2002:a17:902:2ae7:: with SMTP id j94mr81250314plb.270.1563898146596; Tue, 23 Jul 2019 09:09:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563898146; cv=none; d=google.com; s=arc-20160816; b=BbtayW+mXWrpinLDJHA1ZPg7uglCXrW8NnszLD0r8frwUd87VwRd6V1sPQE/mNVmtB 6M6rAFKbGC42sUAQzNdp+LbbAyoUUJ1AMYw110LPP4OZaTDJh5EW94NY5+qKnT0Sjmsb b1zKycIaS0K20cQ7HzMgWuELbaQ8UxPJzDoNSTxlX/Ng8YplF3Phziattkxp1SVAonUA tUKoxJVOuZE88P8ydIVaNR4EzveuRz1dJs/NmINKJWRDlJY/J1mQPKjC/08vpfXQA5O3 fzglf5/FR6EWoed/abOZUBdHjRTN750l9pGkzlE+kwi8xU39SIV9JP+MMFivbkpnzDLK xzvQ== 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=qH6Nd9bqJtiZYL/nDEGvzAicp+D2R74jEO7uQq5DwIo=; b=tVIytvGR3eSUv5nrG7JH6NvVpmAiMpqglK+qePDKTe66URm4nRNe5UNcWmMAQMlVyp fFCZwXgidOMWgbsG9bCCpblKMyeFD0c5DXPCdAKkDC5cRaKnMDFDgdeFScpb6wKIKNBc sNLbKvjRsNhoSvRQ4xyKxflesU6+XbFEirYYosjPQa/Bmfx7jWb1Hugqxj5QVuehcLXs vZOEQd8qO0eb90RJ97ny5rnnM5dx176zJaNa7k3LeIUbMEH6B3sKn2U1V3xQBm7lfNuc LmJptOUJslIXTbOlKnrZMqnMStVxTOF8+hAYfGUkyYNFxBivjlW6eNCX8CtV4NhtRFGK bKmg== 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 k15si16989285pgj.216.2019.07.23.09.09.06; Tue, 23 Jul 2019 09:09:06 -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 S2390800AbfGWQJF (ORCPT + 29 others); Tue, 23 Jul 2019 12:09:05 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:48070 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388931AbfGWQJE (ORCPT ); Tue, 23 Jul 2019 12:09:04 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 4F2D251B1C3190D8618A; Wed, 24 Jul 2019 00:08:44 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Wed, 24 Jul 2019 00:08:34 +0800 From: Shameer Kolothum To: , CC: , , , , , , , Shameer Kolothum Subject: [PATCH v8 6/6] vfio/type1: remove duplicate retrieval of reserved regions Date: Tue, 23 Jul 2019 17:06:37 +0100 Message-ID: <20190723160637.8384-7-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190723160637.8384-1-shameerali.kolothum.thodi@huawei.com> References: <20190723160637.8384-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 Reviewed-by: Eric Auger --- drivers/vfio/vfio_iommu_type1.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index d0c5e768acb7..a68405f24fbf 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -1296,15 +1296,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 @@ -1320,8 +1318,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; } @@ -1768,7 +1765,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);