]> xenbits.xen.org Git - xenclient/ioemu.git/commitdiff
passthrough: unmap INTx interrupt on hot-remove
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 24 Mar 2009 18:24:14 +0000 (18:24 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 24 Mar 2009 18:24:14 +0000 (18:24 +0000)
This patch unmaps INTx interrupt on hot-remove.

Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp>
hw/pass-through.c
hw/pass-through.h

index 48e2e4b7967969ada78ce5cb851ce910c0389e95..f5cdcdd3ed92c7abffc2d1e0739dccbbb4e97270 100644 (file)
@@ -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);
 
index 63d1a6db0c22f063786b44e160c9a903e8466e3d..3132387fa486cb505b1f5f9313716bf3cb8fbd49 100644 (file)
@@ -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)