Skip to content

Commit 4855c92

Browse files
joejin00konradwilk
authored andcommitted
xen-swiotlb: fix the check condition for xen_swiotlb_free_coherent
When run raidconfig from Dom0 we found that the Xen DMA heap is reduced, but Dom Heap is increased by the same size. Tracing raidconfig we found that the related ioctl() in megaraid_sas will call dma_alloc_coherent() to apply memory. If the memory allocated by Dom0 is not in the DMA area, it will exchange memory with Xen to meet the requiment. Later drivers call dma_free_coherent() to free the memory, on xen_swiotlb_free_coherent() the check condition (dev_addr + size - 1 <= dma_mask) is always false, it prevents calling xen_destroy_contiguous_region() to return the memory to the Xen DMA heap. This issue introduced by commit 6810df8 "xen-swiotlb: When doing coherent alloc/dealloc check before swizzling the MFNs.". Signed-off-by: Joe Jin <[email protected]> Tested-by: John Sobecki <[email protected]> Reviewed-by: Rzeszutek Wilk <[email protected]> Cc: [email protected] Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
1 parent 75bc37f commit 4855c92

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/xen/swiotlb-xen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ xen_swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
351351
* physical address */
352352
phys = xen_bus_to_phys(dev_addr);
353353

354-
if (((dev_addr + size - 1 > dma_mask)) ||
354+
if (((dev_addr + size - 1 <= dma_mask)) ||
355355
range_straddles_page_boundary(phys, size))
356356
xen_destroy_contiguous_region(phys, order);
357357

0 commit comments

Comments
 (0)