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()
434 struct vfio_fsl_mc_device *vdev = container_of(nb, in vfio_fsl_mc_bus_notifier() local
441 vdev->mc_dev == mc_cont) { in vfio_fsl_mc_bus_notifier()
451 vdev->mc_dev == mc_cont) { in vfio_fsl_mc_bus_notifier()
462 static int vfio_fsl_mc_init_device(struct vfio_fsl_mc_device *vdev) in vfio_fsl_mc_init_device() argument
464 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_init_device()
475 vdev->nb.notifier_call = vfio_fsl_mc_bus_notifier; in vfio_fsl_mc_init_device()
476 ret = bus_register_notifier(&fsl_mc_bus_type, &vdev->nb); in vfio_fsl_mc_init_device()
489 bus_unregister_notifier(&fsl_mc_bus_type, &vdev->nb); in vfio_fsl_mc_init_device()
510 static void vfio_fsl_uninit_device(struct vfio_fsl_mc_device *vdev) in vfio_fsl_uninit_device() argument
512 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_uninit_device()
518 bus_unregister_notifier(&fsl_mc_bus_type, &vdev->nb); in vfio_fsl_uninit_device()
523 struct vfio_fsl_mc_device *vdev; in vfio_fsl_mc_probe() local
527 vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); in vfio_fsl_mc_probe()
528 if (!vdev) in vfio_fsl_mc_probe()
531 vfio_init_group_dev(&vdev->vdev, dev, &vfio_fsl_mc_ops); in vfio_fsl_mc_probe()
532 vdev->mc_dev = mc_dev; in vfio_fsl_mc_probe()
533 mutex_init(&vdev->igate); in vfio_fsl_mc_probe()
536 ret = vfio_assign_device_set(&vdev->vdev, &mc_dev->dev); in vfio_fsl_mc_probe()
538 ret = vfio_assign_device_set(&vdev->vdev, mc_dev->dev.parent); in vfio_fsl_mc_probe()
542 ret = vfio_fsl_mc_init_device(vdev); in vfio_fsl_mc_probe()
546 ret = vfio_register_group_dev(&vdev->vdev); in vfio_fsl_mc_probe()
555 dev_set_drvdata(dev, vdev); in vfio_fsl_mc_probe()
559 vfio_unregister_group_dev(&vdev->vdev); in vfio_fsl_mc_probe()
561 vfio_fsl_uninit_device(vdev); in vfio_fsl_mc_probe()
563 vfio_uninit_group_dev(&vdev->vdev); in vfio_fsl_mc_probe()
564 kfree(vdev); in vfio_fsl_mc_probe()
571 struct vfio_fsl_mc_device *vdev = dev_get_drvdata(dev); in vfio_fsl_mc_remove() local
573 vfio_unregister_group_dev(&vdev->vdev); in vfio_fsl_mc_remove()
574 mutex_destroy(&vdev->igate); in vfio_fsl_mc_remove()
577 vfio_fsl_uninit_device(vdev); in vfio_fsl_mc_remove()
579 vfio_uninit_group_dev(&vdev->vdev); in vfio_fsl_mc_remove()
580 kfree(vdev); in vfio_fsl_mc_remove()