[PATCH 1/2] vfio: selftests: Find devices that are compatible with VFIO selftests
From: Josh Hilke
Date: Wed Apr 08 2026 - 21:52:14 EST
Update the VFIO selftest setup script to print the segment:bus:device.function
numbers of devices on the user's system that have VFIO selftest drivers (i.e.
are compatible with the VFIO selftest infrastructure). This makes it easy for
users to quickly find devices that are compatible with VFIO selftests.
Example of how to list compatible devices on the system:
$ ./tools/testing/selftests/vfio/scripts/setup.sh -l
Supported devices:
0000:6a:01.0
0000:6f:01.0
0000:74:01.0
0000:79:01.0
0000:e7:01.0
0000:ec:01.0
0000:f1:01.0
0000:f6:01.0
Example of setting up a device:
$ ./tools/testing/selftests/vfio/scripts/setup.sh -d 0000:6a:01.0
+ echo "0000:6a:01.0" > /sys/bus/pci/drivers/idxd/unbind
+ echo "vfio-pci" > /sys/bus/pci/devices/0000:6a:01.0/driver_override
+ echo "0000:6a:01.0" > /sys/bus/pci/drivers/vfio-pci/bind
Successfully set up 0000:6a:01.0
This makes the script much more user friendly so that no one has to dig
around in the VFIO selftest libraries to figure out which devices can
run the selftests.
Signed-off-by: Josh Hilke <jrhilke@xxxxxxxxxx>
---
tools/testing/selftests/vfio/scripts/setup.sh | 43 +++++++++++++++++--
1 file changed, 40 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/vfio/scripts/setup.sh b/tools/testing/selftests/vfio/scripts/setup.sh
index 49a499e51cbe..2cde07eb9c8b 100755
--- a/tools/testing/selftests/vfio/scripts/setup.sh
+++ b/tools/testing/selftests/vfio/scripts/setup.sh
@@ -3,18 +3,54 @@ set -e
source $(dirname -- "${BASH_SOURCE[0]}")/lib.sh
+# List of devices which have a VFIO selftest driver
+DEVICES=(
+ "8086:0b25" # Intel Data Streaming Accelerator
+ "8086:0cf8" # Intel CBDMA
+)
+
+function print_supported_devices() {
+ local vendor_device_id
+ local id
+
+ for vendor_device_id in "${DEVICES[@]}"; do
+ read -r id <<< "${vendor_device_id}"
+ lspci -D -d "${id}" | awk '{ print $1 }'
+ done
+}
+
+function usage() {
+ echo "usage: $0 [-l] [-d <segment:bus:device.function>]" >&2
+ echo "" >&2
+ echo " -l List segment:bus:device.function numbers of supported devices." >&2
+ echo " -d segment:bus:device.function to set up." >&2
+}
+
function main() {
local device_bdf
local device_dir
local numvfs
local driver
+ local bdf_list=()
+
+ while getopts "ld:" opt; do
+ case ${opt} in
+ l)
+ echo "Supported devices: "
+ print_supported_devices
+ exit 0
+ ;;
+ d) bdf_list+=("${OPTARG}") ;;
+ *) usage; exit 1 ;;
+ esac
+ done
- if [ $# = 0 ]; then
- echo "usage: $0 segment:bus:device.function ..." >&2
+ if [ ${#bdf_list[@]} -eq 0 ]; then
+ usage
exit 1
fi
- for device_bdf in "$@"; do
+ for device_bdf in "${bdf_list[@]}"; do
test -d /sys/bus/pci/devices/${device_bdf}
device_dir=${DEVICES_DIR}/${device_bdf}
@@ -42,6 +78,7 @@ function main() {
bind ${device_bdf} vfio-pci
touch ${device_dir}/vfio-pci
+ echo "Successfully set up ${device_bdf}"
done
}
--
2.53.0.1213.gd9a14994de-goog