* [PATCH] vfio: selftests: Support DMR and GNR-D DSA devices
@ 2026-03-19 7:27 Yi Lai
2026-03-19 18:18 ` David Matlack
0 siblings, 1 reply; 3+ messages in thread
From: Yi Lai @ 2026-03-19 7:27 UTC (permalink / raw)
To: Shuah Khan, David Matlack, Raghavendra Rao Ananta, Alex Mastro,
kvm, linux-kselftest, linux-kernel, yi1.lai
Currently, the VFIO DSA driver test only supports the SPR DSA device ID.
Attempting to run the test on newer platforms like DMR or GNR-D results
in a "No driver found" error, causing the test to be skipped.
Refactor the 'dsa_probe' function to use a switch statement for
checking device IDs. This improves maintainability and makes it easier
to add new device IDs in the future.
Add the following DSA device IDs to the supported list:
PCI_DEVICE_ID_INTEL_DSA_DMR (0x1212)
PCI_DEVICE_ID_INTEL_DSA_GNRD (0x11fb)
Signed-off-by: Yi Lai <yi1.lai@intel.com>
---
.../selftests/vfio/lib/drivers/dsa/dsa.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c b/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c
index c75045bcab79..0cbc7606d904 100644
--- a/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c
+++ b/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c
@@ -65,10 +65,23 @@ static bool dsa_int_handle_request_required(struct vfio_pci_device *device)
static int dsa_probe(struct vfio_pci_device *device)
{
- if (!vfio_pci_device_match(device, PCI_VENDOR_ID_INTEL,
- PCI_DEVICE_ID_INTEL_DSA_SPR0))
+ u16 vendor, device_id;
+
+ vendor = vfio_pci_config_readw(device, PCI_VENDOR_ID);
+ device_id = vfio_pci_config_readw(device, PCI_DEVICE_ID);
+
+ if (vendor != PCI_VENDOR_ID_INTEL)
return -EINVAL;
+ switch (device_id) {
+ case PCI_DEVICE_ID_INTEL_DSA_SPR0:
+ case PCI_DEVICE_ID_INTEL_DSA_DMR:
+ case PCI_DEVICE_ID_INTEL_DSA_GNRD:
+ break;
+ default:
+ return -EINVAL;
+ }
+
if (dsa_int_handle_request_required(device)) {
dev_err(device, "Device requires requesting interrupt handles\n");
return -EINVAL;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] vfio: selftests: Support DMR and GNR-D DSA devices
2026-03-19 7:27 [PATCH] vfio: selftests: Support DMR and GNR-D DSA devices Yi Lai
@ 2026-03-19 18:18 ` David Matlack
2026-03-20 0:56 ` Lai, Yi
0 siblings, 1 reply; 3+ messages in thread
From: David Matlack @ 2026-03-19 18:18 UTC (permalink / raw)
To: Yi Lai
Cc: Shuah Khan, Raghavendra Rao Ananta, Alex Mastro, kvm,
linux-kselftest, linux-kernel
On 2026-03-19 03:27 PM, Yi Lai wrote:
> Currently, the VFIO DSA driver test only supports the SPR DSA device ID.
> Attempting to run the test on newer platforms like DMR or GNR-D results
> in a "No driver found" error, causing the test to be skipped.
>
> Refactor the 'dsa_probe' function to use a switch statement for
nit: s/Refactor the 'dsa_probe' function/Refactor dsa_probe()/
If you append () to the end of function names in commit messages and
comments it makes it clear you are referring to a function.
> checking device IDs. This improves maintainability and makes it easier
> to add new device IDs in the future.
>
> Add the following DSA device IDs to the supported list:
> PCI_DEVICE_ID_INTEL_DSA_DMR (0x1212)
> PCI_DEVICE_ID_INTEL_DSA_GNRD (0x11fb)
>
> Signed-off-by: Yi Lai <yi1.lai@intel.com>
Thanks for the patch. Looks good aside from some small nits.
Were you able to test that vfio_pci_driver_test passes with both of the new
devices?
> ---
> .../selftests/vfio/lib/drivers/dsa/dsa.c | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c b/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c
> index c75045bcab79..0cbc7606d904 100644
> --- a/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c
> +++ b/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c
> @@ -65,10 +65,23 @@ static bool dsa_int_handle_request_required(struct vfio_pci_device *device)
>
> static int dsa_probe(struct vfio_pci_device *device)
> {
> - if (!vfio_pci_device_match(device, PCI_VENDOR_ID_INTEL,
> - PCI_DEVICE_ID_INTEL_DSA_SPR0))
> + u16 vendor, device_id;
> +
> + vendor = vfio_pci_config_readw(device, PCI_VENDOR_ID);
> + device_id = vfio_pci_config_readw(device, PCI_DEVICE_ID);
> +
> + if (vendor != PCI_VENDOR_ID_INTEL)
> return -EINVAL;
nit: s/vendor/vendor_id/ to be consistent with device_id and
vfio_pci_device_match().
Also you can initialized these variables when they are declared to
simplify the code a bit. e.g.
diff --git a/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c b/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c
index 0cbc7606d904..19d9630b24c2 100644
--- a/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c
+++ b/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c
@@ -65,12 +65,10 @@ static bool dsa_int_handle_request_required(struct vfio_pci_device *device)
static int dsa_probe(struct vfio_pci_device *device)
{
- u16 vendor, device_id;
+ const u16 vendor_id = vfio_pci_config_readw(device, PCI_VENDOR_ID);
+ const u16 device_id = vfio_pci_config_readw(device, PCI_DEVICE_ID);
- vendor = vfio_pci_config_readw(device, PCI_VENDOR_ID);
- device_id = vfio_pci_config_readw(device, PCI_DEVICE_ID);
-
- if (vendor != PCI_VENDOR_ID_INTEL)
+ if (vendor_id != PCI_VENDOR_ID_INTEL)
return -EINVAL;
switch (device_id) {
>
> + switch (device_id) {
> + case PCI_DEVICE_ID_INTEL_DSA_SPR0:
> + case PCI_DEVICE_ID_INTEL_DSA_DMR:
> + case PCI_DEVICE_ID_INTEL_DSA_GNRD:
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> if (dsa_int_handle_request_required(device)) {
> dev_err(device, "Device requires requesting interrupt handles\n");
> return -EINVAL;
> --
> 2.43.0
>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] vfio: selftests: Support DMR and GNR-D DSA devices
2026-03-19 18:18 ` David Matlack
@ 2026-03-20 0:56 ` Lai, Yi
0 siblings, 0 replies; 3+ messages in thread
From: Lai, Yi @ 2026-03-20 0:56 UTC (permalink / raw)
To: David Matlack
Cc: Yi Lai, Shuah Khan, Raghavendra Rao Ananta, Alex Mastro, kvm,
linux-kselftest, linux-kernel
On Thu, Mar 19, 2026 at 06:18:13PM +0000, David Matlack wrote:
> On 2026-03-19 03:27 PM, Yi Lai wrote:
> > Currently, the VFIO DSA driver test only supports the SPR DSA device ID.
> > Attempting to run the test on newer platforms like DMR or GNR-D results
> > in a "No driver found" error, causing the test to be skipped.
> >
> > Refactor the 'dsa_probe' function to use a switch statement for
>
> nit: s/Refactor the 'dsa_probe' function/Refactor dsa_probe()/
>
> If you append () to the end of function names in commit messages and
> comments it makes it clear you are referring to a function.
>
> > checking device IDs. This improves maintainability and makes it easier
> > to add new device IDs in the future.
> >
> > Add the following DSA device IDs to the supported list:
> > PCI_DEVICE_ID_INTEL_DSA_DMR (0x1212)
> > PCI_DEVICE_ID_INTEL_DSA_GNRD (0x11fb)
> >
> > Signed-off-by: Yi Lai <yi1.lai@intel.com>
>
> Thanks for the patch. Looks good aside from some small nits.
Thanks for reviewing the patch. I will send v2 adopting your comments.
>
> Were you able to test that vfio_pci_driver_test passes with both of the new
> devices?
I tested vfio_pci_driver_test with DMR DSA device. All tests pass.
>
> > ---
> > .../selftests/vfio/lib/drivers/dsa/dsa.c | 17 +++++++++++++++--
> > 1 file changed, 15 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c b/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c
> > index c75045bcab79..0cbc7606d904 100644
> > --- a/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c
> > +++ b/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c
> > @@ -65,10 +65,23 @@ static bool dsa_int_handle_request_required(struct vfio_pci_device *device)
> >
> > static int dsa_probe(struct vfio_pci_device *device)
> > {
> > - if (!vfio_pci_device_match(device, PCI_VENDOR_ID_INTEL,
> > - PCI_DEVICE_ID_INTEL_DSA_SPR0))
> > + u16 vendor, device_id;
> > +
> > + vendor = vfio_pci_config_readw(device, PCI_VENDOR_ID);
> > + device_id = vfio_pci_config_readw(device, PCI_DEVICE_ID);
> > +
> > + if (vendor != PCI_VENDOR_ID_INTEL)
> > return -EINVAL;
>
> nit: s/vendor/vendor_id/ to be consistent with device_id and
> vfio_pci_device_match().
>
> Also you can initialized these variables when they are declared to
> simplify the code a bit. e.g.
>
> diff --git a/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c b/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c
> index 0cbc7606d904..19d9630b24c2 100644
> --- a/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c
> +++ b/tools/testing/selftests/vfio/lib/drivers/dsa/dsa.c
> @@ -65,12 +65,10 @@ static bool dsa_int_handle_request_required(struct vfio_pci_device *device)
>
> static int dsa_probe(struct vfio_pci_device *device)
> {
> - u16 vendor, device_id;
> + const u16 vendor_id = vfio_pci_config_readw(device, PCI_VENDOR_ID);
> + const u16 device_id = vfio_pci_config_readw(device, PCI_DEVICE_ID);
>
> - vendor = vfio_pci_config_readw(device, PCI_VENDOR_ID);
> - device_id = vfio_pci_config_readw(device, PCI_DEVICE_ID);
> -
> - if (vendor != PCI_VENDOR_ID_INTEL)
> + if (vendor_id != PCI_VENDOR_ID_INTEL)
> return -EINVAL;
>
> switch (device_id) {
>
> >
> > + switch (device_id) {
> > + case PCI_DEVICE_ID_INTEL_DSA_SPR0:
> > + case PCI_DEVICE_ID_INTEL_DSA_DMR:
> > + case PCI_DEVICE_ID_INTEL_DSA_GNRD:
> > + break;
> > + default:
> > + return -EINVAL;
> > + }
> > +
> > if (dsa_int_handle_request_required(device)) {
> > dev_err(device, "Device requires requesting interrupt handles\n");
> > return -EINVAL;
> > --
> > 2.43.0
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-20 0:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 7:27 [PATCH] vfio: selftests: Support DMR and GNR-D DSA devices Yi Lai
2026-03-19 18:18 ` David Matlack
2026-03-20 0:56 ` Lai, Yi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox