]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/dma: Remove redundant locking
authorRobin Murphy <robin.murphy@arm.com>
Wed, 26 Feb 2025 15:57:49 +0000 (15:57 +0000)
committerJoerg Roedel <jroedel@suse.de>
Mon, 10 Mar 2025 08:23:58 +0000 (09:23 +0100)
This reverts commit ac9a5d522bb80be50ea84965699e1c8257d745ce.

iommu_dma_init_domain() is now only called under the group mutex, as it
should be given that that the default domain belongs to the group, so
the additional internal locking is no longer needed.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/a943d4c198e6a1fffe998337d577dc3aa7f660a9.1740585469.git.robin.murphy@arm.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/dma-iommu.c

index 94263ed2c5644b18ff112bcb0bce831c70c1ab42..0832998eca389af4b371978962deeb0ade1bf0fe 100644 (file)
@@ -87,7 +87,6 @@ struct iommu_dma_cookie {
        struct iommu_domain             *fq_domain;
        /* Options for dma-iommu use */
        struct iommu_dma_options        options;
-       struct mutex                    mutex;
 };
 
 static DEFINE_STATIC_KEY_FALSE(iommu_deferred_attach_enabled);
@@ -401,7 +400,6 @@ int iommu_get_dma_cookie(struct iommu_domain *domain)
        if (!domain->iova_cookie)
                return -ENOMEM;
 
-       mutex_init(&domain->iova_cookie->mutex);
        iommu_domain_set_sw_msi(domain, iommu_dma_sw_msi);
        return 0;
 }
@@ -709,23 +707,20 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, struct device *dev
                         domain->geometry.aperture_start >> order);
 
        /* start_pfn is always nonzero for an already-initialised domain */
-       mutex_lock(&cookie->mutex);
        if (iovad->start_pfn) {
                if (1UL << order != iovad->granule ||
                    base_pfn != iovad->start_pfn) {
                        pr_warn("Incompatible range for DMA domain\n");
-                       ret = -EFAULT;
-                       goto done_unlock;
+                       return -EFAULT;
                }
 
-               ret = 0;
-               goto done_unlock;
+               return 0;
        }
 
        init_iova_domain(iovad, 1UL << order, base_pfn);
        ret = iova_domain_init_rcaches(iovad);
        if (ret)
-               goto done_unlock;
+               return ret;
 
        iommu_dma_init_options(&cookie->options, dev);
 
@@ -734,11 +729,7 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, struct device *dev
            (!device_iommu_capable(dev, IOMMU_CAP_DEFERRED_FLUSH) || iommu_dma_init_fq(domain)))
                domain->type = IOMMU_DOMAIN_DMA;
 
-       ret = iova_reserve_iommu_regions(dev, domain);
-
-done_unlock:
-       mutex_unlock(&cookie->mutex);
-       return ret;
+       return iova_reserve_iommu_regions(dev, domain);
 }
 
 /**