}
 #endif /* CONFIG_IRQ_REMAP */
 
-#define dmar_alloc_hwirq()     irq_alloc_hwirq(-1)
-#define dmar_free_hwirq                irq_free_hwirq
+extern int dmar_alloc_hwirq(void);
+extern void dmar_free_hwirq(int irq);
 
 #endif /* __X86_IRQ_REMAPPING_H */
 
                                      "edge");
        return 0;
 }
+
+int dmar_alloc_hwirq(void)
+{
+       return irq_domain_alloc_irqs(NULL, 1, NUMA_NO_NODE, NULL);
+}
+
+void dmar_free_hwirq(int irq)
+{
+       irq_domain_free_irqs(irq, 1);
+}
 #endif
 
 /*
 
 #include <linux/msi.h>
 #include <linux/irq.h>
 #include <linux/pci.h>
+#include <linux/irqdomain.h>
 
 #include <asm/hw_irq.h>
 #include <asm/irq_remapping.h>
                disconnect_bsp_APIC(0);
 }
 
+#ifndef CONFIG_GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
+static unsigned int irq_alloc_hwirqs(int cnt, int node)
+{
+       return irq_domain_alloc_irqs(NULL, -1, cnt, node, NULL);
+}
+
+static void irq_free_hwirqs(unsigned int from, int cnt)
+{
+       irq_domain_free_irqs(from, cnt);
+}
+#endif
+
 static int do_setup_msi_irqs(struct pci_dev *dev, int nvec)
 {
        int ret, sub_handle, nvec_pow2, index = 0;
 
        list_for_each_entry(msidesc, &dev->msi_list, list) {
 
-               irq = irq_alloc_hwirq(node);
+               irq = irq_alloc_hwirqs(1, node);
                if (irq == 0)
                        return -1;
 
        return 0;
 
 error:
-       irq_free_hwirq(irq);
+       irq_free_hwirqs(irq, 1);
        return ret;
 }