Skip to content

Commit e2addba

Browse files
rmurphy-armjoergroedel
authored andcommitted
iommu/dma: Document min_align_mask assumption
iommu-dma does not explicitly reference min_align_mask since we already assume that will be less than or equal to any typical IOVA granule. We wouldn't realistically expect to see the case where it is larger, and that would be non-trivial to support, however for the sake of reasoning (particularly around the interaction with SWIOTLB), let's clearly enforce the assumption. Signed-off-by: Robin Murphy <[email protected]> Reviewed-by: Michael Kelley <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/dbb4d2d8e5d1691ac9a6c67e9758904e6c447ba5.1709553942.git.robin.murphy@arm.com Signed-off-by: Joerg Roedel <[email protected]>
1 parent b5a1f75 commit e2addba

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/iommu/dma-iommu.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,11 @@ static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys,
859859
iommu_deferred_attach(dev, domain))
860860
return DMA_MAPPING_ERROR;
861861

862+
/* If anyone ever wants this we'd need support in the IOVA allocator */
863+
if (dev_WARN_ONCE(dev, dma_get_min_align_mask(dev) > iova_mask(iovad),
864+
"Unsupported alignment constraint\n"))
865+
return DMA_MAPPING_ERROR;
866+
862867
size = iova_align(iovad, size + iova_off);
863868

864869
iova = iommu_dma_alloc_iova(domain, size, dma_mask, dev);

0 commit comments

Comments
 (0)