From: David Matlack <dmatlack@google.com>
To: Rubin Du <rubind@nvidia.com>
Cc: Alex Williamson <alex@shazbot.org>, Shuah Khan <shuah@kernel.org>,
kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v10 1/2] selftests/vfio: Add NO_SEND_MSI feature flag and MSI helper macros
Date: Fri, 27 Mar 2026 22:04:37 +0000 [thread overview]
Message-ID: <acb-9VOaA6Ld9BdY@google.com> (raw)
In-Reply-To: <20260325214329.464727-2-rubind@nvidia.com>
On 2026-03-25 02:43 PM, Rubin Du wrote:
> diff --git a/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_driver.h b/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_driver.h
> index e5ada209b1d1..f2cf2608f757 100644
> --- a/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_driver.h
> +++ b/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_driver.h
> @@ -6,6 +6,8 @@
>
> struct vfio_pci_device;
>
> +#define VFIO_PCI_DRIVER_F_NO_SEND_MSI (1UL << 0) /* Device cannot trigger MSI */
I don't see any particular reason to add this flag. All of the checks
for...
device->driver.feature & VFIO_PCI_DRIVER_F_NO_SEND_MSI
can just be rewritten as...
!device->driver.ops->send_msi
to accomplish the same thing. And the latter is less characters while
still being readable.
> -void vfio_pci_driver_send_msi(struct vfio_pci_device *device)
> +int vfio_pci_driver_send_msi(struct vfio_pci_device *device)
> {
> struct vfio_pci_driver *driver = &device->driver;
>
> + if (driver->features & VFIO_PCI_DRIVER_F_NO_SEND_MSI)
> + return -EOPNOTSUPP;
> +
I think it would be better to just let vfio_pci_driver_send_msi() fail
if send_msi() is NULL.
Tests should not be calling vfio_pci_driver_send_msi() if the driver
does not support send_msi(). Tests that require send_msi() should
explicitly check for it, rather than detect it by trying to send an MSI.
It's also more readable to explicitly check for send_msi() support
rather than silently skipping or exiting if send_msi() returns an error.
The latter reads like it could be due to some problem on the device,
rather than just a lack of support in the driver.
> -#define ASSERT_NO_MSI(_eventfd) do { \
> - u64 __value; \
> - \
> - ASSERT_EQ(-1, read(_eventfd, &__value, 8)); \
> - ASSERT_EQ(EAGAIN, errno); \
> +#define fcntl_set_msi_nonblock(_self) do { \
> + if (!(_self->device->driver.features & VFIO_PCI_DRIVER_F_NO_SEND_MSI)) \
> + fcntl_set_nonblock(_self->msi_fd); \
> +} while (0)
I think it may be worthwhile to have the nv_falcon driver still enable
at least one MSI or MSI-x vector on the device and set driver->msi. This
will reduce divergence from other drivers, and simplify this commit down
to just:
diff --git a/tools/testing/selftests/vfio/vfio_pci_driver_test.c b/tools/testing/selftests/vfio/vfio_pci_driver_test.c
index afa0480ddd9b..ebd66d677abb 100644
--- a/tools/testing/selftests/vfio/vfio_pci_driver_test.c
+++ b/tools/testing/selftests/vfio/vfio_pci_driver_test.c
@@ -175,6 +175,9 @@ TEST_F(vfio_pci_driver_test, send_msi)
{
u64 value;
+ if (!self->device->driver.ops->send_msi)
+ SKIP(return, "Driver does not support send_msi()");
+
vfio_pci_driver_send_msi(self->device);
ASSERT_EQ(8, read(self->msi_fd, &value, 8));
ASSERT_EQ(1, value);
@@ -201,6 +204,9 @@ TEST_F(vfio_pci_driver_test, mix_and_match)
self->dst_iova,
self->size);
+ if (!self->device->driver.ops->send_msi)
+ continue;
+
vfio_pci_driver_send_msi(self->device);
ASSERT_EQ(8, read(self->msi_fd, &value, 8));
ASSERT_EQ(1, value);
> TEST_F(vfio_pci_driver_test, send_msi)
> {
> u64 value;
>
> - vfio_pci_driver_send_msi(self->device);
> + if (vfio_pci_driver_send_msi(self->device))
> + SKIP(return, "Device does not support MSI\n");
NV GPUs do support MSI/x though, right? This should probably be:
SKIP(return, "Driver does not support send_msi()\n");
next prev parent reply other threads:[~2026-03-27 22:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-25 21:43 [PATCH v10 0/2] selftests/vfio: Add NVIDIA GPU Falcon DMA test driver Rubin Du
2026-03-25 21:43 ` [PATCH v10 1/2] selftests/vfio: Add NO_SEND_MSI feature flag and MSI helper macros Rubin Du
2026-03-27 22:04 ` David Matlack [this message]
2026-03-30 20:15 ` Rubin Du
2026-03-25 21:43 ` [PATCH v10 2/2] selftests/vfio: Add NVIDIA Falcon driver for DMA testing Rubin Du
2026-03-27 22:38 ` David Matlack
2026-03-30 20:15 ` Rubin Du
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=acb-9VOaA6Ld9BdY@google.com \
--to=dmatlack@google.com \
--cc=alex@shazbot.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=rubind@nvidia.com \
--cc=shuah@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