qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@redhat.com>
To: "Duan, Zhenzhong" <zhenzhong.duan@intel.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "alex.williamson@redhat.com" <alex.williamson@redhat.com>,
	"eric.auger@redhat.com" <eric.auger@redhat.com>,
	"peterx@redhat.com" <peterx@redhat.com>,
	"jasowang@redhat.com" <jasowang@redhat.com>,
	"mst@redhat.com" <mst@redhat.com>,
	"jgg@nvidia.com" <jgg@nvidia.com>,
	"nicolinc@nvidia.com" <nicolinc@nvidia.com>,
	"joao.m.martins@oracle.com" <joao.m.martins@oracle.com>,
	"Tian, Kevin" <kevin.tian@intel.com>,
	"Liu, Yi L" <yi.l.liu@intel.com>,
	"Peng, Chao P" <chao.p.peng@intel.com>
Subject: Re: [PATCH v2 02/10] vfio: Introduce HIODLegacyVFIO device
Date: Tue, 16 Apr 2024 15:53:35 +0200	[thread overview]
Message-ID: <a46d4d57-0d6c-4ba3-887b-bc167a25434a@redhat.com> (raw)
In-Reply-To: <SJ0PR11MB67448DE106AEE894D080D3F492082@SJ0PR11MB6744.namprd11.prod.outlook.com>

Hello,

