[PATCH 3/6] iommu/vt-d: Move deferred device attachment into helper function

Tim Gardner tim.gardner at canonical.com
Tue Apr 6 17:12:25 UTC 2021


From: Joerg Roedel <jroedel at suse.de>

BugLink: https://bugs.launchpad.net/bugs/1922738

Move the code that does the deferred device attachment into a separate
helper function.

Fixes: 1ee0186b9a12 ("iommu/vt-d: Refactor find_domain() helper")
Cc: stable at vger.kernel.org # v5.5
Reviewed-by: Jerry Snitselaar <jsnitsel at redhat.com>
Acked-by: Lu Baolu <baolu.lu at linux.intel.com>
Signed-off-by: Joerg Roedel <jroedel at suse.de>
(cherry picked from commit 034d98cc0cdcde2415c6f598fa9125e3eaa02569)
Signed-off-by: Tim Gardner <tim.gardner at canonical.com>
---
 drivers/iommu/intel-iommu.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 9828f5167332..d234cb22369e 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -2447,16 +2447,20 @@ static struct dmar_domain *find_domain(struct device *dev)
 	return NULL;
 }
 
-static struct dmar_domain *deferred_attach_domain(struct device *dev)
+static void do_deferred_attach(struct device *dev)
 {
-	if (unlikely(attach_deferred(dev))) {
-		struct iommu_domain *domain;
+	struct iommu_domain *domain;
 
-		dev->archdata.iommu = NULL;
-		domain = iommu_get_domain_for_dev(dev);
-		if (domain)
-			intel_iommu_attach_device(domain, dev);
-	}
+	dev->archdata.iommu = NULL;
+	domain = iommu_get_domain_for_dev(dev);
+	if (domain)
+		intel_iommu_attach_device(domain, dev);
+}
+
+static struct dmar_domain *deferred_attach_domain(struct device *dev)
+{
+	if (unlikely(attach_deferred(dev)))
+		do_deferred_attach(dev);
 
 	return find_domain(dev);
 }
-- 
2.17.1




More information about the kernel-team mailing list