[PATCH v12 0/4] selftests/vfio: Add NVIDIA GPU Falcon DMA test driver

Rubin Du
2026-04-03T23:44:50Z

Patch 1:

Add a chunking loop to vfio_pci_driver_memcpy() so that it handles
arbitrarily sized memcpy requests by breaking them into
max_memcpy_size-sized chunks. This allows tests to request any memcpy
size. Update the test to use a size of 4x max_memcpy_size to exercise
the chunking logic.

Patch 2:

Add vfio_pci_cmd_set()/vfio_pci_cmd_clear() macros for PCI_COMMAND
operations.

Patch 3:

Allow drivers that cannot trigger MSI interrupts to leave the
send_msi callback NULL. Tests check ops->send_msi directly and
gracefully skip MSI-related operations when it is absent.

Patch 4:

Introduce the nv_falcon plugin driver, which extracts and adapts
relevant functionality from NVIDIA's gpu-admin-tools project [1] and
integrates it into the VFIO selftest framework. As a result, any
system equipped with a PCIe slot and a supported NVIDIA GPU can now
run VFIO DMA selftests using commonly available hardware.

Falcons are general-purpose microcontrollers present on NVIDIA GPUs
that can perform DMA operations between system memory and device
memory.

[1] https://github.com/NVIDIA/gpu-admin-tools

Note on version numbering: v1 through v9 were internal review
iterations that were mistakenly carried over to the upstream
submission. Apologies for the confusion, the internal changelog
has been dropped.

Changes in v12:
- Split into 4 patches: moved PCI command macros into their own
patch
- Placed PCI command macros next to the existing vfio_pci_config_*()
routines
- Fixed memcpy_storm size to cap at memcpy_region.size / 2

Changes in v11:
- Split into 3 patches: added precursor patch that moves
memcpy chunking into vfio_pci_driver_memcpy() and adds generic
vfio_pci_cmd_set()/vfio_pci_cmd_clear() PCI command helpers
- Replaced feature flag with NULL send_msi callback check
- Renamed nv_falcons/ to nv_falcon/; moved struct gpu_device to
.c file; renamed to_nv_gpu() to to_gpu_device()
- Allow gpu_poll_register() and fsp_poll_queue() callers to
propagate timeout errors
- Fixed macro alignment in hw.h

Changes in v10:
- Replaced NULL pointer checks on send_msi() with per-device
VFIO_PCI_DRIVER_F_NO_SEND_MSI feature flag
- Changed vfio_pci_driver_send_msi() to return int with the feature
check moved inside, so callers branch on the return value
- Added fcntl_set_msi_nonblock(self) and updated ASSERT_NO_MSI(self)
macros that check the flag internally
- Moved DMA execution from memcpy_start() to memcpy_wait() so that
memcpy_start() stores parameters and returns immediately, emulating
async behavior to conform to the memcpy_start()/memcpy_wait() contract
- Split GPU_ARCH_PASCAL into GPU_ARCH_PASCAL (P100, PMC reset) and
GPU_ARCH_PASCAL_10X (P4/P40, engine reset) to match per-product
reset behavior
- Minor cleanups: improved size_to_dma_encoding(), fixed DMA address
bits mask

Rubin Du (4):
selftests/vfio: Add memcpy chunking to vfio_pci_driver_memcpy()
selftests/vfio: Add generic PCI command register helpers
selftests/vfio: Allow drivers without send_msi() support
selftests/vfio: Add NVIDIA Falcon driver for DMA testing

.../selftests/vfio/lib/drivers/nv_falcon/hw.h | 348 ++++++++
.../vfio/lib/drivers/nv_falcon/nv_falcon.c | 755 ++++++++++++++++++
.../lib/include/libvfio/vfio_pci_device.h | 10 +
tools/testing/selftests/vfio/lib/libvfio.mk | 2 +
.../selftests/vfio/lib/vfio_pci_driver.c | 21 +-
.../selftests/vfio/vfio_pci_driver_test.c | 57 +-
6 files changed, 1170 insertions(+), 23 deletions(-)
create mode 100644 tools/testing/selftests/vfio/lib/drivers/nv_falcon/hw.h
create mode 100644 tools/testing/selftests/vfio/lib/drivers/nv_falcon/nv_falcon.c

--
2.43.0