Lines Matching refs:container

76 	struct vfio_container		*container;  member
222 static inline bool vfio_iommu_driver_allowed(struct vfio_container *container, in vfio_iommu_driver_allowed() argument
225 return container->noiommu == (driver->ops == &vfio_noiommu_ops); in vfio_iommu_driver_allowed()
228 static inline bool vfio_iommu_driver_allowed(struct vfio_container *container, in vfio_iommu_driver_allowed() argument
294 static void vfio_container_get(struct vfio_container *container) in vfio_container_get() argument
296 kref_get(&container->kref); in vfio_container_get()
301 struct vfio_container *container; in vfio_container_release() local
302 container = container_of(kref, struct vfio_container, kref); in vfio_container_release()
304 kfree(container); in vfio_container_release()
307 static void vfio_container_put(struct vfio_container *container) in vfio_container_put() argument
309 kref_put(&container->kref, vfio_container_release); in vfio_container_put()
958 wait_event(group->container_q, !group->container); in vfio_unregister_group_dev()
971 static long vfio_ioctl_check_extension(struct vfio_container *container, in vfio_ioctl_check_extension() argument
977 down_read(&container->group_lock); in vfio_ioctl_check_extension()
979 driver = container->iommu_driver; in vfio_ioctl_check_extension()
995 if (!list_empty(&container->group_list) && in vfio_ioctl_check_extension()
996 !vfio_iommu_driver_allowed(container, in vfio_ioctl_check_extension()
1011 ret = driver->ops->ioctl(container->iommu_data, in vfio_ioctl_check_extension()
1015 up_read(&container->group_lock); in vfio_ioctl_check_extension()
1021 static int __vfio_container_attach_groups(struct vfio_container *container, in __vfio_container_attach_groups() argument
1028 list_for_each_entry(group, &container->group_list, container_next) { in __vfio_container_attach_groups()
1038 list_for_each_entry_continue_reverse(group, &container->group_list, in __vfio_container_attach_groups()
1046 static long vfio_ioctl_set_iommu(struct vfio_container *container, in vfio_ioctl_set_iommu() argument
1052 down_write(&container->group_lock); in vfio_ioctl_set_iommu()
1062 if (list_empty(&container->group_list) || container->iommu_driver) { in vfio_ioctl_set_iommu()
1063 up_write(&container->group_lock); in vfio_ioctl_set_iommu()
1071 if (!vfio_iommu_driver_allowed(container, driver)) in vfio_ioctl_set_iommu()
1095 ret = __vfio_container_attach_groups(container, driver, data); in vfio_ioctl_set_iommu()
1102 container->iommu_driver = driver; in vfio_ioctl_set_iommu()
1103 container->iommu_data = data; in vfio_ioctl_set_iommu()
1108 up_write(&container->group_lock); in vfio_ioctl_set_iommu()
1116 struct vfio_container *container = filep->private_data; in vfio_fops_unl_ioctl() local
1121 if (!container) in vfio_fops_unl_ioctl()
1129 ret = vfio_ioctl_check_extension(container, arg); in vfio_fops_unl_ioctl()
1132 ret = vfio_ioctl_set_iommu(container, arg); in vfio_fops_unl_ioctl()
1135 driver = container->iommu_driver; in vfio_fops_unl_ioctl()
1136 data = container->iommu_data; in vfio_fops_unl_ioctl()
1147 struct vfio_container *container; in vfio_fops_open() local
1149 container = kzalloc(sizeof(*container), GFP_KERNEL); in vfio_fops_open()
1150 if (!container) in vfio_fops_open()
1153 INIT_LIST_HEAD(&container->group_list); in vfio_fops_open()
1154 init_rwsem(&container->group_lock); in vfio_fops_open()
1155 kref_init(&container->kref); in vfio_fops_open()
1157 filep->private_data = container; in vfio_fops_open()
1164 struct vfio_container *container = filep->private_data; in vfio_fops_release() local
1165 struct vfio_iommu_driver *driver = container->iommu_driver; in vfio_fops_release()
1168 driver->ops->notify(container->iommu_data, in vfio_fops_release()
1173 vfio_container_put(container); in vfio_fops_release()
1191 struct vfio_container *container = group->container; in __vfio_group_unset_container() local
1194 down_write(&container->group_lock); in __vfio_group_unset_container()
1196 driver = container->iommu_driver; in __vfio_group_unset_container()
1198 driver->ops->detach_group(container->iommu_data, in __vfio_group_unset_container()
1201 group->container = NULL; in __vfio_group_unset_container()
1206 if (driver && list_empty(&container->group_list)) { in __vfio_group_unset_container()
1207 driver->ops->release(container->iommu_data); in __vfio_group_unset_container()
1209 container->iommu_driver = NULL; in __vfio_group_unset_container()
1210 container->iommu_data = NULL; in __vfio_group_unset_container()
1213 up_write(&container->group_lock); in __vfio_group_unset_container()
1215 vfio_container_put(container); in __vfio_group_unset_container()
1253 struct vfio_container *container; in vfio_group_set_container() local
1273 container = f.file->private_data; in vfio_group_set_container()
1274 WARN_ON(!container); /* fget ensures we don't race vfio_release */ in vfio_group_set_container()
1276 down_write(&container->group_lock); in vfio_group_set_container()
1279 if (!list_empty(&container->group_list) && in vfio_group_set_container()
1280 container->noiommu != (group->type == VFIO_NO_IOMMU)) { in vfio_group_set_container()
1285 driver = container->iommu_driver; in vfio_group_set_container()
1287 ret = driver->ops->attach_group(container->iommu_data, in vfio_group_set_container()
1294 group->container = container; in vfio_group_set_container()
1295 container->noiommu = (group->type == VFIO_NO_IOMMU); in vfio_group_set_container()
1296 list_add(&group->container_next, &container->group_list); in vfio_group_set_container()
1299 vfio_container_get(container); in vfio_group_set_container()
1303 up_write(&container->group_lock); in vfio_group_set_container()
1323 if (!group->container->iommu_driver || !vfio_group_viable(group)) { in vfio_group_add_container_user()
1341 !group->container->iommu_driver || !vfio_group_viable(group)) in vfio_group_get_device_fd()
1436 if (group->container) in vfio_group_fops_unl_ioctl()
1501 if (group->container) { in vfio_group_fops_open()
1724 return vfio_ioctl_check_extension(group->container, arg); in vfio_external_check_extension()
1860 struct vfio_container *container; in vfio_pin_pages() local
1884 container = group->container; in vfio_pin_pages()
1885 driver = container->iommu_driver; in vfio_pin_pages()
1887 ret = driver->ops->pin_pages(container->iommu_data, in vfio_pin_pages()
1912 struct vfio_container *container; in vfio_unpin_pages() local
1931 container = group->container; in vfio_unpin_pages()
1932 driver = container->iommu_driver; in vfio_unpin_pages()
1934 ret = driver->ops->unpin_pages(container->iommu_data, user_pfn, in vfio_unpin_pages()
1972 struct vfio_container *container; in vfio_group_pin_pages() local
1985 container = group->container; in vfio_group_pin_pages()
1986 driver = container->iommu_driver; in vfio_group_pin_pages()
1988 ret = driver->ops->pin_pages(container->iommu_data, in vfio_group_pin_pages()
2019 struct vfio_container *container; in vfio_group_unpin_pages() local
2029 container = group->container; in vfio_group_unpin_pages()
2030 driver = container->iommu_driver; in vfio_group_unpin_pages()
2032 ret = driver->ops->unpin_pages(container->iommu_data, in vfio_group_unpin_pages()
2070 struct vfio_container *container; in vfio_dma_rw() local
2077 container = group->container; in vfio_dma_rw()
2078 driver = container->iommu_driver; in vfio_dma_rw()
2081 ret = driver->ops->dma_rw(container->iommu_data, in vfio_dma_rw()
2094 struct vfio_container *container; in vfio_register_iommu_notifier() local
2102 container = group->container; in vfio_register_iommu_notifier()
2103 driver = container->iommu_driver; in vfio_register_iommu_notifier()
2105 ret = driver->ops->register_notifier(container->iommu_data, in vfio_register_iommu_notifier()
2118 struct vfio_container *container; in vfio_unregister_iommu_notifier() local
2126 container = group->container; in vfio_unregister_iommu_notifier()
2127 driver = container->iommu_driver; in vfio_unregister_iommu_notifier()
2129 ret = driver->ops->unregister_notifier(container->iommu_data, in vfio_unregister_iommu_notifier()
2259 struct vfio_container *container; in vfio_group_iommu_domain() local
2265 container = group->container; in vfio_group_iommu_domain()
2266 driver = container->iommu_driver; in vfio_group_iommu_domain()
2268 return driver->ops->group_iommu_domain(container->iommu_data, in vfio_group_iommu_domain()