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()
71 struct vfio_fsl_mc_device *vdev = in vfio_fsl_mc_close_device() local
72 container_of(core_vdev, struct vfio_fsl_mc_device, vdev); in vfio_fsl_mc_close_device()
73 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_close_device()
78 vfio_fsl_mc_regions_cleanup(vdev); in vfio_fsl_mc_close_device()
89 vfio_fsl_mc_irqs_cleanup(vdev); in vfio_fsl_mc_close_device()
98 struct vfio_fsl_mc_device *vdev = in vfio_fsl_mc_ioctl() local
99 container_of(core_vdev, struct vfio_fsl_mc_device, vdev); in vfio_fsl_mc_ioctl()
100 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_ioctl()
143 info.size = vdev->regions[info.index].size; in vfio_fsl_mc_ioctl()
144 info.flags = vdev->regions[info.index].flags; in vfio_fsl_mc_ioctl()
195 mutex_lock(&vdev->igate); in vfio_fsl_mc_ioctl()
196 ret = vfio_fsl_mc_set_irqs_ioctl(vdev, hdr.flags, in vfio_fsl_mc_ioctl()
199 mutex_unlock(&vdev->igate); in vfio_fsl_mc_ioctl()
207 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_ioctl()
228 struct vfio_fsl_mc_device *vdev = in vfio_fsl_mc_read() local
229 container_of(core_vdev, struct vfio_fsl_mc_device, vdev); in vfio_fsl_mc_read()
232 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_read()
240 region = &vdev->regions[index]; in vfio_fsl_mc_read()
307 struct vfio_fsl_mc_device *vdev = in vfio_fsl_mc_write() local
308 container_of(core_vdev, struct vfio_fsl_mc_device, vdev); in vfio_fsl_mc_write()
311 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_write()
319 region = &vdev->regions[index]; in vfio_fsl_mc_write()
372 struct vfio_fsl_mc_device *vdev = in vfio_fsl_mc_mmap() local
373 container_of(core_vdev, struct vfio_fsl_mc_device, vdev); in vfio_fsl_mc_mmap()
374 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_mmap()
390 if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_MMAP)) in vfio_fsl_mc_mmap()
393 if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_READ) in vfio_fsl_mc_mmap()
397 if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_WRITE) in vfio_fsl_mc_mmap()
403 return vfio_fsl_mc_mmap_mmio(vdev->regions[index], vma); in vfio_fsl_mc_mmap()
419 struct vfio_fsl_mc_device *vdev = container_of(nb, in vfio_fsl_mc_bus_notifier() local
426 vdev->mc_dev == mc_cont) { in vfio_fsl_mc_bus_notifier()
436 vdev->mc_dev == mc_cont) { in vfio_fsl_mc_bus_notifier()
447 static int vfio_fsl_mc_init_device(struct vfio_fsl_mc_device *vdev) in vfio_fsl_mc_init_device() argument
449 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_init_device()
460 vdev->nb.notifier_call = vfio_fsl_mc_bus_notifier; in vfio_fsl_mc_init_device()
461 ret = bus_register_notifier(&fsl_mc_bus_type, &vdev->nb); in vfio_fsl_mc_init_device()
474 bus_unregister_notifier(&fsl_mc_bus_type, &vdev->nb); in vfio_fsl_mc_init_device()
495 static void vfio_fsl_uninit_device(struct vfio_fsl_mc_device *vdev) in vfio_fsl_uninit_device() argument
497 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_uninit_device()
503 bus_unregister_notifier(&fsl_mc_bus_type, &vdev->nb); in vfio_fsl_uninit_device()
509 struct vfio_fsl_mc_device *vdev; in vfio_fsl_mc_probe() local
519 vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); in vfio_fsl_mc_probe()
520 if (!vdev) { in vfio_fsl_mc_probe()
525 vfio_init_group_dev(&vdev->vdev, dev, &vfio_fsl_mc_ops); in vfio_fsl_mc_probe()
526 vdev->mc_dev = mc_dev; in vfio_fsl_mc_probe()
527 mutex_init(&vdev->igate); in vfio_fsl_mc_probe()
530 ret = vfio_assign_device_set(&vdev->vdev, &mc_dev->dev); in vfio_fsl_mc_probe()
532 ret = vfio_assign_device_set(&vdev->vdev, mc_dev->dev.parent); in vfio_fsl_mc_probe()
536 ret = vfio_fsl_mc_init_device(vdev); in vfio_fsl_mc_probe()
540 ret = vfio_register_group_dev(&vdev->vdev); in vfio_fsl_mc_probe()
549 dev_set_drvdata(dev, vdev); in vfio_fsl_mc_probe()
553 vfio_unregister_group_dev(&vdev->vdev); in vfio_fsl_mc_probe()
555 vfio_fsl_uninit_device(vdev); in vfio_fsl_mc_probe()
557 vfio_uninit_group_dev(&vdev->vdev); in vfio_fsl_mc_probe()
558 kfree(vdev); in vfio_fsl_mc_probe()
567 struct vfio_fsl_mc_device *vdev = dev_get_drvdata(dev); in vfio_fsl_mc_remove() local
569 vfio_unregister_group_dev(&vdev->vdev); in vfio_fsl_mc_remove()
570 mutex_destroy(&vdev->igate); in vfio_fsl_mc_remove()
573 vfio_fsl_uninit_device(vdev); in vfio_fsl_mc_remove()
575 vfio_uninit_group_dev(&vdev->vdev); in vfio_fsl_mc_remove()
576 kfree(vdev); in vfio_fsl_mc_remove()