Merge master.kernel.org:/pub/scm/linux/kernel/git/steve/gfs2-2.6-nmw
[pandora-kernel.git] / arch / x86_64 / kernel / pci-gart.c
index 82a346e..fc1960f 100644 (file)
@@ -10,7 +10,6 @@
  * Copyright 2002 Andi Kleen, SuSE Labs.
  */
 
-#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/ctype.h>
 #include <linux/agp_backend.h>
@@ -240,8 +239,6 @@ dma_addr_t gart_map_single(struct device *dev, void *addr, size_t size, int dir)
 {
        unsigned long phys_mem, bus;
 
-       BUG_ON(dir == DMA_NONE);
-
        if (!dev)
                dev = &fallback_dev;
 
@@ -384,7 +381,6 @@ int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
        unsigned long pages = 0;
        int need = 0, nextneed;
 
-       BUG_ON(dir == DMA_NONE);
        if (nents == 0) 
                return 0;
 
@@ -571,7 +567,7 @@ static struct dma_mapping_ops gart_dma_ops = {
        .unmap_sg = gart_unmap_sg,
 };
 
-static int __init pci_iommu_init(void)
+void __init gart_iommu_init(void)
 { 
        struct agp_kern_info info;
        unsigned long aper_size;
@@ -581,7 +577,7 @@ static int __init pci_iommu_init(void)
 
        if (cache_k8_northbridges() < 0 || num_k8_northbridges == 0) {
                printk(KERN_INFO "PCI-GART: No AMD northbridge found.\n");
-               return -ENODEV;
+               return;
        }
 
 #ifndef CONFIG_AGP_AMD64
@@ -595,19 +591,22 @@ static int __init pci_iommu_init(void)
 #endif 
 
        if (swiotlb)
-               return -ENODEV;
+               return;
+
+       /* Did we detect a different HW IOMMU? */
+       if (iommu_detected && !iommu_aperture)
+               return;
 
        if (no_iommu ||
            (!force_iommu && end_pfn <= MAX_DMA32_PFN) ||
            !iommu_aperture ||
            (no_agp && init_k8_gatt(&info) < 0)) {
-               printk(KERN_INFO "PCI-DMA: Disabling IOMMU.\n");
                if (end_pfn > MAX_DMA32_PFN) {
                        printk(KERN_ERR "WARNING more than 4GB of memory "
-                                       "but IOMMU not available.\n"
+                                       "but GART IOMMU not available.\n"
                               KERN_ERR "WARNING 32bit PCI may malfunction.\n");
                }
-               return -ENODEV;
+               return;
        }
 
        printk(KERN_INFO "PCI-DMA: using GART IOMMU.\n");
@@ -674,12 +673,8 @@ static int __init pci_iommu_init(void)
 
        flush_gart();
        dma_ops = &gart_dma_ops;
-       return 0;
 } 
 
-/* Must execute after PCI subsystem */
-fs_initcall(pci_iommu_init);
-
 void gart_parse_options(char *p)
 {
        int arg;