Lines Matching defs:device

29 	struct vfio_device *it, *device = ERR_PTR(-ENODEV);
38 device = ERR_PTR(ret);
46 device = it;
52 return device;
160 static void vfio_device_group_get_kvm_safe(struct vfio_device *device)
162 spin_lock(&device->group->kvm_ref_lock);
163 vfio_device_get_kvm_safe(device, device->group->kvm);
164 spin_unlock(&device->group->kvm_ref_lock);
169 struct vfio_device *device = df->device;
172 mutex_lock(&device->group->group_lock);
173 if (!vfio_group_has_iommu(device->group)) {
178 mutex_lock(&device->dev_set->lock);
181 * Before the first device open, get the KVM pointer currently
184 * the pointer in the device for use by drivers.
186 if (device->open_count == 0)
187 vfio_device_group_get_kvm_safe(device);
189 df->iommufd = device->group->iommufd;
190 if (df->iommufd && vfio_device_is_noiommu(device) && device->open_count == 0) {
197 vfio_iommufd_device_has_compat_ioas(device, df->iommufd))
208 if (df->iommufd && device->open_count == 1) {
209 ret = vfio_iommufd_compat_attach_ioas(device, df->iommufd);
220 mutex_unlock(&device->dev_set->lock);
221 mutex_unlock(&device->group->group_lock);
228 if (device->open_count == 0)
229 vfio_device_put_kvm(device);
230 mutex_unlock(&device->dev_set->lock);
232 mutex_unlock(&device->group->group_lock);
238 struct vfio_device *device = df->device;
240 mutex_lock(&device->group->group_lock);
241 mutex_lock(&device->dev_set->lock);
246 if (device->open_count == 0)
247 vfio_device_put_kvm(device);
249 mutex_unlock(&device->dev_set->lock);
250 mutex_unlock(&device->group->group_lock);
253 static struct file *vfio_device_open_file(struct vfio_device *device)
259 df = vfio_allocate_device_file(device);
265 df->group = device->group;
275 filep = anon_inode_getfile("[vfio-device]", &vfio_device_fops,
289 if (device->group->type == VFIO_NO_IOMMU)
290 dev_warn(device->dev, "vfio-noiommu device opened by user "
293 * On success the ref of device is moved to the file and
309 struct vfio_device *device;
319 device = vfio_device_get_from_name(group, buf);
321 if (IS_ERR(device))
322 return PTR_ERR(device);
330 filep = vfio_device_open_file(device);
342 vfio_device_put_registration(device);
405 int vfio_device_block_group(struct vfio_device *device)
407 struct vfio_group *group = device->group;
423 void vfio_device_unblock_group(struct vfio_device *device)
425 struct vfio_group *group = device->group;
526 static void vfio_group_release(struct device *dev)
611 static struct vfio_group *vfio_noiommu_group_alloc(struct device *dev,
646 static bool vfio_group_has_device(struct vfio_group *group, struct device *dev)
648 struct vfio_device *device;
651 list_for_each_entry(device, &group->device_list, group_next) {
652 if (device->dev == dev) {
661 static struct vfio_group *vfio_group_find_or_alloc(struct device *dev)
672 * capable device to a user without IOMMU protection.
677 dev_warn(dev, "Adding kernel taint for vfio-noiommu group on device\n");
702 int vfio_device_set_group(struct vfio_device *device,
708 group = vfio_group_find_or_alloc(device->dev);
710 group = vfio_noiommu_group_alloc(device->dev, type);
715 /* Our reference on group is moved to the device */
716 device->group = group;
720 void vfio_device_remove_group(struct vfio_device *device)
722 struct vfio_group *group = device->group;
726 iommu_group_remove_device(device->dev);
744 * undone when the caller holds a live reference on the device. Since
767 void vfio_device_group_register(struct vfio_device *device)
769 mutex_lock(&device->group->device_lock);
770 list_add(&device->group_next, &device->group->device_list);
771 mutex_unlock(&device->group->device_lock);
774 void vfio_device_group_unregister(struct vfio_device *device)
776 mutex_lock(&device->group->device_lock);
777 list_del(&device->group_next);
778 mutex_unlock(&device->group->device_lock);
781 int vfio_device_group_use_iommu(struct vfio_device *device)
783 struct vfio_group *group = device->group;
794 vfio_device_container_register(device);
798 void vfio_device_group_unuse_iommu(struct vfio_device *device)
800 struct vfio_group *group = device->group;
807 vfio_device_container_unregister(device);
811 bool vfio_device_has_container(struct vfio_device *device)
813 return device->group->container;
866 struct vfio_device *device;
870 * If the device does not have IOMMU_CAP_ENFORCE_CACHE_COHERENCY then
872 * is set then the iommu_domain eventually attached to the device/group
876 list_for_each_entry(device, &group->device_list, group_next) {
877 if (!device_iommu_capable(device->dev,
895 * vfio_file_has_dev - True if the VFIO file is a handle for device
897 * @device: Device that must be part of the file
899 * Returns true if given file has permission to manipulate the given device.
901 bool vfio_file_has_dev(struct file *file, struct vfio_device *device)
908 return group == device->group;
912 static char *vfio_devnode(const struct device *dev, umode_t *mode)