iommu/amd: Use default domain if available for DMA-API
authorJoerg Roedel <jroedel@suse.de>
Thu, 28 May 2015 16:41:38 +0000 (18:41 +0200)
committerJoerg Roedel <jroedel@suse.de>
Thu, 11 Jun 2015 07:42:21 +0000 (09:42 +0200)
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd_iommu.c

index 22d38e3cdc7a2319073d756e53b4410e5f545a10..ae7d636d3099b3fe84a91cec74e254ff167b7486 100644 (file)
@@ -2495,12 +2495,19 @@ void amd_iommu_init_notifier(void)
 static struct protection_domain *get_domain(struct device *dev)
 {
        struct protection_domain *domain;
+       struct iommu_domain *io_domain;
        struct dma_ops_domain *dma_dom;
        u16 devid = get_device_id(dev);
 
        if (!check_device(dev))
                return ERR_PTR(-EINVAL);
 
+       io_domain = iommu_get_domain_for_dev(dev);
+       if (io_domain) {
+               domain = to_pdomain(io_domain);
+               return domain;
+       }
+
        domain = domain_for_device(dev);
        if (domain != NULL && !dma_ops_domain(domain))
                return ERR_PTR(-EBUSY);