Lines Matching refs:vdev

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