Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vfio: selftests: Add test to reset vfio device.

Add a test to vfio_pci_device_test which resets the device. If reset is
not supported by the device, the test is skipped.

Signed-off-by: Josh Hilke <jrhilke@google.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: David Matlack <dmatlack@google.com>
Link: https://lore.kernel.org/r/20250822212518.4156428-7-dmatlack@google.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>

authored by

Josh Hilke and committed by
Alex Williamson
a0fd0af5 b477e7bc

+14
+1
tools/testing/selftests/vfio/lib/include/vfio_util.h
··· 83 83 84 84 struct vfio_pci_device *vfio_pci_device_init(const char *bdf, int iommu_type); 85 85 void vfio_pci_device_cleanup(struct vfio_pci_device *device); 86 + void vfio_pci_device_reset(struct vfio_pci_device *device); 86 87 87 88 void vfio_pci_dma_map(struct vfio_pci_device *device, u64 iova, u64 size, 88 89 void *vaddr);
+5
tools/testing/selftests/vfio/lib/vfio_pci_device.c
··· 202 202 write ? "write to" : "read from", config); 203 203 } 204 204 205 + void vfio_pci_device_reset(struct vfio_pci_device *device) 206 + { 207 + ioctl_assert(device->fd, VFIO_DEVICE_RESET, NULL); 208 + } 209 + 205 210 static unsigned int vfio_pci_get_group_from_dev(const char *bdf) 206 211 { 207 212 char dev_iommu_group_path[PATH_MAX] = {0};
+8
tools/testing/selftests/vfio/vfio_pci_device_test.c
··· 155 155 vfio_pci_irq_disable(self->device, variant->irq_index); 156 156 } 157 157 158 + TEST_F(vfio_pci_device_test, reset) 159 + { 160 + if (!(self->device->info.flags & VFIO_DEVICE_FLAGS_RESET)) 161 + SKIP(return, "Device does not support reset\n"); 162 + 163 + vfio_pci_device_reset(self->device); 164 + } 165 + 158 166 int main(int argc, char *argv[]) 159 167 { 160 168 device_bdf = vfio_selftests_get_bdf(&argc, argv);