Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iommu/dma: Respect bus DMA limit for IOVAs

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.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>

authored by

Robin Murphy and committed by
Christoph Hellwig
03bfdc31 6c2fb2ea

+3
+3
drivers/iommu/dma-iommu.c
··· 367 367 if (iova_len < (1 << (IOVA_RANGE_CACHE_MAX_SIZE - 1))) 368 368 iova_len = roundup_pow_of_two(iova_len); 369 369 370 + if (dev->bus_dma_mask) 371 + dma_limit &= dev->bus_dma_mask; 372 + 370 373 if (domain->geometry.force_aperture) 371 374 dma_limit = min(dma_limit, domain->geometry.aperture_end); 372 375