[PATCH v9 1/2] selftests/vfio: Skip MSI tests for drivers that cannot raise interrupts

Rubin Du posted 2 patches 2 weeks, 5 days ago
There is a newer version of this series
[PATCH v9 1/2] selftests/vfio: Skip MSI tests for drivers that cannot raise interrupts
Posted by Rubin Du 2 weeks, 5 days ago
Some device drivers may not have the capability to trigger MSI/MSI-X
interrupts from software. Add checks to skip the send_msi test and
the MSI portion of the mix_and_match test when the driver's send_msi
callback is NULL, allowing these drivers to still run the DMA tests.

Signed-off-by: Rubin Du <rubind@nvidia.com>
---
 .../selftests/vfio/lib/include/libvfio/vfio_pci_device.h  | 3 +++
 tools/testing/selftests/vfio/vfio_pci_driver_test.c       | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h b/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h
index 2858885a89bb..a497fc990924 100644
--- a/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h
+++ b/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h
@@ -74,6 +74,9 @@ static inline void fcntl_set_nonblock(int fd)
 {
 	int r;
 
+	if (fd == -1)
+		return;
+
 	r = fcntl(fd, F_GETFL, 0);
 	VFIO_ASSERT_NE(r, -1, "F_GETFL failed for fd %d\n", fd);
 
diff --git a/tools/testing/selftests/vfio/vfio_pci_driver_test.c b/tools/testing/selftests/vfio/vfio_pci_driver_test.c
index afa0480ddd9b..8269da741b67 100644
--- a/tools/testing/selftests/vfio/vfio_pci_driver_test.c
+++ b/tools/testing/selftests/vfio/vfio_pci_driver_test.c
@@ -14,6 +14,8 @@ static const char *device_bdf;
 #define ASSERT_NO_MSI(_eventfd) do {			\
 	u64 __value;					\
 							\
+	if (_eventfd == -1)				\
+		break;					\
 	ASSERT_EQ(-1, read(_eventfd, &__value, 8));	\
 	ASSERT_EQ(EAGAIN, errno);			\
 } while (0)
@@ -175,6 +177,9 @@ TEST_F(vfio_pci_driver_test, send_msi)
 {
 	u64 value;
 
+	if (self->device->driver.ops->send_msi == NULL)
+		SKIP(return, "Device does not support MSI\n");
+
 	vfio_pci_driver_send_msi(self->device);
 	ASSERT_EQ(8, read(self->msi_fd, &value, 8));
 	ASSERT_EQ(1, value);
@@ -201,6 +206,9 @@ TEST_F(vfio_pci_driver_test, mix_and_match)
 				       self->dst_iova,
 				       self->size);
 
+		if (self->device->driver.ops->send_msi == NULL)
+			continue;
+
 		vfio_pci_driver_send_msi(self->device);
 		ASSERT_EQ(8, read(self->msi_fd, &value, 8));
 		ASSERT_EQ(1, value);
-- 
2.43.0
Re: [PATCH v9 1/2] selftests/vfio: Skip MSI tests for drivers that cannot raise interrupts
Posted by David Matlack 2 weeks, 4 days ago
On 2026-03-17 02:42 PM, Rubin Du wrote:
> Some device drivers may not have the capability to trigger MSI/MSI-X
> interrupts from software. Add checks to skip the send_msi test and
> the MSI portion of the mix_and_match test when the driver's send_msi
> callback is NULL, allowing these drivers to still run the DMA tests.

I would prefer not to make send_msi() optional if possible. We sould
need changes like this in all future tests that want to use send_msi().

Is there really no way for the nv_falcon to do something to cause the NV
GPU to send an MSI?