Skip to content

Commit 4508a53

Browse files
yiliu1765jgunthorpe
authored andcommitted
vfio-iommufd: No need to record iommufd_ctx in vfio_device
iommufd_ctx is stored in vfio_device for emulated devices per bind_iommufd. However, as iommufd_access is created in bind, no more need to stored it since iommufd_access implicitly stores it. Link: https://lore.kernel.org/r/20230327093351.44505-4-yi.l.liu@intel.com Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Tested-by: Terrence Xu <terrence.xu@intel.com> Tested-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Yi Liu <yi.l.liu@intel.com> Acked-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 54b4758 commit 4508a53

2 files changed

Lines changed: 1 addition & 8 deletions

File tree

drivers/vfio/iommufd.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,10 @@ int vfio_iommufd_emulated_bind(struct vfio_device *vdev,
142142

143143
lockdep_assert_held(&vdev->dev_set->lock);
144144

145-
iommufd_ctx_get(ictx);
146145
user = iommufd_access_create(ictx, &vfio_user_ops, vdev);
147-
if (IS_ERR(user)) {
148-
iommufd_ctx_put(ictx);
146+
if (IS_ERR(user))
149147
return PTR_ERR(user);
150-
}
151148
vdev->iommufd_access = user;
152-
vdev->iommufd_ictx = ictx;
153149
return 0;
154150
}
155151
EXPORT_SYMBOL_GPL(vfio_iommufd_emulated_bind);
@@ -163,8 +159,6 @@ void vfio_iommufd_emulated_unbind(struct vfio_device *vdev)
163159
vdev->iommufd_attached = false;
164160
vdev->iommufd_access = NULL;
165161
}
166-
iommufd_ctx_put(vdev->iommufd_ictx);
167-
vdev->iommufd_ictx = NULL;
168162
}
169163
EXPORT_SYMBOL_GPL(vfio_iommufd_emulated_unbind);
170164

include/linux/vfio.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ struct vfio_device {
6060
void (*put_kvm)(struct kvm *kvm);
6161
#if IS_ENABLED(CONFIG_IOMMUFD)
6262
struct iommufd_device *iommufd_device;
63-
struct iommufd_ctx *iommufd_ictx;
6463
bool iommufd_attached;
6564
#endif
6665
};

0 commit comments

Comments
 (0)