]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - arch/x86/kernel/amd_iommu.c
Merge branch 'x86/mce' into x86/urgent
[mv-sheeva.git] / arch / x86 / kernel / amd_iommu.c
index 32fb09102a1356af2597d1cafd924bbc8e2ee941..b990b5cc95418df45f1c94f1b748cb5d59d45e1c 100644 (file)
@@ -166,6 +166,43 @@ static void iommu_uninit_device(struct device *dev)
 {
        kfree(dev->archdata.iommu);
 }
+
+void __init amd_iommu_uninit_devices(void)
+{
+       struct pci_dev *pdev = NULL;
+
+       for_each_pci_dev(pdev) {
+
+               if (!check_device(&pdev->dev))
+                       continue;
+
+               iommu_uninit_device(&pdev->dev);
+       }
+}
+
+int __init amd_iommu_init_devices(void)
+{
+       struct pci_dev *pdev = NULL;
+       int ret = 0;
+
+       for_each_pci_dev(pdev) {
+
+               if (!check_device(&pdev->dev))
+                       continue;
+
+               ret = iommu_init_device(&pdev->dev);
+               if (ret)
+                       goto out_free;
+       }
+
+       return 0;
+
+out_free:
+
+       amd_iommu_uninit_devices();
+
+       return ret;
+}
 #ifdef CONFIG_AMD_IOMMU_STATS
 
 /*
@@ -1587,6 +1624,11 @@ static struct notifier_block device_nb = {
        .notifier_call = device_change_notifier,
 };
 
+void amd_iommu_init_notifier(void)
+{
+       bus_register_notifier(&pci_bus_type, &device_nb);
+}
+
 /*****************************************************************************
  *
  * The next functions belong to the dma_ops mapping/unmapping code.
@@ -1783,7 +1825,7 @@ retry:
                        goto out;
 
                /*
-                * aperture was sucessfully enlarged by 128 MB, try
+                * aperture was successfully enlarged by 128 MB, try
                 * allocation again
                 */
                goto retry;
@@ -2145,8 +2187,6 @@ static void prealloc_protection_domains(void)
                if (!check_device(&dev->dev))
                        continue;
 
-               iommu_init_device(&dev->dev);
-
                /* Is there already any domain for it? */
                if (domain_for_device(&dev->dev))
                        continue;
@@ -2215,8 +2255,6 @@ int __init amd_iommu_init_dma_ops(void)
 
        register_iommu(&amd_iommu_ops);
 
-       bus_register_notifier(&pci_bus_type, &device_nb);
-
        amd_iommu_stats_init();
 
        return 0;
@@ -2490,7 +2528,7 @@ int __init amd_iommu_init_passthrough(void)
        struct pci_dev *dev = NULL;
        u16 devid;
 
-       /* allocate passthroug domain */
+       /* allocate passthrough domain */
        pt_domain = protection_domain_alloc();
        if (!pt_domain)
                return -ENOMEM;