Lines Matching refs:vdev

24 	struct vfio_fsl_mc_device *vdev =  in vfio_fsl_mc_open_device()  local
25 container_of(core_vdev, struct vfio_fsl_mc_device, vdev); in vfio_fsl_mc_open_device()
26 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_open_device()
30 vdev->regions = kcalloc(count, sizeof(struct vfio_fsl_mc_region), in vfio_fsl_mc_open_device()
32 if (!vdev->regions) in vfio_fsl_mc_open_device()
39 vdev->regions[i].addr = res->start; in vfio_fsl_mc_open_device()
40 vdev->regions[i].size = resource_size(res); in vfio_fsl_mc_open_device()
41 vdev->regions[i].type = mc_dev->regions[i].flags & IORESOURCE_BITS; in vfio_fsl_mc_open_device()
46 if (!no_mmap && !(vdev->regions[i].addr & ~PAGE_MASK) && in vfio_fsl_mc_open_device()
47 !(vdev->regions[i].size & ~PAGE_MASK)) in vfio_fsl_mc_open_device()
48 vdev->regions[i].flags |= in vfio_fsl_mc_open_device()
50 vdev->regions[i].flags |= VFIO_REGION_INFO_FLAG_READ; in vfio_fsl_mc_open_device()
52 vdev->regions[i].flags |= VFIO_REGION_INFO_FLAG_WRITE; in vfio_fsl_mc_open_device()
58 static void vfio_fsl_mc_regions_cleanup(struct vfio_fsl_mc_device *vdev) in vfio_fsl_mc_regions_cleanup() argument
60 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_regions_cleanup()
64 iounmap(vdev->regions[i].ioaddr); in vfio_fsl_mc_regions_cleanup()
65 kfree(vdev->regions); in vfio_fsl_mc_regions_cleanup()
68 static int vfio_fsl_mc_reset_device(struct vfio_fsl_mc_device *vdev) in vfio_fsl_mc_reset_device() argument
70 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_reset_device()
73 if (is_fsl_mc_bus_dprc(vdev->mc_dev)) { in vfio_fsl_mc_reset_device()
99 struct vfio_fsl_mc_device *vdev = in vfio_fsl_mc_close_device() local
100 container_of(core_vdev, struct vfio_fsl_mc_device, vdev); in vfio_fsl_mc_close_device()
101 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_close_device()
106 vfio_fsl_mc_regions_cleanup(vdev); in vfio_fsl_mc_close_device()
109 ret = vfio_fsl_mc_reset_device(vdev); in vfio_fsl_mc_close_device()
115 vfio_fsl_mc_irqs_cleanup(vdev); in vfio_fsl_mc_close_device()
124 struct vfio_fsl_mc_device *vdev = in vfio_fsl_mc_ioctl() local
125 container_of(core_vdev, struct vfio_fsl_mc_device, vdev); in vfio_fsl_mc_ioctl()
126 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_ioctl()
169 info.size = vdev->regions[info.index].size; in vfio_fsl_mc_ioctl()
170 info.flags = vdev->regions[info.index].flags; in vfio_fsl_mc_ioctl()
221 mutex_lock(&vdev->igate); in vfio_fsl_mc_ioctl()
222 ret = vfio_fsl_mc_set_irqs_ioctl(vdev, hdr.flags, in vfio_fsl_mc_ioctl()
225 mutex_unlock(&vdev->igate); in vfio_fsl_mc_ioctl()
232 return vfio_fsl_mc_reset_device(vdev); in vfio_fsl_mc_ioctl()
243 struct vfio_fsl_mc_device *vdev = in vfio_fsl_mc_read() local
244 container_of(core_vdev, struct vfio_fsl_mc_device, vdev); in vfio_fsl_mc_read()
247 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_read()
255 region = &vdev->regions[index]; in vfio_fsl_mc_read()
322 struct vfio_fsl_mc_device *vdev = in vfio_fsl_mc_write() local
323 container_of(core_vdev, struct vfio_fsl_mc_device, vdev); in vfio_fsl_mc_write()
326 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_write()
334 region = &vdev->regions[index]; in vfio_fsl_mc_write()
387 struct vfio_fsl_mc_device *vdev = in vfio_fsl_mc_mmap() local
388 container_of(core_vdev, struct vfio_fsl_mc_device, vdev); in vfio_fsl_mc_mmap()
389 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_mmap()
405 if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_MMAP)) in vfio_fsl_mc_mmap()
408 if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_READ) in vfio_fsl_mc_mmap()
412 if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_WRITE) in vfio_fsl_mc_mmap()
418 return vfio_fsl_mc_mmap_mmio(vdev->regions[index], vma); in vfio_fsl_mc_mmap()
425 struct vfio_fsl_mc_device *vdev = container_of(nb, in vfio_fsl_mc_bus_notifier() local
432 vdev->mc_dev == mc_cont) { in vfio_fsl_mc_bus_notifier()
442 vdev->mc_dev == mc_cont) { in vfio_fsl_mc_bus_notifier()
453 static int vfio_fsl_mc_init_device(struct vfio_fsl_mc_device *vdev) in vfio_fsl_mc_init_device() argument
455 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_init_device()
466 vdev->nb.notifier_call = vfio_fsl_mc_bus_notifier; in vfio_fsl_mc_init_device()
467 ret = bus_register_notifier(&fsl_mc_bus_type, &vdev->nb); in vfio_fsl_mc_init_device()
480 bus_unregister_notifier(&fsl_mc_bus_type, &vdev->nb); in vfio_fsl_mc_init_device()
501 static void vfio_fsl_uninit_device(struct vfio_fsl_mc_device *vdev) in vfio_fsl_uninit_device() argument
503 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_uninit_device()
509 bus_unregister_notifier(&fsl_mc_bus_type, &vdev->nb); in vfio_fsl_uninit_device()
514 struct vfio_fsl_mc_device *vdev = in vfio_fsl_mc_init_dev() local
515 container_of(core_vdev, struct vfio_fsl_mc_device, vdev); in vfio_fsl_mc_init_dev()
519 vdev->mc_dev = mc_dev; in vfio_fsl_mc_init_dev()
520 mutex_init(&vdev->igate); in vfio_fsl_mc_init_dev()
531 return vfio_fsl_mc_init_device(vdev); in vfio_fsl_mc_init_dev()
536 struct vfio_fsl_mc_device *vdev; in vfio_fsl_mc_probe() local
540 vdev = vfio_alloc_device(vfio_fsl_mc_device, vdev, dev, in vfio_fsl_mc_probe()
542 if (IS_ERR(vdev)) in vfio_fsl_mc_probe()
543 return PTR_ERR(vdev); in vfio_fsl_mc_probe()
545 ret = vfio_register_group_dev(&vdev->vdev); in vfio_fsl_mc_probe()
554 dev_set_drvdata(dev, vdev); in vfio_fsl_mc_probe()
558 vfio_unregister_group_dev(&vdev->vdev); in vfio_fsl_mc_probe()
560 vfio_put_device(&vdev->vdev); in vfio_fsl_mc_probe()
566 struct vfio_fsl_mc_device *vdev = in vfio_fsl_mc_release_dev() local
567 container_of(core_vdev, struct vfio_fsl_mc_device, vdev); in vfio_fsl_mc_release_dev()
569 vfio_fsl_uninit_device(vdev); in vfio_fsl_mc_release_dev()
570 mutex_destroy(&vdev->igate); in vfio_fsl_mc_release_dev()
577 struct vfio_fsl_mc_device *vdev = dev_get_drvdata(dev); in vfio_fsl_mc_remove() local
579 vfio_unregister_group_dev(&vdev->vdev); in vfio_fsl_mc_remove()
581 vfio_put_device(&vdev->vdev); in vfio_fsl_mc_remove()