Skip to content

Commit 032d7e4

Browse files
rmurphy-armjoergroedel
authored andcommitted
iommu/dma: Remove redundant locking
This reverts commit ac9a5d5. 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 <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/a943d4c198e6a1fffe998337d577dc3aa7f660a9.1740585469.git.robin.murphy@arm.com Signed-off-by: Joerg Roedel <[email protected]>
1 parent 59b6c34 commit 032d7e4

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

drivers/iommu/dma-iommu.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ struct iommu_dma_cookie {
8787
struct iommu_domain *fq_domain;
8888
/* Options for dma-iommu use */
8989
struct iommu_dma_options options;
90-
struct mutex mutex;
9190
};
9291

9392
static DEFINE_STATIC_KEY_FALSE(iommu_deferred_attach_enabled);
@@ -401,7 +400,6 @@ int iommu_get_dma_cookie(struct iommu_domain *domain)
401400
if (!domain->iova_cookie)
402401
return -ENOMEM;
403402

404-
mutex_init(&domain->iova_cookie->mutex);
405403
iommu_domain_set_sw_msi(domain, iommu_dma_sw_msi);
406404
return 0;
407405
}
@@ -709,23 +707,20 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, struct device *dev
709707
domain->geometry.aperture_start >> order);
710708

711709
/* start_pfn is always nonzero for an already-initialised domain */
712-
mutex_lock(&cookie->mutex);
713710
if (iovad->start_pfn) {
714711
if (1UL << order != iovad->granule ||
715712
base_pfn != iovad->start_pfn) {
716713
pr_warn("Incompatible range for DMA domain\n");
717-
ret = -EFAULT;
718-
goto done_unlock;
714+
return -EFAULT;
719715
}
720716

721-
ret = 0;
722-
goto done_unlock;
717+
return 0;
723718
}
724719

725720
init_iova_domain(iovad, 1UL << order, base_pfn);
726721
ret = iova_domain_init_rcaches(iovad);
727722
if (ret)
728-
goto done_unlock;
723+
return ret;
729724

730725
iommu_dma_init_options(&cookie->options, dev);
731726

@@ -734,11 +729,7 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, struct device *dev
734729
(!device_iommu_capable(dev, IOMMU_CAP_DEFERRED_FLUSH) || iommu_dma_init_fq(domain)))
735730
domain->type = IOMMU_DOMAIN_DMA;
736731

737-
ret = iova_reserve_iommu_regions(dev, domain);
738-
739-
done_unlock:
740-
mutex_unlock(&cookie->mutex);
741-
return ret;
732+
return iova_reserve_iommu_regions(dev, domain);
742733
}
743734

744735
/**

0 commit comments

Comments
 (0)