Lines Matching refs:vdev

13 bool vfio_iommufd_device_has_compat_ioas(struct vfio_device *vdev,
23 struct vfio_device *vdev = df->device;
26 lockdep_assert_held(&vdev->dev_set->lock);
28 return vdev->ops->bind_iommufd(vdev, ictx, &df->devid);
31 int vfio_iommufd_compat_attach_ioas(struct vfio_device *vdev,
37 lockdep_assert_held(&vdev->dev_set->lock);
40 if (vfio_device_is_noiommu(vdev))
48 return vdev->ops->attach_ioas(vdev, &ioas_id);
53 struct vfio_device *vdev = df->device;
55 lockdep_assert_held(&vdev->dev_set->lock);
57 if (vfio_device_is_noiommu(vdev))
60 if (vdev->ops->unbind_iommufd)
61 vdev->ops->unbind_iommufd(vdev);
64 struct iommufd_ctx *vfio_iommufd_device_ictx(struct vfio_device *vdev)
66 if (vdev->iommufd_device)
67 return iommufd_device_to_ictx(vdev->iommufd_device);
72 static int vfio_iommufd_device_id(struct vfio_device *vdev)
74 if (vdev->iommufd_device)
75 return iommufd_device_to_id(vdev->iommufd_device);
85 int vfio_iommufd_get_dev_id(struct vfio_device *vdev, struct iommufd_ctx *ictx)
90 if (vfio_iommufd_device_ictx(vdev) == ictx)
91 return vfio_iommufd_device_id(vdev);
93 group = iommu_group_get(vdev->dev);
110 * physical device vdev->dev that was provided to vfio_init_group_dev(). Drivers
113 int vfio_iommufd_physical_bind(struct vfio_device *vdev,
118 idev = iommufd_device_bind(ictx, vdev->dev, out_device_id);
121 vdev->iommufd_device = idev;
126 void vfio_iommufd_physical_unbind(struct vfio_device *vdev)
128 lockdep_assert_held(&vdev->dev_set->lock);
130 if (vdev->iommufd_attached) {
131 iommufd_device_detach(vdev->iommufd_device);
132 vdev->iommufd_attached = false;
134 iommufd_device_unbind(vdev->iommufd_device);
135 vdev->iommufd_device = NULL;
139 int vfio_iommufd_physical_attach_ioas(struct vfio_device *vdev, u32 *pt_id)
143 lockdep_assert_held(&vdev->dev_set->lock);
145 if (WARN_ON(!vdev->iommufd_device))
148 if (vdev->iommufd_attached)
149 rc = iommufd_device_replace(vdev->iommufd_device, pt_id);
151 rc = iommufd_device_attach(vdev->iommufd_device, pt_id);
154 vdev->iommufd_attached = true;
159 void vfio_iommufd_physical_detach_ioas(struct vfio_device *vdev)
161 lockdep_assert_held(&vdev->dev_set->lock);
163 if (WARN_ON(!vdev->iommufd_device) || !vdev->iommufd_attached)
166 iommufd_device_detach(vdev->iommufd_device);
167 vdev->iommufd_attached = false;
181 struct vfio_device *vdev = data;
183 if (vdev->ops->dma_unmap)
184 vdev->ops->dma_unmap(vdev, iova, length);
192 int vfio_iommufd_emulated_bind(struct vfio_device *vdev,
197 lockdep_assert_held(&vdev->dev_set->lock);
199 user = iommufd_access_create(ictx, &vfio_user_ops, vdev, out_device_id);
202 vdev->iommufd_access = user;
207 void vfio_iommufd_emulated_unbind(struct vfio_device *vdev)
209 lockdep_assert_held(&vdev->dev_set->lock);
211 if (vdev->iommufd_access) {
212 iommufd_access_destroy(vdev->iommufd_access);
213 vdev->iommufd_attached = false;
214 vdev->iommufd_access = NULL;
219 int vfio_iommufd_emulated_attach_ioas(struct vfio_device *vdev, u32 *pt_id)
223 lockdep_assert_held(&vdev->dev_set->lock);
225 if (vdev->iommufd_attached)
226 rc = iommufd_access_replace(vdev->iommufd_access, *pt_id);
228 rc = iommufd_access_attach(vdev->iommufd_access, *pt_id);
231 vdev->iommufd_attached = true;
236 void vfio_iommufd_emulated_detach_ioas(struct vfio_device *vdev)
238 lockdep_assert_held(&vdev->dev_set->lock);
240 if (WARN_ON(!vdev->iommufd_access) ||
241 !vdev->iommufd_attached)
244 iommufd_access_detach(vdev->iommufd_access);
245 vdev->iommufd_attached = false;