microblaze: Fix sg_dma_len() regression
[safe/jmp/linux-2.6] / drivers / pci / intr_remapping.c
index 2cc3f70..1315ac6 100644 (file)
@@ -1,6 +1,7 @@
 #include <linux/interrupt.h>
 #include <linux/dmar.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/hpet.h>
 #include <linux/pci.h>
@@ -57,15 +58,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;
@@ -74,16 +72,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];
@@ -528,7 +521,7 @@ int set_msi_sid(struct irte *irte, struct pci_dev *dev)
                return -1;
 
        /* PCIe device or Root Complex integrated PCI device */
-       if (dev->is_pcie || !dev->bus->parent) {
+       if (pci_is_pcie(dev) || !dev->bus->parent) {
                set_irte_sid(irte, SVT_VERIFY_SID_SQ, SQ_ALL_16,
                             (dev->bus->number << 8) | dev->devfn);
                return 0;
@@ -536,7 +529,7 @@ int set_msi_sid(struct irte *irte, struct pci_dev *dev)
 
        bridge = pci_find_upstream_pcie_bridge(dev);
        if (bridge) {
-               if (bridge->is_pcie) /* this is a PCIE-to-PCI/PCIX bridge */
+               if (pci_is_pcie(bridge))/* this is a PCIe-to-PCI/PCIX bridge */
                        set_irte_sid(irte, SVT_VERIFY_BUS, SQ_ALL_16,
                                (bridge->bus->number << 8) | dev->bus->number);
                else /* this is a legacy PCI bridge */
@@ -598,7 +591,8 @@ static int setup_intr_remapping(struct intel_iommu *iommu, int mode)
        if (!iommu->ir_table)
                return -ENOMEM;
 
-       pages = alloc_pages(GFP_ATOMIC | __GFP_ZERO, INTR_REMAP_PAGE_ORDER);
+       pages = alloc_pages_node(iommu->node, GFP_ATOMIC | __GFP_ZERO,
+                                INTR_REMAP_PAGE_ORDER);
 
        if (!pages) {
                printk(KERN_ERR "failed to allocate pages of order %d\n",
@@ -653,6 +647,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;
 
@@ -668,6 +665,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;
 
@@ -830,9 +832,9 @@ static int ir_parse_ioapic_hpet_scope(struct acpi_dmar_header *header,
                                return -1;
                        }
 
-                       printk(KERN_INFO "IOAPIC id %d under DRHD base"
-                              " 0x%Lx\n", scope->enumeration_id,
-                              drhd->address);
+                       printk(KERN_INFO "IOAPIC id %d under DRHD base "
+                              " 0x%Lx IOMMU %d\n", scope->enumeration_id,
+                              drhd->address, iommu->seq_id);
 
                        ir_parse_one_ioapic_scope(scope, iommu);
                } else if (scope->entry_type == ACPI_DMAR_SCOPE_TYPE_HPET) {