Skip to content

Commit

Permalink
iommu/dma: Remove redundant locking
Browse files Browse the repository at this point in the history
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 <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>
  • Loading branch information
Robin Murphy authored and Joerg Roedel committed Mar 10, 2025
1 parent 59b6c34 commit 032d7e4
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions drivers/iommu/dma-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);

Expand All @@ -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);
}

/**
Expand Down

0 comments on commit 032d7e4

Please sign in to comment.