]> git.ipfire.org Git - thirdparty/linux.git/blobdiff - drivers/iommu/intel-iommu.c
Merge tag 'iommu-fixes-v5.2-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git...
[thirdparty/linux.git] / drivers / iommu / intel-iommu.c
index 162b3236e72c3c8702fd44aac9b0e43f7fb813d5..56297298d6eeef1de4c96d3db0ee3efba7629312 100644 (file)
@@ -2504,6 +2504,7 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu,
                }
        }
 
+       spin_lock(&iommu->lock);
        spin_lock_irqsave(&device_domain_lock, flags);
        if (dev)
                found = find_domain(dev);
@@ -2519,17 +2520,16 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu,
 
        if (found) {
                spin_unlock_irqrestore(&device_domain_lock, flags);
+               spin_unlock(&iommu->lock);
                free_devinfo_mem(info);
                /* Caller must free the original domain */
                return found;
        }
 
-       spin_lock(&iommu->lock);
        ret = domain_attach_iommu(domain, iommu);
-       spin_unlock(&iommu->lock);
-
        if (ret) {
                spin_unlock_irqrestore(&device_domain_lock, flags);
+               spin_unlock(&iommu->lock);
                free_devinfo_mem(info);
                return NULL;
        }
@@ -2539,6 +2539,7 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu,
        if (dev)
                dev->archdata.iommu = info;
        spin_unlock_irqrestore(&device_domain_lock, flags);
+       spin_unlock(&iommu->lock);
 
        /* PASID table is mandatory for a PCI device in scalable mode. */
        if (dev && dev_is_pci(dev) && sm_supported(iommu)) {