Thread (26 messages) flat view 26 messages, 3 authors, 2016-03-22
STALE3787d

Revision v2 of 2 in this series.

Revisions (2)
  1. v1 [diff vs current]
  2. v2 current

[PATCH v2 7/9] pci: remove driver lookup from detach

From: David Marchand <hidden>
Date: 2016-01-29 14:49:26
Subsystem: library code, the rest · Maintainers: Andrew Morton, Linus Torvalds

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 <redacted>
---
Changes since v1:
- moved some logs for consistency

---
 lib/librte_eal/common/eal_common_pci.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 768421a..082eab8 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -256,13 +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);
+	struct rte_pci_driver *dr = dev->driver;
 
 	RTE_LOG(DEBUG, EAL, "  remove driver: %x:%x %s\n", dev->id.vendor_id,
 		dev->id.device_id, dr->name);
@@ -337,20 +333,19 @@ 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);
 
-	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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help