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