From: Huisong Li Date: Thu, 21 Oct 2021 02:24:21 +0000 (+0800) Subject: ethdev: fix PCI device release in secondary process X-Git-Url: http://git.droids-corp.org/?p=dpdk.git;a=commitdiff_plain;h=17faaed85449b58b209150906d2ad2cbfd853150 ethdev: fix PCI device release in secondary process 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: dcd5c8112bc3 ("ethdev: add PCI driver helpers") Cc: stable@dpdk.org Signed-off-by: Huisong Li Reviewed-by: Ferruh Yigit --- diff --git a/lib/ethdev/ethdev_pci.h b/lib/ethdev/ethdev_pci.h index 12015b6b87..59c5d7b40f 100644 --- a/lib/ethdev/ethdev_pci.h +++ b/lib/ethdev/ethdev_pci.h @@ -151,6 +151,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)