Skip to content

dma: fake-dma and IOVA tests

Luis Chamberlain dmaengine linux-block linux-iommu llvm oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 10 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6fake-dma: add fake dma engine driverdrivers/dma/Kconfig drivers/dma/Makefile drivers/dma/fake-dma.c+730 -05 replies
2/6dmatest: split dmatest_func() into helpersdrivers/dma/dmatest.c+320 -2870 replies
3/6dmatest: move printing to its own routinedrivers/dma/dmatest.c+58 -192 replies
4/6dmatest: add IOVA testsdrivers/dma/dmatest.c+229 -560 replies
5/6dma-mapping: benchmark: move validation parameters into a helperkernel/dma/map_benchmark.c+54 -450 replies
6/6dma-mapping: benchmark: add IOVA supportinclude/linux/map_benchmark.h kernel/dma/Kconfig kernel/dma/map_benchmark.c +1 more+562 -152 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/6] dma: fake-dma and IOVA tests

We don't seem to have unit tests for the DMA IOVA API, so I figured we should add some so to ensure we don't regress moving forward, and it allows us to extend these later. Its best to just extend existing tests though. I've found two tests so I've extended them as part of this patchset:

- drivers/dma/dmatest.c
- kernel/dma/map_benchmark.c

However running the dmatest requires some old x86 emulation or some non-upstream qemu patches for intel IOAT a q35 system. This make this easier by providing a simple in-kernel fake-dma controller to let you test run all dmatests on most systems. The only issue I found with that was not being able to get the platform device through an IOMMU for DMA. If folks have an idea of how to make it easy for a platform device to get an IOMMU for DMA it would make it easier to allow us to leverage the existing dmatest for IOVA as well. I only tried briefly with virtio and vfio_iommu_type1, but gave up fast. Not sure if its easy to later allow a platform device like this one to leverage it to make it easier for testing.

The kernel/dma/map_benchmark.c test is extended as well, for that I was able to add follow the instructions on the first commit from that test, by unbinding a device and attaching it to the map benchmark.

I tried twiddle a mocked IOMMU with iommufd on a q35 guest, but alas, that just didn't work as I'd hope, ie, nothing, and so this is the best I have for now to help test IOVA DMA API on a virtualized setup.

Let me know if others have other recomendations.

The hope is to get a CI eventually going to ensure these don't regress.

Luis Chamberlain (6):
fake-dma: add fake dma engine driver
dmatest: split dmatest_func() into helpers
dmatest: move printing to its own routine
dmatest: add IOVA tests
dma-mapping: benchmark: move validation parameters into a helper
dma-mapping: benchmark: add IOVA support

 drivers/dma/Kconfig                           |  11 +
 drivers/dma/Makefile                          |   1 +
 drivers/dma/dmatest.c                         | 795 ++++++++++++------
 drivers/dma/fake-dma.c                        | 718 ++++++++++++++++
 include/linux/map_benchmark.h                 |  11 +
 kernel/dma/Kconfig                            |   4 +-
 kernel/dma/map_benchmark.c                    | 512 +++++++++--
 .../testing/selftests/dma/dma_map_benchmark.c | 145 +++-
 8 files changed, 1864 insertions(+), 333 deletions(-)
 create mode 100644 drivers/dma/fake-dma.c
Signature · 1 line
2.47.2