Lines Matching refs:ctx

55 	return xa_load(&vdev->ctx, index);
59 struct vfio_pci_irq_ctx *ctx, unsigned long index)
61 xa_erase(&vdev->ctx, index);
62 kfree(ctx);
68 struct vfio_pci_irq_ctx *ctx;
71 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL_ACCOUNT);
72 if (!ctx)
75 ret = xa_insert(&vdev->ctx, index, ctx, GFP_KERNEL_ACCOUNT);
77 kfree(ctx);
81 return ctx;
92 struct vfio_pci_irq_ctx *ctx;
95 ctx = vfio_irq_ctx_get(vdev, 0);
96 if (WARN_ON_ONCE(!ctx))
99 trigger = READ_ONCE(ctx->trigger);
109 struct vfio_pci_irq_ctx *ctx;
129 ctx = vfio_irq_ctx_get(vdev, 0);
130 if (WARN_ON_ONCE(!ctx))
133 if (!ctx->masked) {
143 ctx->masked = true;
173 struct vfio_pci_irq_ctx *ctx;
189 ctx = vfio_irq_ctx_get(vdev, 0);
190 if (WARN_ON_ONCE(!ctx))
193 if (ctx->masked && !vdev->virq_disabled) {
205 ctx->masked = (ret > 0);
232 struct vfio_pci_irq_ctx *ctx;
236 ctx = vfio_irq_ctx_get(vdev, 0);
237 if (WARN_ON_ONCE(!ctx))
244 ctx->masked = true;
246 } else if (!ctx->masked && /* may be shared */
248 ctx->masked = true;
264 struct vfio_pci_irq_ctx *ctx;
279 ctx = vfio_irq_ctx_alloc(vdev, 0);
280 if (!ctx)
283 ctx->name = name;
284 ctx->trigger = trigger;
304 ctx->masked = vdev->virq_disabled;
306 pci_intx(pdev, !ctx->masked);
309 irqflags = ctx->masked ? IRQF_NO_AUTOEN : 0;
315 irqflags, ctx->name, vdev);
319 vfio_irq_ctx_free(vdev, ctx, 0);
330 struct vfio_pci_irq_ctx *ctx;
333 ctx = vfio_irq_ctx_get(vdev, 0);
334 if (WARN_ON_ONCE(!ctx))
337 old = ctx->trigger;
339 WRITE_ONCE(ctx->trigger, trigger);
341 /* Releasing an old ctx requires synchronizing in-flight users */
344 vfio_virqfd_flush_thread(&ctx->unmask);
354 struct vfio_pci_irq_ctx *ctx;
356 ctx = vfio_irq_ctx_get(vdev, 0);
357 WARN_ON_ONCE(!ctx);
358 if (ctx) {
359 vfio_virqfd_disable(&ctx->unmask);
360 vfio_virqfd_disable(&ctx->mask);
362 if (ctx->trigger)
363 eventfd_ctx_put(ctx->trigger);
364 kfree(ctx->name);
365 vfio_irq_ctx_free(vdev, ctx, 0);
451 struct vfio_pci_irq_ctx *ctx;
456 ctx = vfio_irq_ctx_get(vdev, vector);
458 if (ctx) {
459 irq_bypass_unregister_producer(&ctx->producer);
462 free_irq(irq, ctx->trigger);
465 kfree(ctx->name);
466 eventfd_ctx_put(ctx->trigger);
467 vfio_irq_ctx_free(vdev, ctx, vector);
480 ctx = vfio_irq_ctx_alloc(vdev, vector);
481 if (!ctx)
484 ctx->name = kasprintf(GFP_KERNEL_ACCOUNT, "vfio-msi%s[%d](%s)",
486 if (!ctx->name) {
510 ret = request_irq(irq, vfio_msihandler, 0, ctx->name, trigger);
515 ctx->producer.token = trigger;
516 ctx->producer.irq = irq;
517 ret = irq_bypass_register_producer(&ctx->producer);
521 ctx->producer.token, ret);
523 ctx->producer.token = NULL;
525 ctx->trigger = trigger;
532 kfree(ctx->name);
534 vfio_irq_ctx_free(vdev, ctx, vector);
560 struct vfio_pci_irq_ctx *ctx;
564 xa_for_each(&vdev->ctx, i, ctx) {
565 vfio_virqfd_disable(&ctx->unmask);
566 vfio_virqfd_disable(&ctx->mask);
601 struct vfio_pci_irq_ctx *ctx = vfio_irq_ctx_get(vdev, 0);
604 if (WARN_ON_ONCE(!ctx))
610 &ctx->unmask, fd);
612 vfio_virqfd_disable(&ctx->unmask);
689 struct vfio_pci_irq_ctx *ctx;
724 ctx = vfio_irq_ctx_get(vdev, i);
725 if (!ctx)
728 eventfd_signal(ctx->trigger);
732 eventfd_signal(ctx->trigger);
738 static int vfio_pci_set_ctx_trigger_single(struct eventfd_ctx **ctx,
744 if (*ctx) {
746 eventfd_signal(*ctx);
748 eventfd_ctx_put(*ctx);
749 *ctx = NULL;
760 if (trigger && *ctx)
761 eventfd_signal(*ctx);
772 if (*ctx)
773 eventfd_ctx_put(*ctx);
774 *ctx = NULL;
782 if (*ctx)
783 eventfd_ctx_put(*ctx);
785 *ctx = efdctx;