[v2,01/25] ethdev: reset device and interrupt pointers on release
diff mbox series

Message ID 20200927234249.3198780-2-thomas@monjalon.net
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series
  • cleanup ethdev close operation
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon Sept. 27, 2020, 11:42 p.m. UTC
The pointers .device and .intr_handle were already reset by the helper
rte_eth_dev_pci_generic_remove().
It is now made part of rte_eth_dev_release_port().

It makes rte_eth_dev_pci_release() meaningless,
so it is replaced with a call to rte_eth_dev_release_port().

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/ark/ark_ethdev.c            |  2 +-
 drivers/net/octeontx2/otx2_ethdev.c     |  2 +-
 drivers/net/szedata2/rte_eth_szedata2.c |  6 +++---
 lib/librte_ethdev/rte_ethdev.c          |  2 ++
 lib/librte_ethdev/rte_ethdev_pci.h      | 14 ++------------
 5 files changed, 9 insertions(+), 17 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index d472ae5643..e13415e95b 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -105,7 +105,7 @@  eth_ark_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 
 	ret = eth_ark_dev_init(eth_dev);
 	if (ret)
-		rte_eth_dev_pci_release(eth_dev);
+		rte_eth_dev_release_port(eth_dev);
 
 	return ret;
 }
diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c
index c06e32f26b..51a6f99877 100644
--- a/drivers/net/octeontx2/otx2_ethdev.c
+++ b/drivers/net/octeontx2/otx2_ethdev.c
@@ -2668,7 +2668,7 @@  nix_remove(struct rte_pci_device *pci_dev)
 		if (rc)
 			return rc;
 
-		rte_eth_dev_pci_release(eth_dev);
+		rte_eth_dev_release_port(eth_dev);
 	}
 
 	/* Nothing to be done for secondary processes */
diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c
index 30c888cd96..a17c53577c 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.c
+++ b/drivers/net/szedata2/rte_eth_szedata2.c
@@ -1802,7 +1802,7 @@  szedata2_eth_dev_release_interval(struct rte_eth_dev **eth_devs,
 
 	for (i = from; i < to; i++) {
 		rte_szedata2_eth_dev_uninit(eth_devs[i]);
-		rte_eth_dev_pci_release(eth_devs[i]);
+		rte_eth_dev_release_port(eth_devs[i]);
 	}
 }
 
@@ -1853,7 +1853,7 @@  static int szedata2_eth_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		if (ret != 0) {
 			PMD_INIT_LOG(ERR, "Failed to init eth_dev for port %u",
 					i);
-			rte_eth_dev_pci_release(eth_devs[i]);
+			rte_eth_dev_release_port(eth_devs[i]);
 			szedata2_eth_dev_release_interval(eth_devs, 0, i);
 			rte_free(list_entry);
 			return ret;
@@ -1922,7 +1922,7 @@  static int szedata2_eth_pci_remove(struct rte_pci_device *pci_dev)
 			retval = retval ? retval : ret;
 		}
 
-		rte_eth_dev_pci_release(eth_dev);
+		rte_eth_dev_release_port(eth_dev);
 	}
 
 	return retval;
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index dfe5c1b488..d12d74dd8c 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -555,6 +555,8 @@  rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
 	eth_dev->state = RTE_ETH_DEV_UNUSED;
+	eth_dev->device = NULL;
+	eth_dev->intr_handle = NULL;
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		rte_free(eth_dev->data->rx_queues);
diff --git a/lib/librte_ethdev/rte_ethdev_pci.h b/lib/librte_ethdev/rte_ethdev_pci.h
index 9c483468ba..bf715896ae 100644
--- a/lib/librte_ethdev/rte_ethdev_pci.h
+++ b/lib/librte_ethdev/rte_ethdev_pci.h
@@ -107,16 +107,6 @@  rte_eth_dev_pci_allocate(struct rte_pci_device *dev, size_t private_data_size)
 	return eth_dev;
 }
 
-static inline void
-rte_eth_dev_pci_release(struct rte_eth_dev *eth_dev)
-{
-	eth_dev->device = NULL;
-	eth_dev->intr_handle = NULL;
-
-	/* free ether device */
-	rte_eth_dev_release_port(eth_dev);
-}
-
 typedef int (*eth_dev_pci_callback_t)(struct rte_eth_dev *eth_dev);
 
 /**
@@ -138,7 +128,7 @@  rte_eth_dev_pci_generic_probe(struct rte_pci_device *pci_dev,
 	RTE_FUNC_PTR_OR_ERR_RET(*dev_init, -EINVAL);
 	ret = dev_init(eth_dev);
 	if (ret)
-		rte_eth_dev_pci_release(eth_dev);
+		rte_eth_dev_release_port(eth_dev);
 	else
 		rte_eth_dev_probing_finish(eth_dev);
 
@@ -167,7 +157,7 @@  rte_eth_dev_pci_generic_remove(struct rte_pci_device *pci_dev,
 			return ret;
 	}
 
-	rte_eth_dev_pci_release(eth_dev);
+	rte_eth_dev_release_port(eth_dev);
 	return 0;
 }