[dpdk-dev] [PATCH 8/9] pci: remove driver lookup from detach

David Marchand david.marchand at 6wind.com
Fri Jan 22 16:27:43 CET 2016


A device is linked to a driver at probe time.
When detaching, we should call this same driver detach() function and no
need for a driver lookup.

Signed-off-by: David Marchand <david.marchand at 6wind.com>
---
 lib/librte_eal/common/eal_common_pci.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index a1efd57..71222a5 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -256,16 +256,9 @@ pci_probe_device(struct rte_pci_driver *dr, struct rte_pci_device *dev)
  * driver.
  */
 static int
-pci_detach_device(struct rte_pci_driver *dr, struct rte_pci_device *dev)
+pci_detach_device(struct rte_pci_device *dev)
 {
-	struct rte_pci_addr *loc = &dev->addr;
-
-	RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
-		loc->domain, loc->bus, loc->devid,
-		loc->function, dev->numa_node);
-
-	RTE_LOG(DEBUG, EAL, "  remove driver: %x:%x %s\n", dev->id.vendor_id,
-		dev->id.device_id, dr->name);
+	struct rte_pci_driver *dr = dev->driver;
 
 	if (dr->devuninit && (dr->devuninit(dev) < 0))
 		return -1;	/* negative value is an error */
@@ -332,20 +325,22 @@ int
 rte_eal_pci_detach(const struct rte_pci_addr *addr)
 {
 	struct rte_pci_device *dev;
-	struct rte_pci_driver *dr;
 
 	if (addr == NULL)
 		return -1;
 
 	dev = pci_find_device(addr);
-	if (!dev)
+	if (!dev || !dev->driver)
 		goto err_return;
 
-	dr = pci_find_driver(dev);
-	if (!dr)
-		goto err_return;
+	RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
+		dev->addr.domain, dev->addr.bus, dev->addr.devid,
+		dev->addr.function, dev->numa_node);
+
+	RTE_LOG(DEBUG, EAL, "  remove driver: %x:%x %s\n", dev->id.vendor_id,
+		dev->id.device_id, dev->driver->name);
 
-	if (pci_detach_device(dr, dev) < 0)
+	if (pci_detach_device(dev) < 0)
 		goto err_return;
 
 	TAILQ_REMOVE(&pci_device_list, dev, next);
-- 
1.9.1



More information about the dev mailing list