]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
iommu/vt-d: Add attach_deferred() helper
authorJoerg Roedel <jroedel@suse.de>
Mon, 17 Feb 2020 16:12:37 +0000 (17:12 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 28 Feb 2020 16:23:24 +0000 (17:23 +0100)
commit 1d4615978f525b769990a4a4ef22fb1b9a04cdf1 upstream.

Implement a helper function to check whether a device's attach process
is deferred.

Fixes: 1ee0186b9a12 ("iommu/vt-d: Refactor find_domain() helper")
Cc: stable@vger.kernel.org # v5.5
Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iommu/intel-iommu.c

index dfedbb04f647de8188acf326988c4902aefe583d..d1ed0866bb0cbb5a7aa93eb74dcada2d2193a698 100644 (file)
@@ -732,6 +732,11 @@ static int iommu_dummy(struct device *dev)
        return dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO;
 }
 
+static bool attach_deferred(struct device *dev)
+{
+       return dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO;
+}
+
 /**
  * is_downstream_to_pci_bridge - test if a device belongs to the PCI
  *                              sub-hierarchy of a candidate PCI-PCI bridge
@@ -2424,8 +2429,7 @@ static struct dmar_domain *find_domain(struct device *dev)
 {
        struct device_domain_info *info;
 
-       if (unlikely(dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO ||
-                    dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO))
+       if (unlikely(attach_deferred(dev) || iommu_dummy(dev)))
                return NULL;
 
        /* No lock here, assumes no domain exit in normal case */
@@ -2438,7 +2442,7 @@ static struct dmar_domain *find_domain(struct device *dev)
 
 static struct dmar_domain *deferred_attach_domain(struct device *dev)
 {
-       if (unlikely(dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO)) {
+       if (unlikely(attach_deferred(dev))) {
                struct iommu_domain *domain;
 
                dev->archdata.iommu = NULL;
@@ -5989,7 +5993,7 @@ intel_iommu_aux_get_pasid(struct iommu_domain *domain, struct device *dev)
 static bool intel_iommu_is_attach_deferred(struct iommu_domain *domain,
                                           struct device *dev)
 {
-       return dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO;
+       return attach_deferred(dev);
 }
 
 const struct iommu_ops intel_iommu_ops = {