From 4e0ac6e474313529c5cc26cdab6ff5c575319a9c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 24 Mar 2009 18:24:14 +0000 Subject: [PATCH] passthrough: unmap INTx interrupt on hot-remove This patch unmaps INTx interrupt on hot-remove. Signed-off-by: Yuji Shimada --- hw/pass-through.c | 16 ++++++++++++++++ hw/pass-through.h | 1 + 2 files changed, 17 insertions(+) diff --git a/hw/pass-through.c b/hw/pass-through.c index 48e2e4b7..f5cdcdd3 100644 --- a/hw/pass-through.c +++ b/hw/pass-through.c @@ -46,6 +46,8 @@ struct dpci_infos { } dpci_infos; +char mapped_machine_irq[PT_NR_IRQS] = {0}; + /* prototype */ static uint32_t pt_common_reg_init(struct pt_dev *ptdev, struct pt_reg_info_tbl *reg, uint32_t real_offset); @@ -3757,6 +3759,7 @@ struct pt_dev * register_real_device(PCIBus *e_bus, { machine_irq = pirq; assigned_device->machine_irq = pirq; + mapped_machine_irq[machine_irq]++; } } @@ -3837,6 +3840,19 @@ int unregister_real_device(int slot) if (assigned_device->msix) pt_msix_disable(assigned_device); + if (machine_irq) + { + mapped_machine_irq[machine_irq]--; + + if (mapped_machine_irq[machine_irq] == 0) + { + rc = xc_physdev_unmap_pirq(xc_handle, domid, machine_irq); + + if (rc < 0) + PT_LOG("Error: Unmaping of interrupt failed! rc=%d\n", rc); + } + } + /* delete all emulated config registers */ pt_config_delete(assigned_device); diff --git a/hw/pass-through.h b/hw/pass-through.h index 63d1a6db..3132387f 100644 --- a/hw/pass-through.h +++ b/hw/pass-through.h @@ -40,6 +40,7 @@ #define PT_MACHINE_IRQ_AUTO (0xFFFFFFFF) #define PT_VIRT_DEVFN_AUTO (-1) +#define PT_NR_IRQS (256) /* Misc PCI constants that should be moved to a separate library :) */ #define PCI_CONFIG_SIZE (256) -- 2.39.5