From: "Cédric Le Goater" <clg@redhat.com>
To: Zhenzhong Duan <zhenzhong.duan@intel.com>, qemu-devel@nongnu.org
Cc: alex.williamson@redhat.com, eric.auger@redhat.com,
peterx@redhat.com, jasowang@redhat.com, mst@redhat.com,
jgg@nvidia.com, nicolinc@nvidia.com, joao.m.martins@oracle.com,
kevin.tian@intel.com, yi.l.liu@intel.com, chao.p.peng@intel.com,
Yi Sun <yi.y.sun@linux.intel.com>
Subject: Re: [PATCH v2 03/10] backends/iommufd: Introduce abstract HIODIOMMUFD device
Date: Mon, 15 Apr 2024 15:07:12 +0200 [thread overview]
Message-ID: <b761d626-046a-4032-940a-17d659090c9f@redhat.com> (raw)
In-Reply-To: <20240408081230.1030078-4-zhenzhong.duan@intel.com>
On 4/8/24 10:12, Zhenzhong Duan wrote:
> HIODIOMMUFD represents a host IOMMU device under iommufd backend.
>
> Currently it includes only public iommufd handle and device id.
> which could be used to get hw IOMMU information.
>
> When nested translation is supported in future, vIOMMU is going
> to have iommufd related operations like attaching/detaching hwpt,
> So IOMMUFDDevice interface will be further extended at that time.
>
> VFIO and VDPA device have different way of attaching/detaching hwpt.
> So HIODIOMMUFD is still an abstract class which will be inherited by
> VFIO and VDPA device.
>
> Introduce a helper hiod_iommufd_init() to initialize HIODIOMMUFD
> device.
>
> Suggested-by: Cédric Le Goater <clg@redhat.com>
> Originally-by: Yi Liu <yi.l.liu@intel.com>
> Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> ---
> include/sysemu/iommufd.h | 22 +++++++++++++++++++
> backends/iommufd.c | 47 ++++++++++++++++++++++++++--------------
> 2 files changed, 53 insertions(+), 16 deletions(-)
>
> diff --git a/include/sysemu/iommufd.h b/include/sysemu/iommufd.h
> index 9af27ebd6c..71c53cbb45 100644
> --- a/include/sysemu/iommufd.h
> +++ b/include/sysemu/iommufd.h
> @@ -4,6 +4,7 @@
> #include "qom/object.h"
> #include "exec/hwaddr.h"
> #include "exec/cpu-common.h"
> +#include "sysemu/host_iommu_device.h"
>
> #define TYPE_IOMMUFD_BACKEND "iommufd"
> OBJECT_DECLARE_TYPE(IOMMUFDBackend, IOMMUFDBackendClass, IOMMUFD_BACKEND)
> @@ -33,4 +34,25 @@ int iommufd_backend_map_dma(IOMMUFDBackend *be, uint32_t ioas_id, hwaddr iova,
> ram_addr_t size, void *vaddr, bool readonly);
> int iommufd_backend_unmap_dma(IOMMUFDBackend *be, uint32_t ioas_id,
> hwaddr iova, ram_addr_t size);
> +
> +#define TYPE_HIOD_IOMMUFD TYPE_HOST_IOMMU_DEVICE "-iommufd"
Please keep TYPE_HOST_IOMMU_DEVICE
> +OBJECT_DECLARE_TYPE(HIODIOMMUFD, HIODIOMMUFDClass, HIOD_IOMMUFD)
> +
> +struct HIODIOMMUFD {
> + /*< private >*/
> + HostIOMMUDevice parent;
> + void *opaque;
> +
> + /*< public >*/
> + IOMMUFDBackend *iommufd;
> + uint32_t devid;
> +};
> +
> +struct HIODIOMMUFDClass {
> + /*< private >*/
> + HostIOMMUDeviceClass parent_class;
> +};
This new class doesn't seem useful. Do you have plans for handlers ?
> +
> +void hiod_iommufd_init(HIODIOMMUFD *idev, IOMMUFDBackend *iommufd,
> + uint32_t devid);
> #endif
> diff --git a/backends/iommufd.c b/backends/iommufd.c
> index 62a79fa6b0..ef8b3a808b 100644
> --- a/backends/iommufd.c
> +++ b/backends/iommufd.c
> @@ -212,23 +212,38 @@ int iommufd_backend_unmap_dma(IOMMUFDBackend *be, uint32_t ioas_id,
> return ret;
> }
>
> -static const TypeInfo iommufd_backend_info = {
> - .name = TYPE_IOMMUFD_BACKEND,
> - .parent = TYPE_OBJECT,
> - .instance_size = sizeof(IOMMUFDBackend),
> - .instance_init = iommufd_backend_init,
> - .instance_finalize = iommufd_backend_finalize,
> - .class_size = sizeof(IOMMUFDBackendClass),
> - .class_init = iommufd_backend_class_init,
> - .interfaces = (InterfaceInfo[]) {
> - { TYPE_USER_CREATABLE },
> - { }
> - }
> -};
> +void hiod_iommufd_init(HIODIOMMUFD *idev, IOMMUFDBackend *iommufd,
> + uint32_t devid)
> +{
> + idev->iommufd = iommufd;
> + idev->devid = devid;
> +}
This routine doesn't seem useful. I wonder if we shouldn't introduce
properties. I'm not sure this is useful either.
> -static void register_types(void)
> +static void hiod_iommufd_class_init(ObjectClass *oc, void *data)
> {
> - type_register_static(&iommufd_backend_info);
> }
>
> -type_init(register_types);
> +static const TypeInfo types[] = {
> + {
> + .name = TYPE_IOMMUFD_BACKEND,
> + .parent = TYPE_OBJECT,
> + .instance_size = sizeof(IOMMUFDBackend),
> + .instance_init = iommufd_backend_init,
> + .instance_finalize = iommufd_backend_finalize,
> + .class_size = sizeof(IOMMUFDBackendClass),
> + .class_init = iommufd_backend_class_init,
> + .interfaces = (InterfaceInfo[]) {
> + { TYPE_USER_CREATABLE },
> + { }
> + }
> + }, {
> + .name = TYPE_HIOD_IOMMUFD,
> + .parent = TYPE_HOST_IOMMU_DEVICE,
> + .instance_size = sizeof(HIODIOMMUFD),
> + .class_size = sizeof(HIODIOMMUFDClass),
> + .class_init = hiod_iommufd_class_init,
> + .abstract = true,
> + }
> +};
> +
> +DEFINE_TYPES(types)
next prev parent reply other threads:[~2024-04-15 13:08 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
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 [this message]
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=b761d626-046a-4032-940a-17d659090c9f@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=yi.y.sun@linux.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).