Lines Matching full:intp
45 static inline bool vfio_irq_is_automasked(VFIOINTp *intp) in vfio_irq_is_automasked() argument
47 return intp->flags & VFIO_IRQ_INFO_AUTOMASKED; in vfio_irq_is_automasked()
64 VFIOINTp *intp; in vfio_init_intp() local
66 intp = g_malloc0(sizeof(*intp)); in vfio_init_intp()
67 intp->vdev = vdev; in vfio_init_intp()
68 intp->pin = info.index; in vfio_init_intp()
69 intp->flags = info.flags; in vfio_init_intp()
70 intp->state = VFIO_IRQ_INACTIVE; in vfio_init_intp()
71 intp->kvm_accel = false; in vfio_init_intp()
73 sysbus_init_irq(sbdev, &intp->qemuirq); in vfio_init_intp()
76 intp->interrupt = g_new0(EventNotifier, 1); in vfio_init_intp()
77 ret = event_notifier_init(intp->interrupt, 0); in vfio_init_intp()
79 g_free(intp->interrupt); in vfio_init_intp()
80 g_free(intp); in vfio_init_intp()
85 if (vfio_irq_is_automasked(intp)) { in vfio_init_intp()
87 intp->unmask = g_new0(EventNotifier, 1); in vfio_init_intp()
88 ret = event_notifier_init(intp->unmask, 0); in vfio_init_intp()
90 g_free(intp->interrupt); in vfio_init_intp()
91 g_free(intp->unmask); in vfio_init_intp()
92 g_free(intp); in vfio_init_intp()
99 QLIST_INSERT_HEAD(&vdev->intp_list, intp, next); in vfio_init_intp()
100 return intp; in vfio_init_intp()
106 * @intp: IRQ struct handle
112 static int vfio_set_trigger_eventfd(VFIOINTp *intp, in vfio_set_trigger_eventfd() argument
115 VFIODevice *vbasedev = &intp->vdev->vbasedev; in vfio_set_trigger_eventfd()
116 int32_t fd = event_notifier_get_fd(intp->interrupt); in vfio_set_trigger_eventfd()
119 qemu_set_fd_handler(fd, (IOHandler *)handler, NULL, intp); in vfio_set_trigger_eventfd()
121 if (!vfio_set_irq_signaling(vbasedev, intp->pin, 0, in vfio_set_trigger_eventfd()
193 static void vfio_intp_inject_pending_lockheld(VFIOINTp *intp) in vfio_intp_inject_pending_lockheld() argument
195 trace_vfio_platform_intp_inject_pending_lockheld(intp->pin, in vfio_intp_inject_pending_lockheld()
196 event_notifier_get_fd(intp->interrupt)); in vfio_intp_inject_pending_lockheld()
198 intp->state = VFIO_IRQ_ACTIVE; in vfio_intp_inject_pending_lockheld()
201 qemu_set_irq(intp->qemuirq, 1); in vfio_intp_inject_pending_lockheld()
212 static void vfio_intp_interrupt(VFIOINTp *intp) in vfio_intp_interrupt() argument
216 VFIOPlatformDevice *vdev = intp->vdev; in vfio_intp_interrupt()
220 if (intp->state == VFIO_IRQ_INACTIVE) { in vfio_intp_interrupt()
234 intp->state = VFIO_IRQ_PENDING; in vfio_intp_interrupt()
235 trace_vfio_intp_interrupt_set_pending(intp->pin); in vfio_intp_interrupt()
237 intp, pqnext); in vfio_intp_interrupt()
238 event_notifier_test_and_clear(intp->interrupt); in vfio_intp_interrupt()
242 trace_vfio_platform_intp_interrupt(intp->pin, in vfio_intp_interrupt()
243 event_notifier_get_fd(intp->interrupt)); in vfio_intp_interrupt()
245 ret = event_notifier_test_and_clear(intp->interrupt); in vfio_intp_interrupt()
248 event_notifier_get_fd(intp->interrupt), ret); in vfio_intp_interrupt()
251 intp->state = VFIO_IRQ_ACTIVE; in vfio_intp_interrupt()
257 qemu_set_irq(intp->qemuirq, 1); in vfio_intp_interrupt()
287 VFIOINTp *intp; in vfio_platform_eoi() local
292 QLIST_FOREACH(intp, &vdev->intp_list, next) { in vfio_platform_eoi()
293 if (intp->state == VFIO_IRQ_ACTIVE) { in vfio_platform_eoi()
294 trace_vfio_platform_eoi(intp->pin, in vfio_platform_eoi()
295 event_notifier_get_fd(intp->interrupt)); in vfio_platform_eoi()
296 intp->state = VFIO_IRQ_INACTIVE; in vfio_platform_eoi()
299 qemu_set_irq(intp->qemuirq, 0); in vfio_platform_eoi()
301 if (vfio_irq_is_automasked(intp)) { in vfio_platform_eoi()
303 vfio_unmask_single_irqindex(vbasedev, intp->pin); in vfio_platform_eoi()
312 intp = QSIMPLEQ_FIRST(&vdev->pending_intp_queue); in vfio_platform_eoi()
313 vfio_intp_inject_pending_lockheld(intp); in vfio_platform_eoi()
328 VFIOINTp *intp; in vfio_start_eventfd_injection() local
330 QLIST_FOREACH(intp, &vdev->intp_list, next) { in vfio_start_eventfd_injection()
331 if (intp->qemuirq == irq) { in vfio_start_eventfd_injection()
335 assert(intp); in vfio_start_eventfd_injection()
337 if (vfio_set_trigger_eventfd(intp, vfio_intp_interrupt)) { in vfio_start_eventfd_injection()
348 * @intp: the IRQ struct handle
350 * intp->unmask eventfd is triggered
352 static int vfio_set_resample_eventfd(VFIOINTp *intp) in vfio_set_resample_eventfd() argument
354 int32_t fd = event_notifier_get_fd(intp->unmask); in vfio_set_resample_eventfd()
355 VFIODevice *vbasedev = &intp->vdev->vbasedev; in vfio_set_resample_eventfd()
359 if (!vfio_set_irq_signaling(vbasedev, intp->pin, 0, in vfio_set_resample_eventfd()
379 VFIOINTp *intp; in vfio_start_irqfd_injection() local
386 QLIST_FOREACH(intp, &vdev->intp_list, next) { in vfio_start_irqfd_injection()
387 if (intp->qemuirq == irq) { in vfio_start_irqfd_injection()
391 assert(intp); in vfio_start_irqfd_injection()
393 if (kvm_irqchip_add_irqfd_notifier(kvm_state, intp->interrupt, in vfio_start_irqfd_injection()
394 intp->unmask, irq) < 0) { in vfio_start_irqfd_injection()
398 if (vfio_set_trigger_eventfd(intp, NULL) < 0) { in vfio_start_irqfd_injection()
401 if (vfio_irq_is_automasked(intp)) { in vfio_start_irqfd_injection()
402 if (vfio_set_resample_eventfd(intp) < 0) { in vfio_start_irqfd_injection()
405 trace_vfio_platform_start_level_irqfd_injection(intp->pin, in vfio_start_irqfd_injection()
406 event_notifier_get_fd(intp->interrupt), in vfio_start_irqfd_injection()
407 event_notifier_get_fd(intp->unmask)); in vfio_start_irqfd_injection()
409 trace_vfio_platform_start_edge_irqfd_injection(intp->pin, in vfio_start_irqfd_injection()
410 event_notifier_get_fd(intp->interrupt)); in vfio_start_irqfd_injection()
413 intp->kvm_accel = true; in vfio_start_irqfd_injection()
417 kvm_irqchip_remove_irqfd_notifier(kvm_state, intp->interrupt, irq); in vfio_start_irqfd_injection()
446 VFIOINTp *intp, *tmp; in vfio_populate_device() local
488 intp = vfio_init_intp(vbasedev, irq, errp); in vfio_populate_device()
489 if (!intp) { in vfio_populate_device()
497 QLIST_FOREACH_SAFE(intp, &vdev->intp_list, next, tmp) { in vfio_populate_device()
498 QLIST_REMOVE(intp, next); in vfio_populate_device()
499 g_free(intp); in vfio_populate_device()