From: Leon Romanovsky <leon@kernel.org>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: vkoul@kernel.org, chenxiang66@hisilicon.com,
m.szyprowski@samsung.com, robin.murphy@arm.com, jgg@nvidia.com,
alex.williamson@redhat.com, joel.granados@kernel.org,
iommu@lists.linux.dev, dmaengine@vger.kernel.org,
linux-block@vger.kernel.org, gost.dev@samsung.com
Subject: Re: [PATCH 0/6] dma: fake-dma and IOVA tests
Date: Wed, 21 May 2025 14:17:38 +0300 [thread overview]
Message-ID: <20250521111738.GL7435@unreal> (raw)
In-Reply-To: <20250520223913.3407136-1-mcgrof@kernel.org>
On Tue, May 20, 2025 at 03:39:07PM -0700, Luis Chamberlain wrote:
> 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.
I'm not sure if this is what you meant, but I'm configuring QEMU in nested VM
mode. It gives me emulated hypervisor with working IOMMU path, which I
tested with NVMe and RDMA.
My QEMU command line is:
/usr/bin/qemu-system-x86_64 -append root=/dev/root rw \
ignore_loglevel rootfstype=9p rootflags="cache=loose,trans=virtio" \
earlyprintk=serial,ttyS0,115200 console=hvc0 panic_on_warn=1 intel_iommu=on \
iommu=nopt iommu.forcedac=1 vfio_iommu_type1.allow_unsafe_interrupts=1 \
systemd.hostname=mtl-leonro-d-vm \
-chardev stdio,id=stdio,mux=on,signal=off \
-cpu host \
-device virtio-rng-pci \
-device virtio-balloon-pci \
-device isa-serial,chardev=stdio \
-device virtio-serial-pci \
-device virtconsole,chardev=stdio \
-device virtio-9p-pci,fsdev=host_fs,mount_tag=/dev/root \
-device virtio-9p-pci,fsdev=host_bind_fs0,mount_tag=bind0 \
-device virtio-9p-pci,fsdev=host_bind_fs1,mount_tag=bind1 \
-device virtio-9p-pci,fsdev=host_bind_fs2,mount_tag=bind2 \
-device intel-iommu,intremap=on \
-device nvme-subsys,id=bar \
-device nvme,id=baz,subsys=bar,serial=qux \
-device nvme-ns,drive=foo,bus=baz,logical_block_size=4096,physical_block_size=4096,ms=16 \
-drive file=/home/leonro/.cache/mellanox/mkt/nvme-1g.raw,format=raw,if=none,id=foo \
-enable-kvm \
-fsdev local,id=host_bind_fs2,security_model=none,path=/home/leonro \
-fsdev local,id=host_bind_fs0,security_model=none,path=/plugins \
-fsdev local,id=host_fs,security_model=none,path=/mnt/self \
-fsdev local,id=host_bind_fs1,security_model=none,path=/logs \
-fw_cfg etc/sercon-port,string=2 \
-kernel /home/leonro/src/kernel/arch/x86/boot/bzImage \
-m 4G \
-machine q35,kernel-irqchip=split \
-mon chardev=stdio \
-net nic,model=virtio,macaddr=52:54:9a:c5:60:66 \
-net user,hostfwd=tcp:127.0.0.1:54409-:22 \
-no-reboot \
-nodefaults \
-nographic \
-smp 64 \
-vga none%
>
> 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
>
> --
> 2.47.2
>
>
prev parent reply other threads:[~2025-05-21 11:17 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-20 22:39 [PATCH 0/6] dma: fake-dma and IOVA tests Luis Chamberlain
2025-05-20 22:39 ` [PATCH 1/6] fake-dma: add fake dma engine driver Luis Chamberlain
2025-05-21 14:20 ` Robin Murphy
2025-05-21 17:07 ` Luis Chamberlain
2025-05-22 11:18 ` Marek Szyprowski
2025-05-22 16:59 ` Luis Chamberlain
2025-05-22 19:38 ` Luis Chamberlain
2025-05-21 23:40 ` kernel test robot
2025-05-20 22:39 ` [PATCH 2/6] dmatest: split dmatest_func() into helpers Luis Chamberlain
2025-05-20 22:39 ` [PATCH 3/6] dmatest: move printing to its own routine Luis Chamberlain
2025-05-21 14:41 ` Robin Murphy
2025-05-21 17:10 ` Luis Chamberlain
2025-05-21 22:26 ` kernel test robot
2025-05-20 22:39 ` [PATCH 4/6] dmatest: add IOVA tests Luis Chamberlain
2025-05-20 22:39 ` [PATCH 5/6] dma-mapping: benchmark: move validation parameters into a helper Luis Chamberlain
2025-05-20 22:39 ` [PATCH 6/6] dma-mapping: benchmark: add IOVA support Luis Chamberlain
2025-05-21 11:58 ` kernel test robot
2025-05-21 16:08 ` Robin Murphy
2025-05-21 17:17 ` Luis Chamberlain
2025-05-21 11:17 ` Leon Romanovsky [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250521111738.GL7435@unreal \
--to=leon@kernel.org \
--cc=alex.williamson@redhat.com \
--cc=chenxiang66@hisilicon.com \
--cc=dmaengine@vger.kernel.org \
--cc=gost.dev@samsung.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joel.granados@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mcgrof@kernel.org \
--cc=robin.murphy@arm.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).