Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 21a037a4 authored by Isaac J. Manjarres's avatar Isaac J. Manjarres Committed by Gerrit - the friendly Code Review server
Browse files

iommu: iommu-debug: Fix functional_fast_dma test



The __full_va_sweep() function within the functional fast DMA
test assumes that the first available mapping within the IOVA
space will be address 0. This was true when the IOVA allocation
code unconditionally set the starting search address to 0 when
it tried to wrap around to find an IOVA. However, since that is
no longer the case, change __full_va_sweep() to ensure that
the starting search address is 0 before executing the test.

Change-Id: Ib264475769fc945c1b9c74225d4189f5a2d912a6
Signed-off-by: default avatarIsaac J. Manjarres <isaacm@codeaurora.org>
parent a65504bf
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -940,6 +940,24 @@ static int __full_va_sweep(struct device *dev, struct seq_file *s,
	}
	phys = virt_to_phys(virt);

	/*
	 * A previous test might have made it so that the next IOVA that we
	 * start to search from is not 0, so map the entire IOVA space, and
	 * then unmap it to reset the starting IOVA to search from to address
	 * 0.
	 */
	dma_addr = dma_map_single_attrs(dev, virt, SZ_1G * 4ULL, DMA_TO_DEVICE,
					DMA_ATTR_SKIP_CPU_SYNC);
	if (dma_mapping_error(dev, dma_addr)) {
		dev_err_ratelimited(dev,
				    "Failed to map all of the IOVA space\n");
		ret = -ENOMEM;
		goto out_free_pages;
	}

	dma_unmap_single_attrs(dev, dma_addr, SZ_1G * 4ULL, DMA_TO_DEVICE,
			       DMA_ATTR_SKIP_CPU_SYNC);

	for (iova = 0, i = 0; iova < max; iova += size, ++i) {
		unsigned long expected = iova;

@@ -991,6 +1009,7 @@ static int __full_va_sweep(struct device *dev, struct seq_file *s,
	for (iova = 0; iova < max; iova += size)
		dma_unmap_single(dev, (dma_addr_t)iova, size, DMA_TO_DEVICE);

out_free_pages:
	free_pages((unsigned long)virt, get_order(size));
	return ret;
}