Merge git://git.infradead.org/iommu-2.6
[firefly-linux-kernel-4.4.55.git] / drivers / pci / intr_remapping.c
index 4f5b8712931f0d34c1702440a80ff0bb71f46964..0ed78a764ded2e10ede6f3f109ab481bca73be42 100644 (file)
@@ -55,15 +55,12 @@ static struct irq_2_iommu *irq_2_iommu(unsigned int irq)
        return desc->irq_2_iommu;
 }
 
-static struct irq_2_iommu *irq_2_iommu_alloc_node(unsigned int irq, int node)
+static struct irq_2_iommu *irq_2_iommu_alloc(unsigned int irq)
 {
        struct irq_desc *desc;
        struct irq_2_iommu *irq_iommu;
 
-       /*
-        * alloc irq desc if not allocated already.
-        */
-       desc = irq_to_desc_alloc_node(irq, node);
+       desc = irq_to_desc(irq);
        if (!desc) {
                printk(KERN_INFO "can not get irq_desc for %d\n", irq);
                return NULL;
@@ -72,16 +69,11 @@ static struct irq_2_iommu *irq_2_iommu_alloc_node(unsigned int irq, int node)
        irq_iommu = desc->irq_2_iommu;
 
        if (!irq_iommu)
-               desc->irq_2_iommu = get_one_free_irq_2_iommu(node);
+               desc->irq_2_iommu = get_one_free_irq_2_iommu(irq_node(irq));
 
        return desc->irq_2_iommu;
 }
 
-static struct irq_2_iommu *irq_2_iommu_alloc(unsigned int irq)
-{
-       return irq_2_iommu_alloc_node(irq, cpu_to_node(boot_cpu_id));
-}
-
 #else /* !CONFIG_SPARSE_IRQ */
 
 static struct irq_2_iommu irq_2_iommuX[NR_IRQS];
@@ -611,6 +603,9 @@ int __init intr_remapping_supported(void)
        if (disable_intremap)
                return 0;
 
+       if (!dmar_ir_support())
+               return 0;
+
        for_each_drhd_unit(drhd) {
                struct intel_iommu *iommu = drhd->iommu;
 
@@ -626,6 +621,11 @@ int __init enable_intr_remapping(int eim)
        struct dmar_drhd_unit *drhd;
        int setup = 0;
 
+       if (parse_ioapics_under_ir() != 1) {
+               printk(KERN_INFO "Not enable interrupt remapping\n");
+               return -1;
+       }
+
        for_each_drhd_unit(drhd) {
                struct intel_iommu *iommu = drhd->iommu;