[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250627033809.1730752-4-yilun.xu@linux.intel.com>
Date: Fri, 27 Jun 2025 11:38:07 +0800
From: Xu Yilun <yilun.xu@...ux.intel.com>
To: jgg@...dia.com,
jgg@...pe.ca,
kevin.tian@...el.com,
will@...nel.org,
aneesh.kumar@...nel.org
Cc: iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org,
joro@...tes.org,
robin.murphy@....com,
shuah@...nel.org,
nicolinc@...dia.com,
aik@....com,
dan.j.williams@...el.com,
baolu.lu@...ux.intel.com,
yilun.xu@...el.com
Subject: [PATCH v3 3/5] iommufd/vdevice: Remove struct device reference from struct vdevice
Remove struct device *dev from struct vdevice.
The dev pointer is the Plan B for vdevice to reference the physical
device. As now vdev->idev is added without refcounting concern, just
use vdev->idev->dev when needed.
Signed-off-by: Xu Yilun <yilun.xu@...ux.intel.com>
---
drivers/iommu/iommufd/driver.c | 4 ++--
drivers/iommu/iommufd/iommufd_private.h | 1 -
drivers/iommu/iommufd/viommu.c | 3 ---
3 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/iommu/iommufd/driver.c b/drivers/iommu/iommufd/driver.c
index 922cd1fe7ec2..942d402bba36 100644
--- a/drivers/iommu/iommufd/driver.c
+++ b/drivers/iommu/iommufd/driver.c
@@ -45,7 +45,7 @@ struct device *iommufd_viommu_find_dev(struct iommufd_viommu *viommu,
lockdep_assert_held(&viommu->vdevs.xa_lock);
vdev = xa_load(&viommu->vdevs, vdev_id);
- return vdev ? vdev->dev : NULL;
+ return vdev ? vdev->idev->dev : NULL;
}
EXPORT_SYMBOL_NS_GPL(iommufd_viommu_find_dev, "IOMMUFD");
@@ -62,7 +62,7 @@ int iommufd_viommu_get_vdev_id(struct iommufd_viommu *viommu,
xa_lock(&viommu->vdevs);
xa_for_each(&viommu->vdevs, index, vdev) {
- if (vdev->dev == dev) {
+ if (vdev->idev->dev == dev) {
*vdev_id = vdev->id;
rc = 0;
break;
diff --git a/drivers/iommu/iommufd/iommufd_private.h b/drivers/iommu/iommufd/iommufd_private.h
index f58aa4439c53..3700193471db 100644
--- a/drivers/iommu/iommufd/iommufd_private.h
+++ b/drivers/iommu/iommufd/iommufd_private.h
@@ -628,7 +628,6 @@ struct iommufd_vdevice {
struct iommufd_object obj;
struct iommufd_ctx *ictx;
struct iommufd_viommu *viommu;
- struct device *dev;
u64 id; /* per-vIOMMU virtual ID */
struct iommufd_device *idev;
};
diff --git a/drivers/iommu/iommufd/viommu.c b/drivers/iommu/iommufd/viommu.c
index 632d1d7b8fd8..452a7a24d738 100644
--- a/drivers/iommu/iommufd/viommu.c
+++ b/drivers/iommu/iommufd/viommu.c
@@ -103,7 +103,6 @@ void iommufd_vdevice_abort(struct iommufd_object *obj)
/* xa_cmpxchg is okay to fail if alloc failed xa_cmpxchg previously */
xa_cmpxchg(&viommu->vdevs, vdev->id, vdev, NULL, GFP_KERNEL);
refcount_dec(&viommu->obj.users);
- put_device(vdev->dev);
vdev->viommu = NULL;
idev->vdev = NULL;
}
@@ -159,8 +158,6 @@ int iommufd_vdevice_alloc_ioctl(struct iommufd_ucmd *ucmd)
}
vdev->id = virt_id;
- vdev->dev = idev->dev;
- get_device(idev->dev);
vdev->viommu = viommu;
refcount_inc(&viommu->obj.users);
/*
--
2.25.1
Powered by blists - more mailing lists