On 4/16/24 05:41, Duan, Zhenzhong wrote:
> Hi Cédric,
> 
>> -----Original Message-----
>> From: Cédric Le Goater <clg@redhat.com>
>> Subject: Re: [PATCH v2 02/10] vfio: Introduce HIODLegacyVFIO device
>>
>> On 4/8/24 10:12, Zhenzhong Duan wrote:
>>> HIODLegacyVFIO represents a host IOMMU device under VFIO legacy
>>> container backend.
>>>
>>> It includes a link to VFIODevice.
>>>
>>> Suggested-by: Eric Auger <eric.auger@redhat.com>
>>> Suggested-by: Cédric Le Goater <clg@redhat.com>
>>> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
>>> ---
>>>    include/hw/vfio/vfio-common.h | 11 +++++++++++
>>>    hw/vfio/container.c           | 11 ++++++++++-
>>>    2 files changed, 21 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-
>> common.h
>>> index b9da6c08ef..f30772f534 100644
>>> --- a/include/hw/vfio/vfio-common.h
>>> +++ b/include/hw/vfio/vfio-common.h
>>> @@ -31,6 +31,7 @@
>>>    #endif
>>>    #include "sysemu/sysemu.h"
>>>    #include "hw/vfio/vfio-container-base.h"
>>> +#include "sysemu/host_iommu_device.h"
>>>
>>>    #define VFIO_MSG_PREFIX "vfio %s: "
>>>
>>> @@ -147,6 +148,16 @@ typedef struct VFIOGroup {
>>>        bool ram_block_discard_allowed;
>>>    } VFIOGroup;
>>>
>>> +#define TYPE_HIOD_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy-
>> vfio"
>>
>> I would prefer to keep the prefix TYPE_HOST_IOMMU_DEVICE.
> 
> Will do.
> 
>>
>>> +OBJECT_DECLARE_SIMPLE_TYPE(HIODLegacyVFIO, HIOD_LEGACY_VFIO)
>>> +
>>> +/* Abstraction of VFIO legacy host IOMMU device */
>>> +struct HIODLegacyVFIO {
>>
>> same here
> 
> Should I do the same for all the HostIOMMUDevice and HostIOMMUDeviceClass sub-structures?

I would for type names. The main reason is for naming consistency, which is
useful for grep and code analysis.

> 
> The reason I used 'HIOD' abbreviation is some function names become extremely long
> and exceed 80 characters. E.g.:
> 
> @@ -1148,9 +1148,9 @@ static void vfio_iommu_legacy_class_init(ObjectClass *klass, void *data)
>       vioc->pci_hot_reset = vfio_legacy_pci_hot_reset;
>   };
> 
> -static int hiod_legacy_vfio_get_host_iommu_info(HostIOMMUDevice *hiod,
> -                                                void *data, uint32_t len,
> -                                                Error **errp)
> +static int host_iommu_device_legacy_vfio_get_host_iommu_info(HostIOMMUDevice *hiod,
> +                                                             void *data, uint32_t len,
> +                                                             Error **errp)
>   {
>       VFIODevice *vbasedev = HIOD_LEGACY_VFIO(hiod)->vdev;
>       /* iova_ranges is a sorted list */
> @@ -1173,7 +1173,7 @@ static void hiod_legacy_vfio_class_init(ObjectClass *oc, void *data)
>   {
>       HostIOMMUDeviceClass *hioc = HOST_IOMMU_DEVICE_CLASS(oc);
> 
> -    hioc->get_host_iommu_info = hiod_legacy_vfio_get_host_iommu_info;
> +    hioc->get_host_iommu_info = host_iommu_device_legacy_vfio_get_host_iommu_info;
>   };
> 
> I didn't find other way to make it meet the 80 chars limitation. Any suggestions on this?

Try :

@@ -1177,7 +1177,8 @@ static void hiod_legacy_vfio_class_init(
  {
      HostIOMMUDeviceClass *hioc = HOST_IOMMU_DEVICE_CLASS(oc);
  
-    hioc->get_host_iommu_info = hiod_legacy_vfio_get_host_iommu_info;
+    hioc->get_host_iommu_info =
+        host_iommu_device_legacy_vfio_get_host_iommu_info;
  };
  
  static const TypeInfo types[] = {

That said, I agree that 'host_iommu_device_legacy_vfio' routine prefix
could be shortened to 'hiod_legacy_vfio'.


Thanks,

C.



> 
>>
>>> +    /*< private >*/
>>> +    HostIOMMUDevice parent;
>>> +    VFIODevice *vdev;
>>
>> It seems to me that the back pointer should be on the container instead.
>> Looks more correct conceptually.
> 
> Yes, that makes sense for legacy VFIO, as iova_ranges, pgsizes etc are all saved in bcontainer.
> 
>>
>>
>>> +};
>>> +
>>>    typedef struct VFIODMABuf {
>>>        QemuDmaBuf buf;
>>>        uint32_t pos_x, pos_y, pos_updates;
>>> diff --git a/hw/vfio/container.c b/hw/vfio/container.c
>>> index 77bdec276e..44018ef085 100644
>>> --- a/hw/vfio/container.c
>>> +++ b/hw/vfio/container.c
>>> @@ -1143,12 +1143,21 @@ static void
>> vfio_iommu_legacy_class_init(ObjectClass *klass, void *data)
>>>        vioc->pci_hot_reset = vfio_legacy_pci_hot_reset;
>>>    };
>>>
>>> +static void hiod_legacy_vfio_class_init(ObjectClass *oc, void *data)
>>> +{
>>> +};
>>
>> Is it preferable to introduce routines when they are actually useful.
>> Please drop the .class_init definition.
> 
> Sure.
> 
> Thanks
> Zhenzhong
> 
>>
>> Thanks,
>>
>> C.
>>
>>
>>> +
>>>    static const TypeInfo types[] = {
>>>        {
>>>            .name = TYPE_VFIO_IOMMU_LEGACY,
>>>            .parent = TYPE_VFIO_IOMMU,
>>>            .class_init = vfio_iommu_legacy_class_init,
>>> -    },
>>> +    }, {
>>> +        .name = TYPE_HIOD_LEGACY_VFIO,
>>> +        .parent = TYPE_HOST_IOMMU_DEVICE,
>>> +        .instance_size = sizeof(HIODLegacyVFIO),
>>> +        .class_init = hiod_legacy_vfio_class_init,
>>> +    }
>>>    };
>>>
>>>    DEFINE_TYPES(types)
> 



  reply	other threads:[~2024-04-16 13:57 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08  8:12 [PATCH v2 00/10] Add a host IOMMU device abstraction Zhenzhong Duan
2024-04-08  8:12 ` [PATCH v2 01/10] backends: Introduce abstract HostIOMMUDevice Zhenzhong Duan
2024-04-15  8:09   ` Cédric Le Goater
2024-04-15  9:57     ` Duan, Zhenzhong
2024-04-15  9:18   ` Philippe Mathieu-Daudé
2024-04-15  9:58     ` Duan, Zhenzhong
2024-04-08  8:12 ` [PATCH v2 02/10] vfio: Introduce HIODLegacyVFIO device Zhenzhong Duan
2024-04-15  9:19   ` Philippe Mathieu-Daudé
2024-04-15 10:10     ` Duan, Zhenzhong
2024-04-15 11:12       ` Philippe Mathieu-Daudé
2024-04-15 12:12         ` Duan, Zhenzhong
2024-04-15 12:47   ` Cédric Le Goater
2024-04-16  3:41     ` Duan, Zhenzhong
2024-04-16 13:53       ` Cédric Le Goater [this message]
2024-04-17  4:22         ` Duan, Zhenzhong
2024-04-08  8:12 ` [PATCH v2 03/10] backends/iommufd: Introduce abstract HIODIOMMUFD device Zhenzhong Duan
2024-04-09  3:41   ` Duan, Zhenzhong
2024-04-15 13:07   ` Cédric Le Goater
2024-04-16  4:09     ` Duan, Zhenzhong
2024-04-08  8:12 ` [PATCH v2 04/10] vfio/iommufd: Introduce HIODIOMMUFDVFIO device Zhenzhong Duan
2024-04-08  8:12 ` [PATCH v2 05/10] vfio: Implement get_host_iommu_info() callback Zhenzhong Duan
2024-04-15 13:15   ` Cédric Le Goater
2024-04-16  5:58     ` Duan, Zhenzhong
2024-04-08  8:12 ` [PATCH v2 06/10] backends/iommufd: Introduce helper function iommufd_backend_get_device_info() Zhenzhong Duan
2024-04-15 13:22   ` Cédric Le Goater
2024-04-16  6:07     ` Duan, Zhenzhong
2024-04-08  8:12 ` [PATCH v2 07/10] backends/iommufd: Implement get_host_iommu_info() callback Zhenzhong Duan
2024-04-15 13:23   ` Cédric Le Goater
2024-04-16  6:10     ` Duan, Zhenzhong
2024-04-08  8:12 ` [PATCH v2 08/10] vfio: Create host IOMMU device instance Zhenzhong Duan
2024-04-15 13:25   ` Cédric Le Goater
2024-04-16  6:11     ` Duan, Zhenzhong
2024-04-08  8:12 ` [PATCH v2 09/10] hw/pci: Introduce pci_device_set/unset_iommu_device() Zhenzhong Duan
2024-04-15 13:34   ` Cédric Le Goater
2024-04-16  6:11     ` Duan, Zhenzhong
2024-04-08  8:12 ` [PATCH v2 10/10] vfio: Pass HostIOMMUDevice to vIOMMU Zhenzhong Duan
2024-04-15 13:37   ` Cédric Le Goater

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a46d4d57-0d6c-4ba3-887b-bc167a25434a@redhat.com \
    --to=clg@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=chao.p.peng@intel.com \
    --cc=eric.auger@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=joao.m.martins@oracle.com \
    --cc=kevin.tian@intel.com \
    --cc=mst@redhat.com \
    --cc=nicolinc@nvidia.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yi.l.liu@intel.com \
    --cc=zhenzhong.duan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).