Message ID | d370670edae9c9c537a5280c5e7c96bf3ec7ed8f.1532382222.git.robin.murphy@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Stop losing firmware-set DMA masks | expand |
On Mon, Jul 23, 2018 at 11:16:10PM +0100, Robin Murphy wrote: > Bonus question: Now that we're collecing DMA API code in kernel/dma/ > do we want to reevaluate dma-iommu? On the one hand it's the bulk of a > dma_ops implementation so should perhaps move, but on the other it's > entirely IOMMU-specific code so should perhaps stay where it is... :/ I think drivers/iommu/ is the right place for it. Higher priorities would be to actually make it a complete dma_map_ops implementation, which should be doable by next merge window, and to actually use it for non-arm(64) iommu drivers..
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index ddcbbdb5d658..511ff9a1d6d9 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -367,6 +367,9 @@ static dma_addr_t iommu_dma_alloc_iova(struct iommu_domain *domain, if (iova_len < (1 << (IOVA_RANGE_CACHE_MAX_SIZE - 1))) iova_len = roundup_pow_of_two(iova_len); + if (dev->bus_dma_mask) + dma_limit &= dev->bus_dma_mask; + if (domain->geometry.force_aperture) dma_limit = min(dma_limit, domain->geometry.aperture_end);
Take the new bus limit into account (when present) for IOVA allocations, to accommodate those SoCs which integrate off-the-shelf IP blocks with narrower interconnects such that the link between a device output and an IOMMU input can truncate DMA addresses to even fewer bits than the native size of either block's interface would imply. Eventually it might make sense for the DMA core to apply this constraint up-front in dma_set_mask() and friends, but for now this seems like the least risky approach. CC: Joerg Roedel <joro@8bytes.org> Signed-off-by: Robin Murphy <robin.murphy@arm.com> --- Bonus question: Now that we're collecing DMA API code in kernel/dma/ do we want to reevaluate dma-iommu? On the one hand it's the bulk of a dma_ops implementation so should perhaps move, but on the other it's entirely IOMMU-specific code so should perhaps stay where it is... :/ drivers/iommu/dma-iommu.c | 3 +++ 1 file changed, 3 insertions(+)