DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net,
	Sangtani Parag Satishbhai
	<parag-satishbhai.sangtani@broadcom.com>,
	stable@dpdk.org, Somnath Kotur <somnath.kotur@broadcom.com>,
	Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Subject: [PATCH 05/11] net/bnxt/truFlow: Fix seg fault when rep are re-attached
Date: Wed,  5 Feb 2025 09:19:58 -0800	[thread overview]
Message-ID: <20250205172004.50395-6-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20250205172004.50395-1-ajit.khaparde@broadcom.com>

From: Sangtani Parag Satishbhai <parag-satishbhai.sangtani@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: stable@dpdk.org
Signed-off-by: Sangtani Parag Satishbhai <parag-satishbhai.sangtani@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@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)


  parent reply	other threads:[~2025-02-05 17:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 17:19 [PATCH 00/11] bnxt patch set Ajit Khaparde
2025-02-05 17:19 ` [PATCH 01/11] net/bnxt: disable TruFlow if compressed CQE is set Ajit Khaparde
2025-02-05 17:19 ` [PATCH 02/11] net/bnxt: simplify check for CQE mode Ajit Khaparde
2025-02-05 17:19 ` [PATCH 03/11] net/bnxt: fix Rx handler Ajit Khaparde
2025-02-05 17:19 ` [PATCH 04/11] net/bnxt: set burst handler correctly Ajit Khaparde
2025-02-05 17:19 ` Ajit Khaparde [this message]
2025-02-05 17:19 ` [PATCH 06/11] net/bnxt: address coverity deadcode issue Ajit Khaparde
2025-02-05 17:20 ` [PATCH 07/11] net/bnxt: address coverity checked return issues Ajit Khaparde
2025-02-05 17:20 ` [PATCH 08/11] net/bnxt: address coverity overflow issues Ajit Khaparde
2025-02-05 17:20 ` [PATCH 09/11] net/bnxt: address coverity integer " Ajit Khaparde
2025-02-05 17:20 ` [PATCH 10/11] net/bnxt: address coverity uninitialized variables issues Ajit Khaparde
2025-02-05 17:20 ` [PATCH 11/11] net/bnxt: address coverity control flow issues Ajit Khaparde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250205172004.50395-6-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=parag-satishbhai.sangtani@broadcom.com \
    --cc=somnath.kotur@broadcom.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).