The per-interrupt context may contain backend specific data. Call a backend provided initializer on per-interrupt context creation. Signed-off-by: Reinette Chatre <reinette.chatre@xxxxxxxxx> --- Changes since RFC V2: - New patch drivers/vfio/pci/vfio_pci_intrs.c | 8 ++++++++ include/linux/vfio_pci_core.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c index 1e6376b048de..8c86f2d6229f 100644 --- a/drivers/vfio/pci/vfio_pci_intrs.c +++ b/drivers/vfio/pci/vfio_pci_intrs.c @@ -73,6 +73,14 @@ vfio_irq_ctx_alloc(struct vfio_pci_intr_ctx *intr_ctx, unsigned long index) if (!ctx) return NULL; + if (intr_ctx->ops->init_irq_ctx) { + ret = intr_ctx->ops->init_irq_ctx(intr_ctx, ctx); + if (ret < 0) { + kfree(ctx); + return NULL; + } + } + ret = xa_insert(&intr_ctx->ctx, index, ctx, GFP_KERNEL_ACCOUNT); if (ret) { kfree(ctx); diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h index f0951084a26f..d5140a732741 100644 --- a/include/linux/vfio_pci_core.h +++ b/include/linux/vfio_pci_core.h @@ -106,6 +106,8 @@ struct vfio_pci_intr_ops { unsigned int vector); char *(*msi_device_name)(struct vfio_pci_intr_ctx *intr_ctx, unsigned int vector, unsigned int index); + int (*init_irq_ctx)(struct vfio_pci_intr_ctx *intr_ctx, + struct vfio_pci_irq_ctx *ctx); }; struct vfio_pci_core_device { -- 2.34.1