From: Sangtani Parag Satishbhai <parag-satishbhai.sangt...@broadcom.com>
When the PCI port is detached using the testpmd command, as part of cleanup testpmd removes resources of parent port and all the children's ports and calls the driver specific pci_remove API with the parent rte ethdev to clean-up ethdevs. For the bnxt driver, a condition to check type of ethdev is added in bnxt_pci_remove and based on the condition relevant ethdev is removed (VF/PF or VFR). As the RTE layer always calls PCI remove with the parent ethdev, the bnxt_pci_remove never frees children (VFRs) ethdev. As, these ethdevs were not freed it gives spurious status in re-allocation check(when pci port attach command is executed) and when RTE layers tries to access interrupt specific info from the ethdev due to uninitialized members it access NULL pointer which results in seg fault. The fix is made in bnxt_pci_remove to clean ethdev for parent (PF/VF) along with children (VFRs). Fixes: 322bd6e70272 ("net/bnxt: add port representor infrastructure") Cc: sta...@dpdk.org Signed-off-by: Sangtani Parag Satishbhai <parag-satishbhai.sangt...@broadcom.com> Reviewed-by: Somnath Kotur <somnath.ko...@broadcom.com> Reviewed-by: Kalesh AP <kalesh-anakkur.pura...@broadcom.com> Reviewed-by: Ajit Khaparde <ajit.khapa...@broadcom.com> --- drivers/net/bnxt/bnxt_ethdev.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index b18247feb2..144d4377bd 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -6993,6 +6993,8 @@ static int bnxt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, static int bnxt_pci_remove(struct rte_pci_device *pci_dev) { struct rte_eth_dev *eth_dev; + uint16_t port_id; + int rc = 0; eth_dev = rte_eth_dev_allocated(pci_dev->device.name); if (!eth_dev) @@ -7002,14 +7004,20 @@ static int bnxt_pci_remove(struct rte_pci_device *pci_dev) * +ve value will at least help in proper cleanup */ - PMD_DRV_LOG_LINE(DEBUG, "BNXT Port:%d pci remove", eth_dev->data->port_id); if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - if (rte_eth_dev_is_repr(eth_dev)) - return rte_eth_dev_destroy(eth_dev, - bnxt_representor_uninit); - else - return rte_eth_dev_destroy(eth_dev, - bnxt_dev_uninit); + RTE_ETH_FOREACH_DEV_OF(port_id, &pci_dev->device) { + PMD_DRV_LOG_LINE(DEBUG, "BNXT Port:%d pci remove", port_id); + eth_dev = &rte_eth_devices[port_id]; + if (eth_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) + rc = rte_eth_dev_destroy(eth_dev, + bnxt_representor_uninit); + else + rc = rte_eth_dev_destroy(eth_dev, + bnxt_dev_uninit); + if (rc != 0) + return rc; + } + return rc; } else { return rte_eth_dev_pci_generic_remove(pci_dev, NULL); } -- 2.39.5 (Apple Git-154)