Skip to content

Commit 23c216b

Browse files
aikmpe
authored andcommitted
powerpc/iommu: Report the correct most efficient DMA mask for PCI devices
According to dma-api.rst, the dma_get_required_mask() helper should return "the mask that the platform requires to operate efficiently". Which in the case of PPC64 means the bypass mask and not a mask from an IOMMU table which is shorter and slower to use due to map/unmap operations (especially expensive on "pseries"). However the existing implementation ignores the possibility of bypassing and returns the IOMMU table mask on the pseries platform which makes some drivers (mpt3sas is one example) choose 32bit DMA even though bypass is supported. The powernv platform sort of handles it by having a bigger default window with a mask >=40 but it only works as drivers choose 63/64bit if the required mask is >32 which is rather pointless. This reintroduces the bypass capability check to let drivers make a better choice of the DMA mask. Fixes: f1565c2 ("powerpc: use the generic dma_ops_bypass mode") Signed-off-by: Alexey Kardashevskiy <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e4e737b commit 23c216b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

arch/powerpc/kernel/dma-iommu.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@ u64 dma_iommu_get_required_mask(struct device *dev)
184184
struct iommu_table *tbl = get_iommu_table_base(dev);
185185
u64 mask;
186186

187+
if (dev_is_pci(dev)) {
188+
u64 bypass_mask = dma_direct_get_required_mask(dev);
189+
190+
if (dma_iommu_dma_supported(dev, bypass_mask)) {
191+
dev_info(dev, "%s: returning bypass mask 0x%llx\n", __func__, bypass_mask);
192+
return bypass_mask;
193+
}
194+
}
195+
187196
if (!tbl)
188197
return 0;
189198

0 commit comments

Comments
 (0)