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>
This commit is contained in:
committed by
Alex Williamson
parent
b477e7bcd2
commit
a0fd0af504
@@ -83,6 +83,7 @@ const char *vfio_selftests_get_bdf(int *argc, char *argv[]);
|
||||
|
||||
struct vfio_pci_device *vfio_pci_device_init(const char *bdf, int iommu_type);
|
||||
void vfio_pci_device_cleanup(struct vfio_pci_device *device);
|
||||
void vfio_pci_device_reset(struct vfio_pci_device *device);
|
||||
|
||||
void vfio_pci_dma_map(struct vfio_pci_device *device, u64 iova, u64 size,
|
||||
void *vaddr);
|
||||
|
||||
@@ -202,6 +202,11 @@ void vfio_pci_config_access(struct vfio_pci_device *device, bool write,
|
||||
write ? "write to" : "read from", config);
|
||||
}
|
||||
|
||||
void vfio_pci_device_reset(struct vfio_pci_device *device)
|
||||
{
|
||||
ioctl_assert(device->fd, VFIO_DEVICE_RESET, NULL);
|
||||
}
|
||||
|
||||
static unsigned int vfio_pci_get_group_from_dev(const char *bdf)
|
||||
{
|
||||
char dev_iommu_group_path[PATH_MAX] = {0};
|
||||
|
||||
@@ -155,6 +155,14 @@ TEST_F(vfio_pci_irq_test, enable_trigger_disable)
|
||||
vfio_pci_irq_disable(self->device, variant->irq_index);
|
||||
}
|
||||
|
||||
TEST_F(vfio_pci_device_test, reset)
|
||||
{
|
||||
if (!(self->device->info.flags & VFIO_DEVICE_FLAGS_RESET))
|
||||
SKIP(return, "Device does not support reset\n");
|
||||
|
||||
vfio_pci_device_reset(self->device);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
device_bdf = vfio_selftests_get_bdf(&argc, argv);
|
||||
|
||||
Reference in New Issue
Block a user