diff mbox series

[v7,6/6] vfio/type1: remove duplicate retrieval of reserved regions

Message ID 20190626151248.11776-7-shameerali.kolothum.thodi@huawei.com
State Superseded
Headers show
Series vfio/type1: Add support for valid iova list management | expand

Commit Message

Shameerali Kolothum Thodi June 26, 2019, 3:12 p.m. UTC
As we now already have the reserved regions list, just pass that into
vfio_iommu_has_sw_msi() fn.

Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>

---
 drivers/vfio/vfio_iommu_type1.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

-- 
2.17.1

Comments

Eric Auger July 7, 2019, 3:03 p.m. UTC | #1
Hi Shameer,
On 6/26/19 5:12 PM, Shameer Kolothum wrote:
> As we now already have the reserved regions list, just pass that into

> vfio_iommu_has_sw_msi() fn.

> 

> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>

Reviewed-by: Eric Auger <eric.auger@redhat.com>


Thanks

Eric
> ---

>  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);

>
diff mbox series

Patch

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);