Lines Matching refs:private
21 static int vfio_ccw_mdev_reset(struct vfio_ccw_private *private) in vfio_ccw_mdev_reset() argument
27 vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_CLOSE); in vfio_ccw_mdev_reset()
28 vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_OPEN); in vfio_ccw_mdev_reset()
29 if (private->state == VFIO_CCW_STATE_NOT_OPER) in vfio_ccw_mdev_reset()
37 struct vfio_ccw_private *private = in vfio_ccw_dma_unmap() local
41 if (!cp_iova_pinned(&private->cp, iova, length)) in vfio_ccw_dma_unmap()
44 vfio_ccw_mdev_reset(private); in vfio_ccw_dma_unmap()
49 struct vfio_ccw_private *private = in vfio_ccw_mdev_init_dev() local
52 mutex_init(&private->io_mutex); in vfio_ccw_mdev_init_dev()
53 private->state = VFIO_CCW_STATE_STANDBY; in vfio_ccw_mdev_init_dev()
54 INIT_LIST_HEAD(&private->crw); in vfio_ccw_mdev_init_dev()
55 INIT_WORK(&private->io_work, vfio_ccw_sch_io_todo); in vfio_ccw_mdev_init_dev()
56 INIT_WORK(&private->crw_work, vfio_ccw_crw_todo); in vfio_ccw_mdev_init_dev()
58 private->cp.guest_cp = kcalloc(CCWCHAIN_LEN_MAX, sizeof(struct ccw1), in vfio_ccw_mdev_init_dev()
60 if (!private->cp.guest_cp) in vfio_ccw_mdev_init_dev()
63 private->io_region = kmem_cache_zalloc(vfio_ccw_io_region, in vfio_ccw_mdev_init_dev()
65 if (!private->io_region) in vfio_ccw_mdev_init_dev()
68 private->cmd_region = kmem_cache_zalloc(vfio_ccw_cmd_region, in vfio_ccw_mdev_init_dev()
70 if (!private->cmd_region) in vfio_ccw_mdev_init_dev()
73 private->schib_region = kmem_cache_zalloc(vfio_ccw_schib_region, in vfio_ccw_mdev_init_dev()
75 if (!private->schib_region) in vfio_ccw_mdev_init_dev()
78 private->crw_region = kmem_cache_zalloc(vfio_ccw_crw_region, in vfio_ccw_mdev_init_dev()
80 if (!private->crw_region) in vfio_ccw_mdev_init_dev()
86 kmem_cache_free(vfio_ccw_schib_region, private->schib_region); in vfio_ccw_mdev_init_dev()
88 kmem_cache_free(vfio_ccw_cmd_region, private->cmd_region); in vfio_ccw_mdev_init_dev()
90 kmem_cache_free(vfio_ccw_io_region, private->io_region); in vfio_ccw_mdev_init_dev()
92 kfree(private->cp.guest_cp); in vfio_ccw_mdev_init_dev()
94 mutex_destroy(&private->io_mutex); in vfio_ccw_mdev_init_dev()
102 struct vfio_ccw_private *private; in vfio_ccw_mdev_probe() local
105 private = vfio_alloc_device(vfio_ccw_private, vdev, &mdev->dev, in vfio_ccw_mdev_probe()
107 if (IS_ERR(private)) in vfio_ccw_mdev_probe()
108 return PTR_ERR(private); in vfio_ccw_mdev_probe()
110 dev_set_drvdata(&parent->dev, private); in vfio_ccw_mdev_probe()
117 ret = vfio_register_emulated_iommu_dev(&private->vdev); in vfio_ccw_mdev_probe()
120 dev_set_drvdata(&mdev->dev, private); in vfio_ccw_mdev_probe()
125 vfio_put_device(&private->vdev); in vfio_ccw_mdev_probe()
131 struct vfio_ccw_private *private = in vfio_ccw_mdev_release_dev() local
135 list_for_each_entry_safe(crw, temp, &private->crw, next) { in vfio_ccw_mdev_release_dev()
140 kmem_cache_free(vfio_ccw_crw_region, private->crw_region); in vfio_ccw_mdev_release_dev()
141 kmem_cache_free(vfio_ccw_schib_region, private->schib_region); in vfio_ccw_mdev_release_dev()
142 kmem_cache_free(vfio_ccw_cmd_region, private->cmd_region); in vfio_ccw_mdev_release_dev()
143 kmem_cache_free(vfio_ccw_io_region, private->io_region); in vfio_ccw_mdev_release_dev()
144 kfree(private->cp.guest_cp); in vfio_ccw_mdev_release_dev()
145 mutex_destroy(&private->io_mutex); in vfio_ccw_mdev_release_dev()
152 struct vfio_ccw_private *private = dev_get_drvdata(&parent->dev); in vfio_ccw_mdev_remove() local
159 vfio_unregister_group_dev(&private->vdev); in vfio_ccw_mdev_remove()
162 vfio_put_device(&private->vdev); in vfio_ccw_mdev_remove()
167 struct vfio_ccw_private *private = in vfio_ccw_mdev_open_device() local
172 if (private->state == VFIO_CCW_STATE_NOT_OPER) in vfio_ccw_mdev_open_device()
175 ret = vfio_ccw_register_async_dev_regions(private); in vfio_ccw_mdev_open_device()
179 ret = vfio_ccw_register_schib_dev_regions(private); in vfio_ccw_mdev_open_device()
183 ret = vfio_ccw_register_crw_dev_regions(private); in vfio_ccw_mdev_open_device()
187 vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_OPEN); in vfio_ccw_mdev_open_device()
188 if (private->state == VFIO_CCW_STATE_NOT_OPER) { in vfio_ccw_mdev_open_device()
196 vfio_ccw_unregister_dev_regions(private); in vfio_ccw_mdev_open_device()
202 struct vfio_ccw_private *private = in vfio_ccw_mdev_close_device() local
205 vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_CLOSE); in vfio_ccw_mdev_close_device()
206 vfio_ccw_unregister_dev_regions(private); in vfio_ccw_mdev_close_device()
209 static ssize_t vfio_ccw_mdev_read_io_region(struct vfio_ccw_private *private, in vfio_ccw_mdev_read_io_region() argument
220 mutex_lock(&private->io_mutex); in vfio_ccw_mdev_read_io_region()
221 region = private->io_region; in vfio_ccw_mdev_read_io_region()
226 mutex_unlock(&private->io_mutex); in vfio_ccw_mdev_read_io_region()
235 struct vfio_ccw_private *private = in vfio_ccw_mdev_read() local
239 if (index >= VFIO_CCW_NUM_REGIONS + private->num_regions) in vfio_ccw_mdev_read()
244 return vfio_ccw_mdev_read_io_region(private, buf, count, ppos); in vfio_ccw_mdev_read()
247 return private->region[index].ops->read(private, buf, count, in vfio_ccw_mdev_read()
254 static ssize_t vfio_ccw_mdev_write_io_region(struct vfio_ccw_private *private, in vfio_ccw_mdev_write_io_region() argument
265 if (!mutex_trylock(&private->io_mutex)) in vfio_ccw_mdev_write_io_region()
268 region = private->io_region; in vfio_ccw_mdev_write_io_region()
274 vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_IO_REQ); in vfio_ccw_mdev_write_io_region()
278 mutex_unlock(&private->io_mutex); in vfio_ccw_mdev_write_io_region()
287 struct vfio_ccw_private *private = in vfio_ccw_mdev_write() local
291 if (index >= VFIO_CCW_NUM_REGIONS + private->num_regions) in vfio_ccw_mdev_write()
296 return vfio_ccw_mdev_write_io_region(private, buf, count, ppos); in vfio_ccw_mdev_write()
299 return private->region[index].ops->write(private, buf, count, in vfio_ccw_mdev_write()
306 static int vfio_ccw_mdev_get_device_info(struct vfio_ccw_private *private, in vfio_ccw_mdev_get_device_info() argument
310 info->num_regions = VFIO_CCW_NUM_REGIONS + private->num_regions; in vfio_ccw_mdev_get_device_info()
316 static int vfio_ccw_mdev_get_region_info(struct vfio_ccw_private *private, in vfio_ccw_mdev_get_region_info() argument
338 VFIO_CCW_NUM_REGIONS + private->num_regions) in vfio_ccw_mdev_get_region_info()
343 private->num_regions); in vfio_ccw_mdev_get_region_info()
348 info->size = private->region[i].size; in vfio_ccw_mdev_get_region_info()
349 info->flags = private->region[i].flags; in vfio_ccw_mdev_get_region_info()
351 cap_type.type = private->region[i].type; in vfio_ccw_mdev_get_region_info()
352 cap_type.subtype = private->region[i].subtype; in vfio_ccw_mdev_get_region_info()
396 static int vfio_ccw_mdev_set_irqs(struct vfio_ccw_private *private, in vfio_ccw_mdev_set_irqs() argument
408 ctx = &private->io_trigger; in vfio_ccw_mdev_set_irqs()
411 ctx = &private->crw_trigger; in vfio_ccw_mdev_set_irqs()
414 ctx = &private->req_trigger; in vfio_ccw_mdev_set_irqs()
470 int vfio_ccw_register_dev_region(struct vfio_ccw_private *private, in vfio_ccw_register_dev_region() argument
477 region = krealloc(private->region, in vfio_ccw_register_dev_region()
478 (private->num_regions + 1) * sizeof(*region), in vfio_ccw_register_dev_region()
483 private->region = region; in vfio_ccw_register_dev_region()
484 private->region[private->num_regions].type = VFIO_REGION_TYPE_CCW; in vfio_ccw_register_dev_region()
485 private->region[private->num_regions].subtype = subtype; in vfio_ccw_register_dev_region()
486 private->region[private->num_regions].ops = ops; in vfio_ccw_register_dev_region()
487 private->region[private->num_regions].size = size; in vfio_ccw_register_dev_region()
488 private->region[private->num_regions].flags = flags; in vfio_ccw_register_dev_region()
489 private->region[private->num_regions].data = data; in vfio_ccw_register_dev_region()
491 private->num_regions++; in vfio_ccw_register_dev_region()
496 void vfio_ccw_unregister_dev_regions(struct vfio_ccw_private *private) in vfio_ccw_unregister_dev_regions() argument
500 for (i = 0; i < private->num_regions; i++) in vfio_ccw_unregister_dev_regions()
501 private->region[i].ops->release(private, &private->region[i]); in vfio_ccw_unregister_dev_regions()
502 private->num_regions = 0; in vfio_ccw_unregister_dev_regions()
503 kfree(private->region); in vfio_ccw_unregister_dev_regions()
504 private->region = NULL; in vfio_ccw_unregister_dev_regions()
511 struct vfio_ccw_private *private = in vfio_ccw_mdev_ioctl() local
529 ret = vfio_ccw_mdev_get_device_info(private, &info); in vfio_ccw_mdev_ioctl()
547 ret = vfio_ccw_mdev_get_region_info(private, &info, arg); in vfio_ccw_mdev_ioctl()
592 return vfio_ccw_mdev_set_irqs(private, hdr.flags, hdr.index, in vfio_ccw_mdev_ioctl()
596 return vfio_ccw_mdev_reset(private); in vfio_ccw_mdev_ioctl()
605 struct vfio_ccw_private *private = in vfio_ccw_mdev_request() local
609 if (private->req_trigger) { in vfio_ccw_mdev_request()
615 eventfd_signal(private->req_trigger, 1); in vfio_ccw_mdev_request()