mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 18:13:41 +02:00
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. To avoid exposing struct iommufd_device in the public header, export a iommufd_vdevice_to_device() helper. Link: https://patch.msgid.link/r/20250716070349.1807226-6-yilun.xu@linux.intel.com Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Nicolin Chen <nicolinc@nvidia.com> Co-developed-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Tested-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Xu Yilun <yilun.xu@linux.intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
parent
850f14f5b9
commit
651f733675
|
|
@ -1218,7 +1218,8 @@ static void tegra241_vintf_destroy_vsid(struct iommufd_vdevice *vdev)
|
|||
|
||||
static int tegra241_vintf_init_vsid(struct iommufd_vdevice *vdev)
|
||||
{
|
||||
struct arm_smmu_master *master = dev_iommu_priv_get(vdev->dev);
|
||||
struct device *dev = iommufd_vdevice_to_device(vdev);
|
||||
struct arm_smmu_master *master = dev_iommu_priv_get(dev);
|
||||
struct tegra241_vintf *vintf = viommu_to_vintf(vdev->viommu);
|
||||
struct tegra241_vintf_sid *vsid = vdev_to_vsid(vdev);
|
||||
struct arm_smmu_stream *stream = &master->streams[0];
|
||||
|
|
|
|||
|
|
@ -83,6 +83,12 @@ void _iommufd_destroy_mmap(struct iommufd_ctx *ictx,
|
|||
}
|
||||
EXPORT_SYMBOL_NS_GPL(_iommufd_destroy_mmap, "IOMMUFD");
|
||||
|
||||
struct device *iommufd_vdevice_to_device(struct iommufd_vdevice *vdev)
|
||||
{
|
||||
return vdev->idev->dev;
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(iommufd_vdevice_to_device, "IOMMUFD");
|
||||
|
||||
/* Caller should xa_lock(&viommu->vdevs) to protect the return value */
|
||||
struct device *iommufd_viommu_find_dev(struct iommufd_viommu *viommu,
|
||||
unsigned long vdev_id)
|
||||
|
|
@ -92,7 +98,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 ? iommufd_vdevice_to_device(vdev) : NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(iommufd_viommu_find_dev, "IOMMUFD");
|
||||
|
||||
|
|
@ -109,7 +115,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 (iommufd_vdevice_to_device(vdev) == dev) {
|
||||
*vdev_id = vdev->virt_id;
|
||||
rc = 0;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -125,7 +125,6 @@ void iommufd_vdevice_abort(struct iommufd_object *obj)
|
|||
xa_cmpxchg(&viommu->vdevs, vdev->virt_id, vdev, NULL, GFP_KERNEL);
|
||||
refcount_dec(&viommu->obj.users);
|
||||
idev->vdev = NULL;
|
||||
put_device(vdev->dev);
|
||||
}
|
||||
|
||||
void iommufd_vdevice_destroy(struct iommufd_object *obj)
|
||||
|
|
@ -203,8 +202,6 @@ int iommufd_vdevice_alloc_ioctl(struct iommufd_ucmd *ucmd)
|
|||
}
|
||||
|
||||
vdev->virt_id = virt_id;
|
||||
vdev->dev = idev->dev;
|
||||
get_device(idev->dev);
|
||||
vdev->viommu = viommu;
|
||||
refcount_inc(&viommu->obj.users);
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ struct iommufd_vdevice {
|
|||
struct iommufd_object obj;
|
||||
struct iommufd_viommu *viommu;
|
||||
struct iommufd_device *idev;
|
||||
struct device *dev;
|
||||
|
||||
/*
|
||||
* Virtual device ID per vIOMMU, e.g. vSID of ARM SMMUv3, vDeviceID of
|
||||
|
|
@ -261,6 +260,7 @@ int _iommufd_alloc_mmap(struct iommufd_ctx *ictx, struct iommufd_object *owner,
|
|||
unsigned long *offset);
|
||||
void _iommufd_destroy_mmap(struct iommufd_ctx *ictx,
|
||||
struct iommufd_object *owner, unsigned long offset);
|
||||
struct device *iommufd_vdevice_to_device(struct iommufd_vdevice *vdev);
|
||||
struct device *iommufd_viommu_find_dev(struct iommufd_viommu *viommu,
|
||||
unsigned long vdev_id);
|
||||
int iommufd_viommu_get_vdev_id(struct iommufd_viommu *viommu,
|
||||
|
|
@ -295,6 +295,12 @@ static inline void _iommufd_destroy_mmap(struct iommufd_ctx *ictx,
|
|||
{
|
||||
}
|
||||
|
||||
static inline struct device *
|
||||
iommufd_vdevice_to_device(struct iommufd_vdevice *vdev)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct device *
|
||||
iommufd_viommu_find_dev(struct iommufd_viommu *viommu, unsigned long vdev_id)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user