Re: [dpdk-dev] [RFC V1] ethdev: fix the issue that dev uninit may be called twice
From: Singh, Aman Deep <hidden>
Date: 2021-08-18 09:47:49
Hi Huison, On 8/2/2021 6:16 PM, Huisong Li wrote:
Ethernet devices in DPDK can be released by rte_eth_dev_close() and rte_dev_remove(). However, these two APIs do not have explicit invocation restrictions. In other words, at the ethdev layer, calling rte_eth_dev_close() and then rte_dev_remove() or rte_eal_hotplug_remove() is allowed. In such a bad scenario, the primary process may be fine, but it may cause that dev_unint() in the secondary process will be called twice,
Shouldn't dev_unint() for Secondary process, simply return with no-action.
quoted hunk ↗ jump to hunk
and even other serious problems. So this patch fixes it. Fixes: 99a2dd955fba ("lib: remove librte_ prefix from directory names") Signed-off-by: Huisong Li <lihuisong@huawei.com> --- lib/ethdev/ethdev_pci.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)diff --git a/lib/ethdev/ethdev_pci.h b/lib/ethdev/ethdev_pci.h index 8edca82..14a0e01 100644 --- a/lib/ethdev/ethdev_pci.h +++ b/lib/ethdev/ethdev_pci.h@@ -151,6 +151,19 @@ rte_eth_dev_pci_generic_remove(struct rte_pci_device *pci_dev, if (!eth_dev) return 0; + /* + * The eth_dev->data->name doesn't be cleared by the secondary precess,
Can we reprase above sentence "doesn't be cleared "
+ * so above "eth_dev" isn't NULL after rte_eth_dev_close() called. + * Namely, whether "eth_dev" is NULL cannot be used to determine whether + * an ethdev port has been released. + * For both primary precess and secondary precess, eth_dev->state is
s/ precess / process
+ * RTE_ETH_DEV_UNUSED, which means the ethdev port has been released.
+ */
+ if (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)