[PATCH v1 14/22] vfio/common: Simplify vfio_viommu_preset()

Zhenzhong Duan posted 22 patches 2 years, 5 months ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Yi Liu <yi.l.liu@intel.com>, Eric Auger <eric.auger@redhat.com>, Alex Williamson <alex.williamson@redhat.com>, "Cédric Le Goater" <clg@redhat.com>, Tony Krowiak <akrowiak@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Jason Herne <jjherne@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, Eric Farman <farman@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, David Gibson <david@gibson.dropbear.id.au>, Greg Kurz <groug@kaod.org>, Harsh Prateek Bora <harshpb@linux.ibm.com>, "Michael S. Tsirkin" <mst@redhat.com>, Cornelia Huck <cohuck@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Eduardo Habkost <eduardo@habkost.net>
There is a newer version of this series
[PATCH v1 14/22] vfio/common: Simplify vfio_viommu_preset()
Posted by Zhenzhong Duan 2 years, 5 months ago
Commit "vfio/container-base: Introduce [attach/detach]_device container callbacks"
add support to link to address space, we can utilize it to simplify
vfio_viommu_preset().

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
 hw/vfio/common.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 86b6af5740..6c3e98d5fd 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -165,22 +165,7 @@ void vfio_unblock_multiple_devices_migration(void)
 
 bool vfio_viommu_preset(VFIODevice *vbasedev)
 {
-    VFIOAddressSpace *space;
-    VFIOContainer *container;
-    VFIODevice *tmp_dev;
-
-    QLIST_FOREACH(space, &vfio_address_spaces, list) {
-        QLIST_FOREACH(container, &space->containers, next) {
-            tmp_dev = NULL;
-            while ((tmp_dev = vfio_container_dev_iter_next(container,
-                                                           tmp_dev))) {
-                if (vbasedev == tmp_dev) {
-                    return space->as != &address_space_memory;
-                }
-            }
-        }
-    }
-    g_assert_not_reached();
+    return vbasedev->container->space->as != &address_space_memory;
 }
 
 static void vfio_set_migration_error(int err)
-- 
2.34.1
Re: [PATCH v1 14/22] vfio/common: Simplify vfio_viommu_preset()
Posted by Cédric Le Goater 2 years, 4 months ago
On 8/30/23 12:37, Zhenzhong Duan wrote:
> Commit "vfio/container-base: Introduce [attach/detach]_device container callbacks"
> add support to link to address space, we can utilize it to simplify
> vfio_viommu_preset().
> 
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>

This looks like a revert of patch 07. Can it be avoided in v2 ?

Thanks,

C.

> ---
>   hw/vfio/common.c | 17 +----------------
>   1 file changed, 1 insertion(+), 16 deletions(-)
> 
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 86b6af5740..6c3e98d5fd 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -165,22 +165,7 @@ void vfio_unblock_multiple_devices_migration(void)
>   
>   bool vfio_viommu_preset(VFIODevice *vbasedev)
>   {
> -    VFIOAddressSpace *space;
> -    VFIOContainer *container;
> -    VFIODevice *tmp_dev;
> -
> -    QLIST_FOREACH(space, &vfio_address_spaces, list) {
> -        QLIST_FOREACH(container, &space->containers, next) {
> -            tmp_dev = NULL;
> -            while ((tmp_dev = vfio_container_dev_iter_next(container,
> -                                                           tmp_dev))) {
> -                if (vbasedev == tmp_dev) {
> -                    return space->as != &address_space_memory;
> -                }
> -            }
> -        }
> -    }
> -    g_assert_not_reached();
> +    return vbasedev->container->space->as != &address_space_memory;
>   }
>   
>   static void vfio_set_migration_error(int err)
RE: [PATCH v1 14/22] vfio/common: Simplify vfio_viommu_preset()
Posted by Duan, Zhenzhong 2 years, 4 months ago

>-----Original Message-----
>From: Cédric Le Goater <clg@redhat.com>
>Sent: Wednesday, September 20, 2023 12:01 AM
>Subject: Re: [PATCH v1 14/22] vfio/common: Simplify vfio_viommu_preset()
>
>On 8/30/23 12:37, Zhenzhong Duan wrote:
>> Commit "vfio/container-base: Introduce [attach/detach]_device container
>callbacks"
>> add support to link to address space, we can utilize it to simplify
>> vfio_viommu_preset().
>>
>> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
>
>This looks like a revert of patch 07. Can it be avoided in v2 ?

Yes, I will redesign the related part so that I could have this patch dropped.

Thanks
Zhenzhong