Merge branches 'amd-iommu/fixes' and 'dma-debug/fixes' into iommu/fixes
[linux-2.6-block.git] / drivers / char / agp / amd64-agp.c
index 2fb2e6cc322aab1a36164de3fc99674559dea9ed..1afb8968a342082b87381d206beea315108431c2 100644 (file)
@@ -728,6 +728,10 @@ int __init agp_amd64_init(void)
 
        if (agp_off)
                return -EINVAL;
+
+       if (gart_iommu_aperture)
+               return agp_bridges_found ? 0 : -ENODEV;
+
        err = pci_register_driver(&agp_amd64_pci_driver);
        if (err < 0)
                return err;
@@ -766,17 +770,15 @@ int __init agp_amd64_init(void)
 
 static void __exit agp_amd64_cleanup(void)
 {
+       if (gart_iommu_aperture)
+               return;
        if (aperture_resource)
                release_resource(aperture_resource);
        pci_unregister_driver(&agp_amd64_pci_driver);
 }
 
-/* On AMD64 the PCI driver needs to initialize this driver early
-   for the IOMMU, so it has to be called via a backdoor. */
-#ifndef CONFIG_GART_IOMMU
 module_init(agp_amd64_init);
 module_exit(agp_amd64_cleanup);
-#endif
 
 MODULE_AUTHOR("Dave Jones <davej@redhat.com>, Andi Kleen");
 module_param(agp_try_unsupported, bool, 0);