From 6fb00f8baefa03b9cfd1b2dfc1787258b8459601 Mon Sep 17 00:00:00 2001 From: Jerin Jacob Date: Sat, 28 Oct 2017 11:52:55 +0530 Subject: [PATCH] bus/pci: fix VFIO device reset If the device is not capable of resetting, then Linux kernel updates the errno as EINVAL. http://elixir.free-electrons.com/linux/v4.9/source/drivers/vfio/pci/vfio_pci.c#L887 Honor the EINVAL errno value to avoid pci vfio setup failure. Fixes: f25f8f367644 ("bus/pci: check VFIO reset ioctl error") Signed-off-by: Jerin Jacob Reviewed-by: Jonas Pfefferle --- drivers/bus/pci/linux/pci_vfio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c index 13d52a8b17..3ca35b6db5 100644 --- a/drivers/bus/pci/linux/pci_vfio.c +++ b/drivers/bus/pci/linux/pci_vfio.c @@ -338,8 +338,11 @@ pci_vfio_setup_device(struct rte_pci_device *dev, int vfio_dev_fd) return -1; } - /* Reset the device */ - if (ioctl(vfio_dev_fd, VFIO_DEVICE_RESET)) { + /* + * Reset the device. If the device is not capable of resetting, + * then it updates errno as EINVAL. + */ + if (ioctl(vfio_dev_fd, VFIO_DEVICE_RESET) && errno != EINVAL) { RTE_LOG(ERR, EAL, "Unable to reset device! Error: %d (%s)\n", errno, strerror(errno)); return -1; -- 2.20.1