[dpdk-dev] [PATCH] ethdev: fix eth device released repeatedly
Huisong Li
lihuisong at huawei.com
Fri Oct 8 10:21:14 CEST 2021
In secondary process, because it doesn't clear eth_dev->data, the "eth_dev"
above will not be NULL when rte_eth_dev_close() has been called before this
interface is called. In this case, Ethernet device will be released
repeatedly. The state of the Ethernet device is equal to RTE_ETH_DEV_UNUSED
after calling rte_eth_dev_close(). Using this state resolves problem.
Fixes: 99a2dd955fba ("lib: remove librte_ prefix from directory names")
Signed-off-by: Huisong Li <lihuisong at huawei.com>
---
RFC -> v1:
* fix commit log and add a judgment for secondary process.
---
lib/ethdev/ethdev_pci.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/lib/ethdev/ethdev_pci.h b/lib/ethdev/ethdev_pci.h
index 8edca82ce8..be695feefe 100644
--- a/lib/ethdev/ethdev_pci.h
+++ b/lib/ethdev/ethdev_pci.h
@@ -151,6 +151,20 @@ rte_eth_dev_pci_generic_remove(struct rte_pci_device *pci_dev,
if (!eth_dev)
return 0;
+ /*
+ * In secondary process, because it doesn't clear eth_dev->data, the
+ * "eth_dev" above will not be NULL when rte_eth_dev_close() has been
+ * called before this interface is called.
+ * In this case, Ethernet device will be released repeatedly.
+ * The state of the Ethernet device is equal to RTE_ETH_DEV_UNUSED after
+ * calling rte_eth_dev_close(). Using this state resolves problem.
+ */
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY &&
+ eth_dev->state == RTE_ETH_DEV_UNUSED) {
+ RTE_ETHDEV_LOG(INFO, "The ethdev port has been released.");
+ return 0;
+ }
+
if (dev_uninit) {
ret = dev_uninit(eth_dev);
if (ret)
--
2.33.0
More information about the dev
mailing list