]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
iommu: Move default domain allocation to iommu_group_get_for_dev()
authorJoerg Roedel <jroedel@suse.de>
Wed, 21 Oct 2015 21:51:43 +0000 (23:51 +0200)
committerJoerg Roedel <jroedel@suse.de>
Wed, 21 Oct 2015 22:00:49 +0000 (00:00 +0200)
Now that the iommu core support for iommu groups is not
pci-centric anymore, we can move default domain allocation
to the bus independent iommu_group_get_for_dev() function.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/iommu.c

index e2b5526506fd4a81423dd3c3fc600fe4c8f432fd..abae363c7b9bd8932066e760beea7f76f22e7b8d 100644 (file)
@@ -810,14 +810,6 @@ struct iommu_group *pci_device_group(struct device *dev)
        if (IS_ERR(group))
                return NULL;
 
-       /*
-        * Try to allocate a default domain - needs support from the
-        * IOMMU driver.
-        */
-       group->default_domain = __iommu_domain_alloc(pdev->dev.bus,
-                                                    IOMMU_DOMAIN_DMA);
-       group->domain = group->default_domain;
-
        return group;
 }
 
@@ -849,6 +841,16 @@ struct iommu_group *iommu_group_get_for_dev(struct device *dev)
        if (IS_ERR(group))
                return group;
 
+       /*
+        * Try to allocate a default domain - needs support from the
+        * IOMMU driver.
+        */
+       if (!group->default_domain) {
+               group->default_domain = __iommu_domain_alloc(dev->bus,
+                                                            IOMMU_DOMAIN_DMA);
+               group->domain = group->default_domain;
+       }
+
        ret = iommu_group_add_device(group, dev);
        if (ret) {
                iommu_group_put(group);