Skip to content

Commit 685e3d1

Browse files
aikgregkh
authored andcommitted
powerpc/dma: Fix dma_map_ops::get_required_mask
commit 437ef80 upstream. There are 2 problems with it: 1. "<" vs expected "<<" 2. the shift number is an IOMMU page number mask, not an address mask as the IOMMU page shift is missing. This did not hit us before f1565c2 ("powerpc: use the generic dma_ops_bypass mode") because we had additional code to handle bypass mask so this chunk (almost?) never executed.However there were reports that aacraid does not work with "iommu=nobypass". After f1565c2, aacraid (and probably others which call dma_get_required_mask() before setting the mask) was unable to enable 64bit DMA and fall back to using IOMMU which was known not to work, one of the problems is double free of an IOMMU page. This fixes DMA for aacraid, both with and without "iommu=nobypass" in the kernel command line. Verified with "stress-ng -d 4". Fixes: 6a5c7be ("powerpc: Override dma_get_required_mask by platform hook and ops") Cc: [email protected] # v3.2+ Signed-off-by: Alexey Kardashevskiy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent be0d3b6 commit 685e3d1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/powerpc/kernel/dma-iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ u64 dma_iommu_get_required_mask(struct device *dev)
160160
return bypass_mask;
161161
}
162162

163-
mask = 1ULL < (fls_long(tbl->it_offset + tbl->it_size) - 1);
163+
mask = 1ULL << (fls_long(tbl->it_offset + tbl->it_size) +
164+
tbl->it_page_shift - 1);
164165
mask += mask - 1;
165166

166167
return mask;

0 commit comments

Comments
 (0)