iommu/iova: Make dma_32bit_pfn implicit
Now that the cached node optimisation can apply to all allocations, the couple of users which were playing tricks with dma_32bit_pfn in order to benefit from it can stop doing so. Conversely, there is also no need for all the other users to explicitly calculate a 'real' 32-bit PFN, when init_iova_domain() can happily do that itself from the page granularity. CC: Thierry Reding <thierry.reding@gmail.com> CC: Jonathan Hunter <jonathanh@nvidia.com> CC: David Airlie <airlied@linux.ie> CC: Sudeep Dutt <sudeep.dutt@intel.com> CC: Ashutosh Dixit <ashutosh.dixit@intel.com> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Zhen Lei <thunder.leizhen@huawei.com> Tested-by: Nate Watterson <nwatters@codeaurora.org> [rm: use iova_shift(), rewrote commit message] Signed-off-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
@@ -292,18 +292,7 @@ int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base,
|
||||
/* ...then finally give it a kicking to make sure it fits */
|
||||
base_pfn = max_t(unsigned long, base_pfn,
|
||||
domain->geometry.aperture_start >> order);
|
||||
end_pfn = min_t(unsigned long, end_pfn,
|
||||
domain->geometry.aperture_end >> order);
|
||||
}
|
||||
/*
|
||||
* PCI devices may have larger DMA masks, but still prefer allocating
|
||||
* within a 32-bit mask to avoid DAC addressing. Such limitations don't
|
||||
* apply to the typical platform device, so for those we may as well
|
||||
* leave the cache limit at the top of their range to save an rb_last()
|
||||
* traversal on every allocation.
|
||||
*/
|
||||
if (dev && dev_is_pci(dev))
|
||||
end_pfn &= DMA_BIT_MASK(32) >> order;
|
||||
|
||||
/* start_pfn is always nonzero for an already-initialised domain */
|
||||
if (iovad->start_pfn) {
|
||||
@@ -312,16 +301,11 @@ int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base,
|
||||
pr_warn("Incompatible range for DMA domain\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
/*
|
||||
* If we have devices with different DMA masks, move the free
|
||||
* area cache limit down for the benefit of the smaller one.
|
||||
*/
|
||||
iovad->dma_32bit_pfn = min(end_pfn + 1, iovad->dma_32bit_pfn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
init_iova_domain(iovad, 1UL << order, base_pfn, end_pfn);
|
||||
init_iova_domain(iovad, 1UL << order, base_pfn);
|
||||
if (!dev)
|
||||
return 0;
|
||||
|
||||
|
Reference in New Issue
Block a user