Lines Matching full:vdev
24 static int vfio_cdx_msi_enable(struct vfio_cdx_device *vdev, int nvec) in vfio_cdx_msi_enable() argument
26 struct cdx_device *cdx_dev = to_cdx_device(vdev->vdev.dev); in vfio_cdx_msi_enable()
27 struct device *dev = vdev->vdev.dev; in vfio_cdx_msi_enable()
30 vdev->cdx_irqs = kcalloc(nvec, sizeof(struct vfio_cdx_irq), GFP_KERNEL); in vfio_cdx_msi_enable()
31 if (!vdev->cdx_irqs) in vfio_cdx_msi_enable()
36 kfree(vdev->cdx_irqs); in vfio_cdx_msi_enable()
44 kfree(vdev->cdx_irqs); in vfio_cdx_msi_enable()
49 vdev->cdx_irqs[msi_idx].irq_no = msi_get_virq(dev, msi_idx); in vfio_cdx_msi_enable()
51 vdev->msi_count = nvec; in vfio_cdx_msi_enable()
52 vdev->config_msi = 1; in vfio_cdx_msi_enable()
57 static int vfio_cdx_msi_set_vector_signal(struct vfio_cdx_device *vdev, in vfio_cdx_msi_set_vector_signal() argument
63 if (vector < 0 || vector >= vdev->msi_count) in vfio_cdx_msi_set_vector_signal()
66 irq_no = vdev->cdx_irqs[vector].irq_no; in vfio_cdx_msi_set_vector_signal()
68 if (vdev->cdx_irqs[vector].trigger) { in vfio_cdx_msi_set_vector_signal()
69 free_irq(irq_no, vdev->cdx_irqs[vector].trigger); in vfio_cdx_msi_set_vector_signal()
70 kfree(vdev->cdx_irqs[vector].name); in vfio_cdx_msi_set_vector_signal()
71 eventfd_ctx_put(vdev->cdx_irqs[vector].trigger); in vfio_cdx_msi_set_vector_signal()
72 vdev->cdx_irqs[vector].trigger = NULL; in vfio_cdx_msi_set_vector_signal()
78 vdev->cdx_irqs[vector].name = kasprintf(GFP_KERNEL, "vfio-msi[%d](%s)", in vfio_cdx_msi_set_vector_signal()
79 vector, dev_name(vdev->vdev.dev)); in vfio_cdx_msi_set_vector_signal()
80 if (!vdev->cdx_irqs[vector].name) in vfio_cdx_msi_set_vector_signal()
85 kfree(vdev->cdx_irqs[vector].name); in vfio_cdx_msi_set_vector_signal()
90 vdev->cdx_irqs[vector].name, trigger); in vfio_cdx_msi_set_vector_signal()
92 kfree(vdev->cdx_irqs[vector].name); in vfio_cdx_msi_set_vector_signal()
97 vdev->cdx_irqs[vector].trigger = trigger; in vfio_cdx_msi_set_vector_signal()
102 static int vfio_cdx_msi_set_block(struct vfio_cdx_device *vdev, in vfio_cdx_msi_set_block() argument
108 if (start >= vdev->msi_count || start + count > vdev->msi_count) in vfio_cdx_msi_set_block()
114 ret = vfio_cdx_msi_set_vector_signal(vdev, j, fd); in vfio_cdx_msi_set_block()
119 vfio_cdx_msi_set_vector_signal(vdev, j, -1); in vfio_cdx_msi_set_block()
125 static void vfio_cdx_msi_disable(struct vfio_cdx_device *vdev) in vfio_cdx_msi_disable() argument
127 struct cdx_device *cdx_dev = to_cdx_device(vdev->vdev.dev); in vfio_cdx_msi_disable()
128 struct device *dev = vdev->vdev.dev; in vfio_cdx_msi_disable()
130 vfio_cdx_msi_set_block(vdev, 0, vdev->msi_count, NULL); in vfio_cdx_msi_disable()
132 if (!vdev->config_msi) in vfio_cdx_msi_disable()
137 kfree(vdev->cdx_irqs); in vfio_cdx_msi_disable()
139 vdev->cdx_irqs = NULL; in vfio_cdx_msi_disable()
140 vdev->msi_count = 0; in vfio_cdx_msi_disable()
141 vdev->config_msi = 0; in vfio_cdx_msi_disable()
144 static int vfio_cdx_set_msi_trigger(struct vfio_cdx_device *vdev, in vfio_cdx_set_msi_trigger() argument
149 struct cdx_device *cdx_dev = to_cdx_device(vdev->vdev.dev); in vfio_cdx_set_msi_trigger()
156 vfio_cdx_msi_disable(vdev); in vfio_cdx_set_msi_trigger()
164 if (vdev->config_msi) in vfio_cdx_set_msi_trigger()
165 return vfio_cdx_msi_set_block(vdev, start, count, in vfio_cdx_set_msi_trigger()
167 ret = vfio_cdx_msi_enable(vdev, cdx_dev->num_msi); in vfio_cdx_set_msi_trigger()
171 ret = vfio_cdx_msi_set_block(vdev, start, count, fds); in vfio_cdx_set_msi_trigger()
173 vfio_cdx_msi_disable(vdev); in vfio_cdx_set_msi_trigger()
179 if (!vdev->cdx_irqs[i].trigger) in vfio_cdx_set_msi_trigger()
182 eventfd_signal(vdev->cdx_irqs[i].trigger); in vfio_cdx_set_msi_trigger()
187 eventfd_signal(vdev->cdx_irqs[i].trigger); in vfio_cdx_set_msi_trigger()
194 int vfio_cdx_set_irqs_ioctl(struct vfio_cdx_device *vdev, in vfio_cdx_set_irqs_ioctl() argument
200 return vfio_cdx_set_msi_trigger(vdev, index, start, in vfio_cdx_set_irqs_ioctl()
207 void vfio_cdx_irqs_cleanup(struct vfio_cdx_device *vdev) in vfio_cdx_irqs_cleanup() argument
213 if (!vdev->cdx_irqs) in vfio_cdx_irqs_cleanup()
216 vfio_cdx_set_msi_trigger(vdev, 0, 0, 0, VFIO_IRQ_SET_DATA_NONE, NULL); in vfio_cdx_irqs_cleanup()