diff options
| author | Rubin Du <rubind@nvidia.com> | 2026-06-09 16:28:52 -0700 |
|---|---|---|
| committer | Alex Williamson <alex@shazbot.org> | 2026-07-17 08:39:34 -0600 |
| commit | df34ecc52526480a1a4bb78bc75bfb009c6076a4 (patch) | |
| tree | c4992371daf019beac1823e662af7179a0a27c55 /tools/testing/selftests/vfio/lib | |
| parent | a13c140cc289c0b7b3770bce5b3ad42ab35074aa (diff) | |
| download | linux-next-df34ecc52526480a1a4bb78bc75bfb009c6076a4.tar.gz linux-next-df34ecc52526480a1a4bb78bc75bfb009c6076a4.zip | |
vfio: selftests: Add memcpy chunking to vfio_pci_driver_memcpy()
Add a chunking loop to vfio_pci_driver_memcpy() so that it breaks up
large memcpy requests into max_memcpy_size-sized chunks. This allows
callers to request any size without worrying about per-driver limits.
The memcpy_start()/memcpy_wait() semantics are unchanged.
Update the test to use 4x max_memcpy_size so it exercises the new
chunking path (4 iterations) while keeping execution fast for drivers
with small DMA transfer sizes.
Reviewed-by: David Matlack <dmatlack@google.com>
Signed-off-by: Alex Williamson <alex.williamson@nvidia.com>
Signed-off-by: Rubin Du <rubind@nvidia.com>
Link: https://lore.kernel.org/r/20260609232855.3808971-2-rubind@nvidia.com
Signed-off-by: Alex Williamson <alex@shazbot.org>
Diffstat (limited to 'tools/testing/selftests/vfio/lib')
| -rw-r--r-- | tools/testing/selftests/vfio/lib/vfio_pci_driver.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tools/testing/selftests/vfio/lib/vfio_pci_driver.c b/tools/testing/selftests/vfio/lib/vfio_pci_driver.c index 6827f4a6febe..e6c5b9c703f4 100644 --- a/tools/testing/selftests/vfio/lib/vfio_pci_driver.c +++ b/tools/testing/selftests/vfio/lib/vfio_pci_driver.c @@ -106,7 +106,21 @@ int vfio_pci_driver_memcpy_wait(struct vfio_pci_device *device) int vfio_pci_driver_memcpy(struct vfio_pci_device *device, iova_t src, iova_t dst, u64 size) { - vfio_pci_driver_memcpy_start(device, src, dst, size, 1); + struct vfio_pci_driver *driver = &device->driver; + u64 offset = 0; + + while (offset < size) { + u64 chunk = min(size - offset, driver->max_memcpy_size); + int ret; + + vfio_pci_driver_memcpy_start(device, src + offset, + dst + offset, chunk, 1); + ret = vfio_pci_driver_memcpy_wait(device); + if (ret) + return ret; + + offset += chunk; + } - return vfio_pci_driver_memcpy_wait(device); + return 0; } |
