Skip to content

Commit

Permalink
ethdev: fix PCI device release in secondary process
Browse files Browse the repository at this point in the history
[ upstream commit 17faaed ]

In secondary process, rte_eth_dev_close() doesn't clear eth_dev->data.
If calling rte_dev_remove() after rte_eth_dev_close(), in
rte_eth_dev_pci_generic_remove() function, the released eth device still
can be found by its name in shared memory. As a result, the eth device
will be released repeatedly. The state of the eth device is modified to
RTE_ETH_DEV_UNUSED after rte_eth_dev_close(). So this state can be used
to avoid this problem.

Fixes: dcd5c81 ("ethdev: add PCI driver helpers")

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  • Loading branch information
LiHuiSong1 authored and cpaelzer committed Nov 30, 2021
1 parent 27c4b80 commit 7715355
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/librte_ethdev/rte_ethdev_pci.h
Expand Up @@ -164,6 +164,16 @@ rte_eth_dev_pci_generic_remove(struct rte_pci_device *pci_dev,
if (!eth_dev)
return 0;

/*
* In secondary process, a released eth device can be found by its name
* in shared memory.
* If the state of the eth device is RTE_ETH_DEV_UNUSED, it means the
* eth device has been released.
*/
if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
eth_dev->state == RTE_ETH_DEV_UNUSED)
return 0;

if (dev_uninit) {
ret = dev_uninit(eth_dev);
if (ret)
Expand Down

0 comments on commit 7715355

Please sign in to comment.