From 51093e679be90a9f7431f3e0d0fe4226c10eda3d Mon Sep 17 00:00:00 2001 From: Gaetan Rivet Date: Tue, 24 Oct 2017 12:35:39 +0200 Subject: [PATCH] pci: propagate PMD removal error value for unplug If a PCI device detach removal fails, returns the actual removal operator error value. Use this value within pci->unplug, as it may help applications solve an issue with the feature or more accurately warn their users. Signed-off-by: Gaetan Rivet Acked-by: Thomas Monjalon --- lib/librte_eal/common/eal_common_pci.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 0f0e4b93bf..fb92ee7b9b 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -263,6 +263,7 @@ rte_pci_detach_dev(struct rte_pci_device *dev) { struct rte_pci_addr *loc; struct rte_pci_driver *dr; + int ret = 0; if (dev == NULL) return -EINVAL; @@ -277,8 +278,11 @@ rte_pci_detach_dev(struct rte_pci_device *dev) RTE_LOG(DEBUG, EAL, " remove driver: %x:%x %s\n", dev->id.vendor_id, dev->id.device_id, dr->driver.name); - if (dr->remove && (dr->remove(dev) < 0)) - return -1; /* negative value is an error */ + if (dr->remove) { + ret = dr->remove(dev); + if (ret < 0) + return ret; + } /* clear driver structure */ dev->driver = NULL; @@ -551,8 +555,10 @@ pci_unplug(struct rte_device *dev) pdev = RTE_DEV_TO_PCI(dev); ret = rte_pci_detach_dev(pdev); - rte_pci_remove_device(pdev); - free(pdev); + if (ret == 0) { + rte_pci_remove_device(pdev); + free(pdev); + } return ret; } -- 2.20.1