vfio-iommufd: Add detach_ioas support for emulated VFIO devices
This prepares for adding DETACH ioctl for emulated VFIO devices. Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Tested-by: Terrence Xu <terrence.xu@intel.com> Tested-by: Nicolin Chen <nicolinc@nvidia.com> Tested-by: Matthew Rosato <mjrosato@linux.ibm.com> Tested-by: Yanting Jiang <yanting.jiang@intel.com> Tested-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> Tested-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Signed-off-by: Yi Liu <yi.l.liu@intel.com> Link: https://lore.kernel.org/r/20230718135551.6592-16-yi.l.liu@intel.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
parent
e23a6217f3
commit
8cfa718602
@ -1474,6 +1474,7 @@ static const struct vfio_device_ops intel_vgpu_dev_ops = {
|
||||
.bind_iommufd = vfio_iommufd_emulated_bind,
|
||||
.unbind_iommufd = vfio_iommufd_emulated_unbind,
|
||||
.attach_ioas = vfio_iommufd_emulated_attach_ioas,
|
||||
.detach_ioas = vfio_iommufd_emulated_detach_ioas,
|
||||
};
|
||||
|
||||
static int intel_vgpu_probe(struct mdev_device *mdev)
|
||||
|
@ -632,6 +632,7 @@ static const struct vfio_device_ops vfio_ccw_dev_ops = {
|
||||
.bind_iommufd = vfio_iommufd_emulated_bind,
|
||||
.unbind_iommufd = vfio_iommufd_emulated_unbind,
|
||||
.attach_ioas = vfio_iommufd_emulated_attach_ioas,
|
||||
.detach_ioas = vfio_iommufd_emulated_detach_ioas,
|
||||
};
|
||||
|
||||
struct mdev_driver vfio_ccw_mdev_driver = {
|
||||
|
@ -1975,6 +1975,7 @@ static const struct vfio_device_ops vfio_ap_matrix_dev_ops = {
|
||||
.bind_iommufd = vfio_iommufd_emulated_bind,
|
||||
.unbind_iommufd = vfio_iommufd_emulated_unbind,
|
||||
.attach_ioas = vfio_iommufd_emulated_attach_ioas,
|
||||
.detach_ioas = vfio_iommufd_emulated_detach_ioas,
|
||||
.request = vfio_ap_mdev_request
|
||||
};
|
||||
|
||||
|
@ -231,3 +231,16 @@ int vfio_iommufd_emulated_attach_ioas(struct vfio_device *vdev, u32 *pt_id)
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vfio_iommufd_emulated_attach_ioas);
|
||||
|
||||
void vfio_iommufd_emulated_detach_ioas(struct vfio_device *vdev)
|
||||
{
|
||||
lockdep_assert_held(&vdev->dev_set->lock);
|
||||
|
||||
if (WARN_ON(!vdev->iommufd_access) ||
|
||||
!vdev->iommufd_attached)
|
||||
return;
|
||||
|
||||
iommufd_access_detach(vdev->iommufd_access);
|
||||
vdev->iommufd_attached = false;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vfio_iommufd_emulated_detach_ioas);
|
||||
|
@ -128,6 +128,7 @@ int vfio_iommufd_emulated_bind(struct vfio_device *vdev,
|
||||
struct iommufd_ctx *ictx, u32 *out_device_id);
|
||||
void vfio_iommufd_emulated_unbind(struct vfio_device *vdev);
|
||||
int vfio_iommufd_emulated_attach_ioas(struct vfio_device *vdev, u32 *pt_id);
|
||||
void vfio_iommufd_emulated_detach_ioas(struct vfio_device *vdev);
|
||||
#else
|
||||
static inline struct iommufd_ctx *
|
||||
vfio_iommufd_device_ictx(struct vfio_device *vdev)
|
||||
@ -157,6 +158,8 @@ vfio_iommufd_get_dev_id(struct vfio_device *vdev, struct iommufd_ctx *ictx)
|
||||
((void (*)(struct vfio_device *vdev)) NULL)
|
||||
#define vfio_iommufd_emulated_attach_ioas \
|
||||
((int (*)(struct vfio_device *vdev, u32 *pt_id)) NULL)
|
||||
#define vfio_iommufd_emulated_detach_ioas \
|
||||
((void (*)(struct vfio_device *vdev)) NULL)
|
||||
#endif
|
||||
|
||||
static inline bool vfio_device_cdev_opened(struct vfio_device *device)
|
||||
|
@ -1377,6 +1377,7 @@ static const struct vfio_device_ops mbochs_dev_ops = {
|
||||
.bind_iommufd = vfio_iommufd_emulated_bind,
|
||||
.unbind_iommufd = vfio_iommufd_emulated_unbind,
|
||||
.attach_ioas = vfio_iommufd_emulated_attach_ioas,
|
||||
.detach_ioas = vfio_iommufd_emulated_detach_ioas,
|
||||
};
|
||||
|
||||
static struct mdev_driver mbochs_driver = {
|
||||
|
@ -666,6 +666,7 @@ static const struct vfio_device_ops mdpy_dev_ops = {
|
||||
.bind_iommufd = vfio_iommufd_emulated_bind,
|
||||
.unbind_iommufd = vfio_iommufd_emulated_unbind,
|
||||
.attach_ioas = vfio_iommufd_emulated_attach_ioas,
|
||||
.detach_ioas = vfio_iommufd_emulated_detach_ioas,
|
||||
};
|
||||
|
||||
static struct mdev_driver mdpy_driver = {
|
||||
|
@ -1272,6 +1272,7 @@ static const struct vfio_device_ops mtty_dev_ops = {
|
||||
.bind_iommufd = vfio_iommufd_emulated_bind,
|
||||
.unbind_iommufd = vfio_iommufd_emulated_unbind,
|
||||
.attach_ioas = vfio_iommufd_emulated_attach_ioas,
|
||||
.detach_ioas = vfio_iommufd_emulated_detach_ioas,
|
||||
};
|
||||
|
||||
static struct mdev_driver mtty_driver = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user