bus/pci: fix VFIO device reset
[dpdk.git] / drivers / bus / pci / linux / pci_vfio.c
index 1a3c308..3ca35b6 100644 (file)
@@ -62,7 +62,7 @@
  * This file is only compiled if CONFIG_RTE_EAL_VFIO is set to "y".
  */
 
-#ifdef RTE_EAL_VFIO
+#ifdef VFIO_PRESENT
 
 #define PAGE_SIZE   (sysconf(_SC_PAGESIZE))
 #define PAGE_MASK   (~(PAGE_SIZE - 1))
@@ -338,8 +338,15 @@ pci_vfio_setup_device(struct rte_pci_device *dev, int vfio_dev_fd)
                return -1;
        }
 
-       /* Reset the device */
-       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;
+       }
 
        return 0;
 }