From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 36402461A0 for ; Wed, 5 Feb 2025 18:20:19 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E3CAB4069F; Wed, 5 Feb 2025 18:20:17 +0100 (CET) Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) by mails.dpdk.org (Postfix) with ESMTP id CDD7D40667 for ; Wed, 5 Feb 2025 18:20:15 +0100 (CET) Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-5fa9778fa2cso868eaf.0 for ; Wed, 05 Feb 2025 09:20:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1738776015; x=1739380815; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=O85u+27WVnGagTl4sTWvq49mCi5oT6PwWx/mi9+I9+g=; b=TDTlphgponTIiKzcFpMA3RV8XsH9679+4HDai/NEhOH/02LLkneFxnwLhgXIB/cux5 K22zSbJgioGRankeyrOWnMUmt8UYTLf3av6h7OZhp4R5GRTVmg5Eg/IVZI0387c0gkEX s07ely5kim/88OfyC6LkuyXa5KHQzEF4Md4xg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738776015; x=1739380815; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O85u+27WVnGagTl4sTWvq49mCi5oT6PwWx/mi9+I9+g=; b=sZDnR3Ee9bJT/f5+Rgk8y/r7b/iCh2HpdpP4MYl9gG2V0JrBGw90jkl/EFpHKYhKfo KwpTZ1U/Fed/y8ax+hZAybuwIo4eb9MHnA25uUsFmrOhqig9VNXYouV18XSCInLPB6Sd 8Cb80vPB5sYCavHeOJuRPy4kB9k6GtlGpDzhYXDj4vFpzlC1VaQqTqb8WYD0Wqo9gUPw jckYDVlJwsr618njYdjkkeCL59Vvx3rCpixPrSV0RikIU0iQRP3s+Mc3dSFrbeOs20nG vLZbNXUkByZI0XTLrbwRXjkq3wArgeWlwrsgp0sWWzNlIdwOfnHTMwk3Ah8RLbh11F6i hp1A== X-Forwarded-Encrypted: i=1; AJvYcCXf8ejaW26x5eqvkKUY6m+LEP0fEREBsIut62bq8OdRhRwobBQ+uXxMsixL8O9ttOfVioPR4zQ=@dpdk.org X-Gm-Message-State: AOJu0YwuebT8JOrCR8cu8+WGLUf9F4+7fD33rKHaDYAvr64rBmKjYqTj FRdd/67vHOFqmggGTFxLk0IojL9J6fdBmTP9Sv5bExzqXhKo889ZDIw/Urbl2uxaahHAl1CiYP4 = X-Gm-Gg: ASbGncvfh3lbC5LecnwVNdzBhExhixZ4nVg1u9PET8RwRGCKElwcxfMvaOvkbL/8P/K lJdclpNqIwt+fDgv063G8lVFApyPdAeDnJyZOFrk0kSY5uyZldEeQmsFqCYeZqk7wiXJMLw1jqH fQm7QBxshj0XQDrnuDZ4EURlhsta6JgQrQmQ25w4PfNG0fMxh6GWACniMtW5gQ3m1O8PH9rdE2w wcjwAvxKH2FcPRUPJFiK6ajbIIAZLwo75JuM1QurN5NWMpdsrf6LBLW25pGBy4qkjXYU13Wr305 IEylKnoY1MjJIXlcSVRWljF2tTmWfnTEgpD92chT4kr5AoZ36AGjyiMzL+UTQvdKMnlT3XLzaOF 3oqd4N3Xy X-Google-Smtp-Source: AGHT+IE/LDrTMRXefw2ov4zhT2g/2ARVxAO31ZYHSgYEdsOzqI8rH7iuTFsT0DWYZ2ae79ZH2ejsOQ== X-Received: by 2002:a05:6820:2787:b0:5fa:6805:645b with SMTP id 006d021491bc7-5fc479cbc96mr2751736eaf.6.1738776015086; Wed, 05 Feb 2025 09:20:15 -0800 (PST) Received: from C02GC2QQMD6T.wifi.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-726617cde49sm4004016a34.27.2025.02.05.09.20.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 09:20:14 -0800 (PST) From: Ajit Khaparde To: dev@dpdk.org Cc: thomas@monjalon.net, Sangtani Parag Satishbhai , stable@dpdk.org, Somnath Kotur , Kalesh AP Subject: [PATCH 05/11] net/bnxt/truFlow: Fix seg fault when rep are re-attached Date: Wed, 5 Feb 2025 09:19:58 -0800 Message-Id: <20250205172004.50395-6-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250205172004.50395-1-ajit.khaparde@broadcom.com> References: <20250205172004.50395-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org From: Sangtani Parag Satishbhai 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 Reviewed-by: Somnath Kotur Reviewed-by: Kalesh AP Reviewed-by: Ajit Khaparde --- 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)