ethdev: fix eth device released repeatedly
Checks
Commit Message
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@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(+)
Comments
08/10/2021 10:21, Huisong Li:
> 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.
Sorry I have difficulties to understand.
The use of "it" everywhere doesn't help.
You should name things instead of refering to "it".
> Fixes: 99a2dd955fba ("lib: remove librte_ prefix from directory names")
For sure that's not the root cause.
在 2021/10/8 18:23, Thomas Monjalon 写道:
> 08/10/2021 10:21, Huisong Li:
>> 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.
> Sorry I have difficulties to understand.
> The use of "it" everywhere doesn't help.
> You should name things instead of refering to "it".
ok. I will fix it. Thanks.
>> Fixes: 99a2dd955fba ("lib: remove librte_ prefix from directory names")
> For sure that's not the root cause.
>
>
>
> .
@@ -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)