Merge git://git.infradead.org/~dwmw2/mtd-2.6.35
[pandora-kernel.git] / arch / x86 / kernel / amd_iommu_init.c
index 6360abf..3cc63e2 100644 (file)
@@ -120,6 +120,7 @@ struct ivmd_header {
 bool amd_iommu_dump;
 
 static int __initdata amd_iommu_detected;
+static bool __initdata amd_iommu_disabled;
 
 u16 amd_iommu_last_bdf;                        /* largest PCI device id we have
                                           to handle */
@@ -286,8 +287,12 @@ static u8 * __init iommu_map_mmio_space(u64 address)
 {
        u8 *ret;
 
-       if (!request_mem_region(address, MMIO_REGION_LENGTH, "amd_iommu"))
+       if (!request_mem_region(address, MMIO_REGION_LENGTH, "amd_iommu")) {
+               pr_err("AMD-Vi: Can not reserve memory region %llx for mmio\n",
+                       address);
+               pr_err("AMD-Vi: This is a BIOS bug. Please contact your hardware vendor\n");
                return NULL;
+       }
 
        ret = ioremap_nocache(address, MMIO_REGION_LENGTH);
        if (ret != NULL)
@@ -1313,7 +1318,7 @@ static int __init amd_iommu_init(void)
                ret = amd_iommu_init_dma_ops();
 
        if (ret)
-               goto free;
+               goto free_disable;
 
        amd_iommu_init_api();
 
@@ -1331,9 +1336,10 @@ static int __init amd_iommu_init(void)
 out:
        return ret;
 
-free:
+free_disable:
        disable_iommus();
 
+free:
        amd_iommu_uninit_devices();
 
        free_pages((unsigned long)amd_iommu_pd_alloc_bitmap,
@@ -1352,6 +1358,15 @@ free:
 
        free_unity_maps();
 
+#ifdef CONFIG_GART_IOMMU
+       /*
+        * We failed to initialize the AMD IOMMU - try fallback to GART
+        * if possible.
+        */
+       gart_iommu_init();
+
+#endif
+
        goto out;
 }
 
@@ -1372,6 +1387,9 @@ void __init amd_iommu_detect(void)
        if (no_iommu || (iommu_detected && !gart_iommu_aperture))
                return;
 
+       if (amd_iommu_disabled)
+               return;
+
        if (acpi_table_parse("IVRS", early_amd_iommu_detect) == 0) {
                iommu_detected = 1;
                amd_iommu_detected = 1;
@@ -1401,6 +1419,8 @@ static int __init parse_amd_iommu_options(char *str)
        for (; *str; ++str) {
                if (strncmp(str, "fullflush", 9) == 0)
                        amd_iommu_unmap_flush = true;
+               if (strncmp(str, "off", 3) == 0)
+                       amd_iommu_disabled = true;
        }
 
        return 1;