qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
To: qemu-devel@nongnu.org
Cc: alex.williamson@redhat.com, clg@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, yi.y.sun@intel.com, chao.p.peng@intel.com,
	Zhenzhong Duan <zhenzhong.duan@intel.com>,
	Thomas Huth <thuth@redhat.com>,
	Tony Krowiak <akrowiak@linux.ibm.com>,
	Halil Pasic <pasic@linux.ibm.com>,
	Jason Herne <jjherne@linux.ibm.com>,
	Eric Farman <farman@linux.ibm.com>,
	Matthew Rosato <mjrosato@linux.ibm.com>,
	qemu-s390x@nongnu.org (open list:S390 general arch...)
Subject: [PATCH rfcv2 05/18] vfio: Remove redundant iommufd and devid elements in VFIODevice
Date: Thu,  1 Feb 2024 15:28:05 +0800	[thread overview]
Message-ID: <20240201072818.327930-6-zhenzhong.duan@intel.com> (raw)
In-Reply-To: <20240201072818.327930-1-zhenzhong.duan@intel.com>

iommufd and devid in VFIODevice are redundant with the ones
in IOMMUFDDevice, so remove them.

Suggested-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
 include/hw/vfio/vfio-common.h |  2 --
 hw/vfio/ap.c                  |  2 +-
 hw/vfio/ccw.c                 |  2 +-
 hw/vfio/common.c              |  2 +-
 hw/vfio/helpers.c             |  2 +-
 hw/vfio/iommufd.c             | 26 ++++++++++++++------------
 hw/vfio/pci.c                 |  2 +-
 hw/vfio/platform.c            |  3 ++-
 8 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index 1bbad003ee..24e3eaaf3d 100644
