Lines Matching refs:vdev

59 static int vfio_fsl_mc_reflck_attach(struct vfio_fsl_mc_device *vdev)  in vfio_fsl_mc_reflck_attach()  argument
64 if (is_fsl_mc_bus_dprc(vdev->mc_dev)) { in vfio_fsl_mc_reflck_attach()
65 vdev->reflck = vfio_fsl_mc_reflck_alloc(); in vfio_fsl_mc_reflck_attach()
66 ret = PTR_ERR_OR_ZERO(vdev->reflck); in vfio_fsl_mc_reflck_attach()
68 struct device *mc_cont_dev = vdev->mc_dev->dev.parent; in vfio_fsl_mc_reflck_attach()
85 vdev->reflck = cont_vdev->reflck; in vfio_fsl_mc_reflck_attach()
94 static int vfio_fsl_mc_regions_init(struct vfio_fsl_mc_device *vdev) in vfio_fsl_mc_regions_init() argument
96 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_regions_init()
100 vdev->regions = kcalloc(count, sizeof(struct vfio_fsl_mc_region), in vfio_fsl_mc_regions_init()
102 if (!vdev->regions) in vfio_fsl_mc_regions_init()
109 vdev->regions[i].addr = res->start; in vfio_fsl_mc_regions_init()
110 vdev->regions[i].size = resource_size(res); in vfio_fsl_mc_regions_init()
111 vdev->regions[i].type = mc_dev->regions[i].flags & IORESOURCE_BITS; in vfio_fsl_mc_regions_init()
116 if (!no_mmap && !(vdev->regions[i].addr & ~PAGE_MASK) && in vfio_fsl_mc_regions_init()
117 !(vdev->regions[i].size & ~PAGE_MASK)) in vfio_fsl_mc_regions_init()
118 vdev->regions[i].flags |= in vfio_fsl_mc_regions_init()
120 vdev->regions[i].flags |= VFIO_REGION_INFO_FLAG_READ; in vfio_fsl_mc_regions_init()
122 vdev->regions[i].flags |= VFIO_REGION_INFO_FLAG_WRITE; in vfio_fsl_mc_regions_init()
128 static void vfio_fsl_mc_regions_cleanup(struct vfio_fsl_mc_device *vdev) in vfio_fsl_mc_regions_cleanup() argument
130 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_regions_cleanup()
134 iounmap(vdev->regions[i].ioaddr); in vfio_fsl_mc_regions_cleanup()
135 kfree(vdev->regions); in vfio_fsl_mc_regions_cleanup()
140 struct vfio_fsl_mc_device *vdev = device_data; in vfio_fsl_mc_open() local
146 mutex_lock(&vdev->reflck->lock); in vfio_fsl_mc_open()
147 if (!vdev->refcnt) { in vfio_fsl_mc_open()
148 ret = vfio_fsl_mc_regions_init(vdev); in vfio_fsl_mc_open()
152 vdev->refcnt++; in vfio_fsl_mc_open()
154 mutex_unlock(&vdev->reflck->lock); in vfio_fsl_mc_open()
159 mutex_unlock(&vdev->reflck->lock); in vfio_fsl_mc_open()
166 struct vfio_fsl_mc_device *vdev = device_data; in vfio_fsl_mc_release() local
169 mutex_lock(&vdev->reflck->lock); in vfio_fsl_mc_release()
171 if (!(--vdev->refcnt)) { in vfio_fsl_mc_release()
172 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_release()
176 vfio_fsl_mc_regions_cleanup(vdev); in vfio_fsl_mc_release()
190 vfio_fsl_mc_irqs_cleanup(vdev); in vfio_fsl_mc_release()
195 mutex_unlock(&vdev->reflck->lock); in vfio_fsl_mc_release()
204 struct vfio_fsl_mc_device *vdev = device_data; in vfio_fsl_mc_ioctl() local
205 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_ioctl()
248 info.size = vdev->regions[info.index].size; in vfio_fsl_mc_ioctl()
249 info.flags = vdev->regions[info.index].flags; in vfio_fsl_mc_ioctl()
300 mutex_lock(&vdev->igate); in vfio_fsl_mc_ioctl()
301 ret = vfio_fsl_mc_set_irqs_ioctl(vdev, hdr.flags, in vfio_fsl_mc_ioctl()
304 mutex_unlock(&vdev->igate); in vfio_fsl_mc_ioctl()
312 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_ioctl()
333 struct vfio_fsl_mc_device *vdev = device_data; in vfio_fsl_mc_read() local
336 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_read()
344 region = &vdev->regions[index]; in vfio_fsl_mc_read()
410 struct vfio_fsl_mc_device *vdev = device_data; in vfio_fsl_mc_write() local
413 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_write()
421 region = &vdev->regions[index]; in vfio_fsl_mc_write()
473 struct vfio_fsl_mc_device *vdev = device_data; in vfio_fsl_mc_mmap() local
474 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_mmap()
490 if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_MMAP)) in vfio_fsl_mc_mmap()
493 if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_READ) in vfio_fsl_mc_mmap()
497 if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_WRITE) in vfio_fsl_mc_mmap()
503 return vfio_fsl_mc_mmap_mmio(vdev->regions[index], vma); in vfio_fsl_mc_mmap()
519 struct vfio_fsl_mc_device *vdev = container_of(nb, in vfio_fsl_mc_bus_notifier() local
526 vdev->mc_dev == mc_cont) { in vfio_fsl_mc_bus_notifier()
536 vdev->mc_dev == mc_cont) { in vfio_fsl_mc_bus_notifier()
547 static int vfio_fsl_mc_init_device(struct vfio_fsl_mc_device *vdev) in vfio_fsl_mc_init_device() argument
549 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_mc_init_device()
560 vdev->nb.notifier_call = vfio_fsl_mc_bus_notifier; in vfio_fsl_mc_init_device()
561 ret = bus_register_notifier(&fsl_mc_bus_type, &vdev->nb); in vfio_fsl_mc_init_device()
574 bus_unregister_notifier(&fsl_mc_bus_type, &vdev->nb); in vfio_fsl_mc_init_device()
595 static void vfio_fsl_uninit_device(struct vfio_fsl_mc_device *vdev) in vfio_fsl_uninit_device() argument
597 struct fsl_mc_device *mc_dev = vdev->mc_dev; in vfio_fsl_uninit_device()
603 bus_unregister_notifier(&fsl_mc_bus_type, &vdev->nb); in vfio_fsl_uninit_device()
609 struct vfio_fsl_mc_device *vdev; in vfio_fsl_mc_probe() local
619 vdev = devm_kzalloc(dev, sizeof(*vdev), GFP_KERNEL); in vfio_fsl_mc_probe()
620 if (!vdev) { in vfio_fsl_mc_probe()
625 vdev->mc_dev = mc_dev; in vfio_fsl_mc_probe()
626 mutex_init(&vdev->igate); in vfio_fsl_mc_probe()
628 ret = vfio_fsl_mc_reflck_attach(vdev); in vfio_fsl_mc_probe()
632 ret = vfio_fsl_mc_init_device(vdev); in vfio_fsl_mc_probe()
636 ret = vfio_add_group_dev(dev, &vfio_fsl_mc_ops, vdev); in vfio_fsl_mc_probe()
656 vfio_fsl_uninit_device(vdev); in vfio_fsl_mc_probe()
658 vfio_fsl_mc_reflck_put(vdev->reflck); in vfio_fsl_mc_probe()
666 struct vfio_fsl_mc_device *vdev; in vfio_fsl_mc_remove() local
669 vdev = vfio_del_group_dev(dev); in vfio_fsl_mc_remove()
670 if (!vdev) in vfio_fsl_mc_remove()
673 mutex_destroy(&vdev->igate); in vfio_fsl_mc_remove()
676 vfio_fsl_uninit_device(vdev); in vfio_fsl_mc_remove()
677 vfio_fsl_mc_reflck_put(vdev->reflck); in vfio_fsl_mc_remove()