From: Joerg Roedel <jroedel@suse.de>
Date: Thu, 7 Jul 2016 15:31:13 +0200
Subject: iommu/amd: Use dev_data->domain in get_domain()
Git-commit: d26592a93ddb7a73cbd82b08e2e0d2985d68d750
Patch-mainline: v4.8-rc1
References: fate#321026

Using the cached value is much more efficient than calling
into the IOMMU core code.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/iommu/amd_iommu.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -2217,16 +2217,11 @@ static void queue_add(struct dma_ops_dom
 static struct protection_domain *get_domain(struct device *dev)
 {
 	struct protection_domain *domain;
-	struct iommu_domain *io_domain;
 
 	if (!check_device(dev))
 		return ERR_PTR(-EINVAL);
 
-	io_domain = iommu_get_domain_for_dev(dev);
-	if (!io_domain)
-		return NULL;
-
-	domain = to_pdomain(io_domain);
+	domain = get_dev_data(dev)->domain;
 	if (!dma_ops_domain(domain))
 		return ERR_PTR(-EBUSY);
 
