From nobody Tue Nov 26 16:26:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1706772669; cv=none; d=zohomail.com; s=zohoarc; b=Dh1/vdQiUpK3nKRQeeXBIwdWL4NKcuU6YEth8DOxC6KqNANH3K7fa1uK7CxRlpW+fbVZPF1wKDgixOdDWvQ6n3ScR8qflFvSlwAXwUl5985Sb9yao17/vPCVoVBG9OTNAa/I3Wq3+/B2qHr8LsTLpp97R7M/oBUtjT2VVm+dfPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706772669; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=H+hgtkX87V8thNdJrp8zJ1kkIDNchghHd+QfmQUrF1Q=; b=HP1y4+VEIao47AT7WXwxeHTbczj4lGtFGF9/JUcXWf8Sd89+6HI3qkagegveFv4oQMftwKV/L/7XhtWK8csZXWfuB/ksJN2z7cuPhzaSfuphEe2qh6WLbrGLaYCTR9lPfiQbYyyYTxPjkyDksTWnKmW0e/W1+6Pc/K60TZzmJfc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706772669191137.13939193311046; Wed, 31 Jan 2024 23:31:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVRX9-0005VQ-TX; Thu, 01 Feb 2024 02:30:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVRX8-0005UK-Fo; Thu, 01 Feb 2024 02:30:50 -0500 Received: from mgamail.intel.com ([192.55.52.120]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVRX4-0001ck-1Q; Thu, 01 Feb 2024 02:30:50 -0500 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2024 23:30:42 -0800 Received: from spr-s2600bt.bj.intel.com ([10.240.192.124]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2024 23:30:37 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706772646; x=1738308646; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TgSkZfw+it2zJiFcuri/JTQyY0VaeQ1D5N/sRZjophw=; b=JX6ODzplnBgH+po5S9cAPaejaiR/If0WC7RtpNl8YcSDQa5iMRo529xT OX7iKnPsSuWu+18btu+0tFf4a3Cq0EiUMaWjBXfRnEE8Q0p0vDQGrXG4F dJuhghg7xNXYAsWKmOReteCZyovjvIcGa1AT5G+vKTMRS5QSmLvVL27fl e+VQ0ylxmyn38WdlXK+6Jo9vsGtNV+lECzxfm2phwnhC8SM07uiIRIhVE zhrKtjSyvROskVY2i1sWRrkwE588OaC/3RTdxjLtJsU85sZ3HqTkRJ+58 YKDModsGZmBYHt76m3SpVdwSt5yCVshXNvY/1Z7eFKbRMU9G1k/G1Eilw w==; X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="402676690" X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="402676690" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="4443226" From: Zhenzhong Duan 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 , Thomas Huth , Tony Krowiak , Halil Pasic , Jason Herne , Eric Farman , Matthew Rosato , 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 Message-Id: <20240201072818.327930-6-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240201072818.327930-1-zhenzhong.duan@intel.com> References: <20240201072818.327930-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.55.52.120; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -56 X-Spam_score: -5.7 X-Spam_bar: ----- X-Spam_report: (-5.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.292, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1706772669985100001 Content-Type: text/plain; charset="utf-8" iommufd and devid in VFIODevice are redundant with the ones in IOMMUFDDevice, so remove them. Suggested-by: Eric Auger Signed-off-by: Zhenzhong Duan --- 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[] =3D { 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[] =3D { DEFINE_PROP_STRING("sysfsdev", VFIOCCWDevice, vdev.sysfsdev), DEFINE_PROP_BOOL("force-orb-pfch", VFIOCCWDevice, force_orb_pfch, fals= e), #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 *vbased= ev, const VFIOIOMMUClass *ops =3D VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_LEGACY)); =20 - if (vbasedev->iommufd) { + if (vbasedev->iommufd_dev.iommufd) { ops =3D VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_IOMM= UFD)); } =20 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 =3D 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 *vbase= dev) =20 static int iommufd_cdev_connect_and_bind(VFIODevice *vbasedev, Error **err= p) { - IOMMUFDBackend *iommufd =3D vbasedev->iommufd; + IOMMUFDBackend *iommufd =3D vbasedev->iommufd_dev.iommufd; struct vfio_device_bind_iommufd bind =3D { .argsz =3D sizeof(bind), .flags =3D 0, @@ -96,9 +96,10 @@ static int iommufd_cdev_connect_and_bind(VFIODevice *vba= sedev, Error **errp) goto err_bind; } =20 - vbasedev->devid =3D bind.out_devid; + vbasedev->iommufd_dev.devid =3D 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(VFIODevi= ce *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); } =20 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 =3D vbasedev->iommufd->fd; + int ret, iommufd =3D vbasedev->iommufd_dev.iommufd->fd; struct vfio_device_attach_iommufd_pt attach_data =3D { .argsz =3D sizeof(attach_data), .flags =3D 0, @@ -203,7 +204,7 @@ static int iommufd_cdev_attach_ioas_hwpt(VFIODevice *vb= asedev, uint32_t id, =20 static int iommufd_cdev_detach_ioas_hwpt(VFIODevice *vbasedev, Error **err= p) { - int ret, iommufd =3D vbasedev->iommufd->fd; + int ret, iommufd =3D vbasedev->iommufd_dev.iommufd->fd; struct vfio_device_detach_iommufd_pt detach_data =3D { .argsz =3D sizeof(detach_data), .flags =3D 0, @@ -337,7 +338,7 @@ static int iommufd_cdev_attach(const char *name, VFIODe= vice *vbasedev, QLIST_FOREACH(bcontainer, &space->containers, next) { container =3D container_of(bcontainer, VFIOIOMMUFDContainer, bcont= ainer); if (bcontainer->ops !=3D iommufd_vioc || - vbasedev->iommufd !=3D container->be) { + vbasedev->iommufd_dev.iommufd !=3D container->be) { continue; } if (iommufd_cdev_attach_container(vbasedev, container, &err)) { @@ -358,15 +359,16 @@ static int iommufd_cdev_attach(const char *name, VFIO= Device *vbasedev, } =20 /* Need to allocate a new dedicated container */ - ret =3D iommufd_backend_alloc_ioas(vbasedev->iommufd, &ioas_id, errp); + ret =3D iommufd_backend_alloc_ioas(vbasedev->iommufd_dev.iommufd, + &ioas_id, errp); if (ret < 0) { goto err_alloc_ioas; } =20 - trace_iommufd_cdev_alloc_ioas(vbasedev->iommufd->fd, ioas_id); + trace_iommufd_cdev_alloc_ioas(vbasedev->iommufd_dev.iommufd->fd, ioas_= id); =20 container =3D g_malloc0(sizeof(*container)); - container->be =3D vbasedev->iommufd; + container->be =3D vbasedev->iommufd_dev.iommufd; container->ioas_id =3D ioas_id; =20 bcontainer =3D &container->bcontainer; @@ -479,7 +481,7 @@ static VFIODevice *iommufd_cdev_pci_find_by_devid(__u32= devid) if (vbasedev_iter->bcontainer->ops !=3D iommufd_vioc) { continue; } - if (devid =3D=3D vbasedev_iter->devid) { + if (devid =3D=3D vbasedev_iter->iommufd_dev.devid) { return vbasedev_iter; } } @@ -492,7 +494,7 @@ iommufd_cdev_dep_get_realized_vpdev(struct vfio_pci_dep= endent_device *dep_dev, { VFIODevice *vbasedev_tmp; =20 - if (dep_dev->devid =3D=3D reset_dev->devid || + if (dep_dev->devid =3D=3D reset_dev->iommufd_dev.devid || dep_dev->devid =3D=3D 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[] =3D { DEFINE_PROP_OFF_AUTO_PCIBAR("x-msix-relocation", VFIOPCIDevice, msix_r= elo, OFF_AUTOPCIBAR_OFF), #ifdef CONFIG_IOMMUFD - DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd, + DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd_dev.iommuf= d, 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[] =3D { 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(), --=20 2.34.1