Skip to content

Commit 54dd5d6

Browse files
johnernberggregkh
authored andcommitted
xen: swiotlb: Use swiotlb bouncing if kmalloc allocation demands it
commit cd9c058 upstream. Xen swiotlb support was missed when the patch set starting with 4ab5f8e ("mm/slab: decouple ARCH_KMALLOC_MINALIGN from ARCH_DMA_MINALIGN") was merged. When running Xen on iMX8QXP, a SoC without IOMMU, the effect was that USB transfers ended up corrupted when there was more than one URB inflight at the same time. Add a call to dma_kmalloc_needs_bounce() to make sure that allocations too small for DMA get bounced via swiotlb. Closes: https://lore.kernel.org/linux-usb/[email protected]/ Fixes: 4ab5f8e ("mm/slab: decouple ARCH_KMALLOC_MINALIGN from ARCH_DMA_MINALIGN") Cc: [email protected] # v6.5+ Signed-off-by: John Ernberg <[email protected]> Reviewed-by: Stefano Stabellini <[email protected]> Signed-off-by: Juergen Gross <[email protected]> Message-ID: <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 571dcf3 commit 54dd5d6

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/xen/swiotlb-xen.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ static dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page,
217217
* buffering it.
218218
*/
219219
if (dma_capable(dev, dev_addr, size, true) &&
220+
!dma_kmalloc_needs_bounce(dev, size, dir) &&
220221
!range_straddles_page_boundary(phys, size) &&
221222
!xen_arch_need_swiotlb(dev, phys, dev_addr) &&
222223
!is_swiotlb_force_bounce(dev))

0 commit comments

Comments
 (0)