--- a/include/hw/vfio/vfio-common.h
+++ b/include/hw/vfio/vfio-common.h
@@ -131,8 +131,6 @@ typedef struct VFIODevice {
     OnOffAuto pre_copy_dirty_page_tracking;
     bool dirty_pages_supported;
     bool dirty_tracking;
-    int devid;
-    IOMMUFDBackend *iommufd;
     union {
         HostIOMMUDevice base_hdev;
         IOMMULegacyDevice legacy_dev;
diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
index e157aa1ff7..11526d93d4 100644
--- a/hw/vfio/ap.c
+++ b/hw/vfio/ap.c
@@ -198,7 +198,7 @@ static void vfio_ap_unrealize(DeviceState *dev)
 static Property vfio_ap_properties[] = {
     DEFINE_PROP_STRING("sysfsdev", VFIOAPDevice, vdev.sysfsdev),
 #ifdef CONFIG_IOMMUFD
-    DEFINE_PROP_LINK("iommufd", VFIOAPDevice, vdev.iommufd,
+    DEFINE_PROP_LINK("iommufd", VFIOAPDevice, vdev.iommufd_dev.iommufd,
                      TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
 #endif
     DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index 90e4a53437..b1b75ffa2a 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -667,7 +667,7 @@ static Property vfio_ccw_properties[] = {
     DEFINE_PROP_STRING("sysfsdev", VFIOCCWDevice, vdev.sysfsdev),
     DEFINE_PROP_BOOL("force-orb-pfch", VFIOCCWDevice, force_orb_pfch, false),
 #ifdef CONFIG_IOMMUFD
-    DEFINE_PROP_LINK("iommufd", VFIOCCWDevice, vdev.iommufd,
+    DEFINE_PROP_LINK("iommufd", VFIOCCWDevice, vdev.iommufd_dev.iommufd,
                      TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
 #endif
     DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 059bfdc07a..8b3b575c9d 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1505,7 +1505,7 @@ int vfio_attach_device(char *name, VFIODevice *vbasedev,
     const VFIOIOMMUClass *ops =
         VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_LEGACY));
 
-    if (vbasedev->iommufd) {
+    if (vbasedev->iommufd_dev.iommufd) {
         ops = VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_IOMMUFD));
     }
 
diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c
index 6789870802..e5457ca326 100644
--- a/hw/vfio/helpers.c
+++ b/hw/vfio/helpers.c
@@ -626,7 +626,7 @@ int vfio_device_get_name(VFIODevice *vbasedev, Error **errp)
             vbasedev->name = g_path_get_basename(vbasedev->sysfsdev);
         }
     } else {
-        if (!vbasedev->iommufd) {
+        if (!vbasedev->iommufd_dev.iommufd) {
             error_setg(errp, "Use FD passing only with iommufd backend");
             return -EINVAL;
         }
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
index 9bfddc1360..5d50549713 100644
--- a/hw/vfio/iommufd.c
+++ b/hw/vfio/iommufd.c
@@ -65,7 +65,7 @@ static void iommufd_cdev_kvm_device_del(VFIODevice *vbasedev)
 
 static int iommufd_cdev_connect_and_bind(VFIODevice *vbasedev, Error **errp)
 {
-    IOMMUFDBackend *iommufd = vbasedev->iommufd;
+    IOMMUFDBackend *iommufd = vbasedev->iommufd_dev.iommufd;
     struct vfio_device_bind_iommufd bind = {
         .argsz = sizeof(bind),
         .flags = 0,
@@ -96,9 +96,10 @@ static int iommufd_cdev_connect_and_bind(VFIODevice *vbasedev, Error **errp)
         goto err_bind;
     }
 
-    vbasedev->devid = bind.out_devid;
+    vbasedev->iommufd_dev.devid = bind.out_devid;
     trace_iommufd_cdev_connect_and_bind(bind.iommufd, vbasedev->name,
-                                        vbasedev->fd, vbasedev->devid);
+                                        vbasedev->fd,
+                                        vbasedev->iommufd_dev.devid);
     return ret;
 err_bind:
     iommufd_cdev_kvm_device_del(vbasedev);
@@ -111,7 +112,7 @@ static void iommufd_cdev_unbind_and_disconnect(VFIODevice *vbasedev)
 {
     /* Unbind is automatically conducted when device fd is closed */
     iommufd_cdev_kvm_device_del(vbasedev);
-    iommufd_backend_disconnect(vbasedev->iommufd);
+    iommufd_backend_disconnect(vbasedev->iommufd_dev.iommufd);
 }
 
 static int iommufd_cdev_getfd(const char *sysfs_path, Error **errp)
@@ -181,7 +182,7 @@ out_free_path:
 static int iommufd_cdev_attach_ioas_hwpt(VFIODevice *vbasedev, uint32_t id,
                                          Error **errp)
 {
-    int ret, iommufd = vbasedev->iommufd->fd;
+    int ret, iommufd = vbasedev->iommufd_dev.iommufd->fd;
     struct vfio_device_attach_iommufd_pt attach_data = {
         .argsz = sizeof(attach_data),
         .flags = 0,
@@ -203,7 +204,7 @@ static int iommufd_cdev_attach_ioas_hwpt(VFIODevice *vbasedev, uint32_t id,
 
 static int iommufd_cdev_detach_ioas_hwpt(VFIODevice *vbasedev, Error **errp)
 {
-    int ret, iommufd = vbasedev->iommufd->fd;
+    int ret, iommufd = vbasedev->iommufd_dev.iommufd->fd;
     struct vfio_device_detach_iommufd_pt detach_data = {
         .argsz = sizeof(detach_data),
         .flags = 0,
@@ -337,7 +338,7 @@ static int iommufd_cdev_attach(const char *name, VFIODevice *vbasedev,
     QLIST_FOREACH(bcontainer, &space->containers, next) {
         container = container_of(bcontainer, VFIOIOMMUFDContainer, bcontainer);
         if (bcontainer->ops != iommufd_vioc ||
-            vbasedev->iommufd != container->be) {
+            vbasedev->iommufd_dev.iommufd != container->be) {
             continue;
         }
         if (iommufd_cdev_attach_container(vbasedev, container, &err)) {
@@ -358,15 +359,16 @@ static int iommufd_cdev_attach(const char *name, VFIODevice *vbasedev,
     }
 
     /* Need to allocate a new dedicated container */
-    ret = iommufd_backend_alloc_ioas(vbasedev->iommufd, &ioas_id, errp);
+    ret = iommufd_backend_alloc_ioas(vbasedev->iommufd_dev.iommufd,
+                                     &ioas_id, errp);
     if (ret < 0) {
         goto err_alloc_ioas;
     }
 
-    trace_iommufd_cdev_alloc_ioas(vbasedev->iommufd->fd, ioas_id);
+    trace_iommufd_cdev_alloc_ioas(vbasedev->iommufd_dev.iommufd->fd, ioas_id);
 
     container = g_malloc0(sizeof(*container));
-    container->be = vbasedev->iommufd;
+    container->be = vbasedev->iommufd_dev.iommufd;
     container->ioas_id = ioas_id;
 
     bcontainer = &container->bcontainer;
@@ -479,7 +481,7 @@ static VFIODevice *iommufd_cdev_pci_find_by_devid(__u32 devid)
         if (vbasedev_iter->bcontainer->ops != iommufd_vioc) {
             continue;
         }
-        if (devid == vbasedev_iter->devid) {
+        if (devid == vbasedev_iter->iommufd_dev.devid) {
             return vbasedev_iter;
         }
     }
@@ -492,7 +494,7 @@ iommufd_cdev_dep_get_realized_vpdev(struct vfio_pci_dependent_device *dep_dev,
 {
     VFIODevice *vbasedev_tmp;
 
-    if (dep_dev->devid == reset_dev->devid ||
+    if (dep_dev->devid == reset_dev->iommufd_dev.devid ||
         dep_dev->devid == VFIO_PCI_DEVID_OWNED) {
         return NULL;
     }
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 4fa387f043..d1e1b8cb89 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -3385,7 +3385,7 @@ static Property vfio_pci_dev_properties[] = {
     DEFINE_PROP_OFF_AUTO_PCIBAR("x-msix-relocation", VFIOPCIDevice, msix_relo,
                                 OFF_AUTOPCIBAR_OFF),
 #ifdef CONFIG_IOMMUFD
-    DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd,
+    DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd_dev.iommufd,
                      TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
 #endif
     DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
index a8d9b7da63..823a17b9c5 100644
--- a/hw/vfio/platform.c
+++ b/hw/vfio/platform.c
@@ -646,7 +646,8 @@ static Property vfio_platform_dev_properties[] = {
                        mmap_timeout, 1100),
     DEFINE_PROP_BOOL("x-irqfd", VFIOPlatformDevice, irqfd_allowed, true),
 #ifdef CONFIG_IOMMUFD
-    DEFINE_PROP_LINK("iommufd", VFIOPlatformDevice, vbasedev.iommufd,
+    DEFINE_PROP_LINK("iommufd", VFIOPlatformDevice,
+                     vbasedev.iommufd_dev.iommufd,
                      TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
 #endif
     DEFINE_PROP_END_OF_LIST(),
-- 
2.34.1



  parent reply	other threads:[~2024-02-01  7:31 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01  7:28 [PATCH rfcv2 00/18] Check and sync host IOMMU cap/ecap with vIOMMU Zhenzhong Duan
2024-02-01  7:28 ` [PATCH rfcv2 01/18] Introduce a common abstract struct HostIOMMUDevice Zhenzhong Duan
2024-02-01  7:28 ` [PATCH rfcv2 02/18] backends/iommufd: Introduce IOMMUFDDevice Zhenzhong Duan
2024-02-01  7:28 ` [PATCH rfcv2 03/18] vfio: Introduce IOMMULegacyDevice Zhenzhong Duan
2024-02-01  7:28 ` [PATCH rfcv2 04/18] vfio: Add host iommu device instance into VFIODevice Zhenzhong Duan
2024-02-19 15:34   ` Eric Auger
2024-02-19 15:45   ` Eric Auger
2024-02-26  6:16     ` Duan, Zhenzhong
2024-02-01  7:28 ` Zhenzhong Duan [this message]
2024-02-01  7:28 ` [PATCH rfcv2 06/18] vfio: Introduce host_iommu_device_init callback Zhenzhong Duan
2024-02-01  7:28 ` [PATCH rfcv2 07/18] vfio/container: Implement host_iommu_device_init callback in legacy mode Zhenzhong Duan
2024-02-19 17:13   ` Eric Auger
2024-02-26  6:56     ` Duan, Zhenzhong
2024-02-01  7:28 ` [PATCH rfcv2 08/18] vfio/iommufd: Implement host_iommu_device_init callback in iommufd mode Zhenzhong Duan
2024-02-01  7:28 ` [PATCH rfcv2 09/18] vfio/pci: Initialize host iommu device instance after attachment Zhenzhong Duan
2024-02-01  7:28 ` [PATCH rfcv2 10/18] hw/pci: Introduce pci_device_set/unset_iommu_device() Zhenzhong Duan
2024-02-19 17:41   ` Eric Auger
2024-02-26  6:26     ` Duan, Zhenzhong
2024-02-01  7:28 ` [PATCH rfcv2 11/18] intel_iommu: Add set/unset_iommu_device callback Zhenzhong Duan
2024-02-19 17:46   ` Eric Auger
2024-02-26  6:52     ` Duan, Zhenzhong
2024-02-01  7:28 ` [PATCH rfcv2 12/18] vfio: Initialize host IOMMU device and pass to vIOMMU Zhenzhong Duan
2024-02-01  7:28 ` [PATCH rfcv2 13/18] intel_iommu: Extract out vtd_cap_init to initialize cap/ecap Zhenzhong Duan
2024-02-01  7:28 ` [PATCH rfcv2 14/18] intel_iommu: Add a framework to check and sync host IOMMU cap/ecap Zhenzhong Duan
2024-02-19 17:51   ` Eric Auger
2024-02-26  7:36     ` Duan, Zhenzhong
2024-02-27 17:06       ` Eric Auger
2024-02-01  7:28 ` [PATCH rfcv2 15/18] backends/iommufd: Introduce helper function iommufd_device_get_info() Zhenzhong Duan
2024-02-01  7:28 ` [PATCH rfcv2 16/18] intel_iommu: Implement check and sync mechanism in iommufd mode Zhenzhong Duan
2024-02-01  7:28 ` [PATCH rfcv2 17/18] intel_iommu: Use mgaw instead of s->aw_bits Zhenzhong Duan
2024-02-01  7:28 ` [PATCH rfcv2 18/18] intel_iommu: Block migration if cap is updated Zhenzhong Duan
2024-02-13 10:55   ` Joao Martins
2024-02-27  2:41     ` Duan, Zhenzhong
2024-02-27 11:08       ` Joao Martins
2024-02-28  2:14         ` Duan, Zhenzhong

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=20240201072818.327930-6-zhenzhong.duan@intel.com \
    --to=zhenzhong.duan@intel.com \
    --cc=akrowiak@linux.ibm.com \
    --cc=alex.williamson@redhat.com \
    --cc=chao.p.peng@intel.com \
    --cc=clg@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=farman@linux.ibm.com \
    --cc=jasowang@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=jjherne@linux.ibm.com \
    --cc=joao.m.martins@oracle.com \
    --cc=kevin.tian@intel.com \
    --cc=mjrosato@linux.ibm.com \
    --cc=mst@redhat.com \
    --cc=nicolinc@nvidia.com \
    --cc=pasic@linux.ibm.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=thuth@redhat.com \
    --cc=yi.l.liu@intel.com \
    --cc=yi.y.sun@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).