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 616B143B86 for ; Tue, 5 Mar 2024 10:55:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B4DB42E45; Tue, 5 Mar 2024 10:55:17 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2051.outbound.protection.outlook.com [40.107.92.51]) by mails.dpdk.org (Postfix) with ESMTP id D4F3E4014F for ; Tue, 5 Mar 2024 10:55:15 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ky7nnyrL3MeqKkmjJVxaLl4fiBQC+uup9683d//y3Ff917CsGrvXJ8zbBCI0EKi0L53+4hzxZbf1qL+94Tk5UzDFUjZWTYhrZKVhVVCaTK6ZFB3j18tOr+4wZfq/W8eMWfuzh/4y+plefsRqGocxvaq7CElvu6hXIwiU3HlvoSaor2tbA2BvL8uiGKJi1GInoklA9LUBRtUFE/sRXWUeDUPM6msYjSE8NAVSU/NYqkcfN3heTAQIf6qrECx4sE75esgEN8VFBoCtCO1yy0Avs+TpKdDuCCxo0zdGQyoEpsWdGifYTMcXsyHZhusfUswZRnkMu2U4A+2pA6pQmHo3KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rZwpll2YXMiZnswp6Twuec6Yves9o+VHPLhcAo1Ot8Y=; b=kpqnxk2EOueLT4oU/vjh8Ntrp8/oK++pI3p6FbKbrqfEaQ6COoTCTP3KUkFmnoYGBBbWRSCsWMUUzujI95ovO7CA7IpEfuQi0qb4Mxml2tw6YE5EAGTopBrG8yuYo8zTvKysf5NcJ2v2qzKAgZEs8QNgDtUebEBO6hOl5v9K8sdco7oAcBfur3h8sSSdpNtG0kf/RUhPQX0eyfOWSUzhpWSpOR6Frga6S84/xd4grAXrDVd/DqcNVS+jLtKIbIi5+Km99ulRhzMPC1+qbLDMyNpp4+xAFG2C772rkG26sDmR8wmbDclKCfUtQ9FEC3KRvnt82CyjlJRkZN9eKx8TOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=corigine.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rZwpll2YXMiZnswp6Twuec6Yves9o+VHPLhcAo1Ot8Y=; b=bM0TntPtox85uzVuDtSRLALd4n4ZwJBNW4XQiJ16Kp43JiP+UtMFiPk4R7guOIdev+Q6eKDGJs0qlWLFQDytVQVXpZFAU2/POxouvoMFAa8RVYaY0r2iNnUyEHwQKKwj2FWGTTJkslcaw/yayycz+JniCHDh5JAYShewo15ZZIYPvF1ziSCniFWn5OZcGbRRBjqPq3grn7ZsXHy2bAzVCn8loDkp56SiEnM+z0iVpc+907PVIDgvxWU3T8urv3qIggr0oiUlSTtd/CdVk+G/wJabuWaf9VK4QT2eXWkAR4Tv1jWRwm0BqfGMyN9OOpZ8fLQ1ltY2txkd1KUNe2q6dg== Received: from MW4PR04CA0055.namprd04.prod.outlook.com (2603:10b6:303:6a::30) by CH3PR12MB7596.namprd12.prod.outlook.com (2603:10b6:610:14b::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Tue, 5 Mar 2024 09:55:13 +0000 Received: from CO1PEPF000042A7.namprd03.prod.outlook.com (2603:10b6:303:6a:cafe::b6) by MW4PR04CA0055.outlook.office365.com (2603:10b6:303:6a::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38 via Frontend Transport; Tue, 5 Mar 2024 09:55:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1PEPF000042A7.mail.protection.outlook.com (10.167.243.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Tue, 5 Mar 2024 09:55:12 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 5 Mar 2024 01:54:59 -0800 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Tue, 5 Mar 2024 01:54:57 -0800 From: Xueming Li To: Chaoyong He CC: Long Wu , Peng Zhang , "dpdk stable" Subject: patch 'net/nfp: fix resource leak for exit of flower firmware' has been queued to stable release 23.11.1 Date: Tue, 5 Mar 2024 17:46:59 +0800 Message-ID: <20240305094757.439387-79-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240305094757.439387-1-xuemingl@nvidia.com> References: <20240305094757.439387-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042A7:EE_|CH3PR12MB7596:EE_ X-MS-Office365-Filtering-Correlation-Id: 9fd68285-e072-4c84-df80-08dc3cfa59de X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2skGlaqLHfcSyNJaC77nhFKAzm0jqtuWyfPJkuI9ZdCa7dGi49GVI02I3OifWubfjTR21gw3ngcXPhev/GJVGvIVtiBeCNKNr5k17JX0zAlSgJ544taHGkzPK/RTyuRQjkpsW0IGVK+yX0e0CiDaLC7ITZ6nYnjC4iVwB2nzIl5jMfIwlNdqaCPRi8FBROMfzlFy6zKrY5tAqIqz8L4gkTr9g3EigreM8JWqbvAOCcE/H9qHWtBWK+jmdk2YTsolMpqONHQLkOryTgcUQRooyTXcZZN9usDhjpAed0PaILCOr1WTULBER5WkR15C7ae0d5+R3+PyJtSbVw5yz1gESKAWp7lW37JKA6u4jmwfK9KpyP2m54HOWxvBd5S5cUKdvPLfgYnWzisOtwQhVeVUmgbIGUESVeTgCipIpSnjYYNDQaOCv4iNlubE8l1JCGVr/TyvjkIgVS/pFOZiSg/196gNOVl5fTrcfm5Kwl3WsldhXM/LneqEefSRljel/MeJy1O57wtcu8wXQcR2q90eVgTmco5WQknySGkm4ZiwcAmpROcPMy1ZM33wNhevL2BPbPH1s160yMDDj0Xb/jkXYbGyzsJ0bbyHZVCXveo2k0lxbn7UJlzD9wZNdoIq6xh8c2EmLUdbiUv16ov5+MfVaal0i8WOWKJN9VCEkTv7guN7ogs3DeC1AKzLp3TVcaB0yhXse++NvwnQTdgPx1TA/XamrJsNCm+jv9EA4hntQSzur1IBGRghHQAKMMT2pBKG X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(36860700004)(376005)(82310400014); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2024 09:55:12.5474 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9fd68285-e072-4c84-df80-08dc3cfa59de X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042A7.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7596 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 Hi, FYI, your patch has been queued to stable release 23.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 03/31/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://git.dpdk.org/dpdk-stable/log/?h=23.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=ddeb9d64a933aa84eb4e2c87d341b04401a5947b Thanks. Xueming Li --- >From ddeb9d64a933aa84eb4e2c87d341b04401a5947b Mon Sep 17 00:00:00 2001 From: Chaoyong He Date: Mon, 4 Dec 2023 09:57:17 +0800 Subject: [PATCH] net/nfp: fix resource leak for exit of flower firmware Cc: Xueming Li [ upstream commit a256a1227dbe0eac576a42b6c336ce55b7713109 ] Fix the resource leak problem in the exit logic of flower firmware. Fixes: e1124c4f8a45 ("net/nfp: add flower representor framework") Signed-off-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang --- drivers/net/nfp/flower/nfp_flower.c | 73 ++++--------------- drivers/net/nfp/flower/nfp_flower.h | 1 + .../net/nfp/flower/nfp_flower_representor.c | 64 ++++++++++++++++ 3 files changed, 80 insertions(+), 58 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 6b523d98b0..3698a3d4aa 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -82,63 +82,6 @@ nfp_flower_pf_start(struct rte_eth_dev *dev) return 0; } -/* Reset and stop device. The device can not be restarted. */ -static int -nfp_flower_pf_close(struct rte_eth_dev *dev) -{ - uint16_t i; - struct nfp_net_hw *hw; - struct nfp_pf_dev *pf_dev; - struct nfp_net_txq *this_tx_q; - struct nfp_net_rxq *this_rx_q; - struct nfp_flower_representor *repr; - struct nfp_app_fw_flower *app_fw_flower; - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return 0; - - repr = dev->data->dev_private; - hw = repr->app_fw_flower->pf_hw; - pf_dev = hw->pf_dev; - app_fw_flower = NFP_PRIV_TO_APP_FW_FLOWER(pf_dev->app_fw_priv); - - nfp_mtr_priv_uninit(pf_dev); - - /* - * We assume that the DPDK application is stopping all the - * threads/queues before calling the device close function. - */ - nfp_net_disable_queues(dev); - - /* Clear queues */ - for (i = 0; i < dev->data->nb_tx_queues; i++) { - this_tx_q = dev->data->tx_queues[i]; - nfp_net_reset_tx_queue(this_tx_q); - } - - for (i = 0; i < dev->data->nb_rx_queues; i++) { - this_rx_q = dev->data->rx_queues[i]; - nfp_net_reset_rx_queue(this_rx_q); - } - - /* Cancel possible impending LSC work here before releasing the port */ - rte_eal_alarm_cancel(nfp_net_dev_interrupt_delayed_handler, (void *)dev); - - nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, 0xff); - - /* Now it is safe to free all PF resources */ - PMD_DRV_LOG(INFO, "Freeing PF resources"); - nfp_cpp_area_free(pf_dev->ctrl_area); - nfp_cpp_area_free(pf_dev->qc_area); - free(pf_dev->hwinfo); - free(pf_dev->sym_tbl); - nfp_cpp_free(pf_dev->cpp); - rte_free(app_fw_flower); - rte_free(pf_dev); - - return 0; -} - static const struct eth_dev_ops nfp_flower_pf_vnic_ops = { .dev_infos_get = nfp_net_infos_get, .link_update = nfp_net_link_update, @@ -146,7 +89,6 @@ static const struct eth_dev_ops nfp_flower_pf_vnic_ops = { .dev_start = nfp_flower_pf_start, .dev_stop = nfp_net_stop, - .dev_close = nfp_flower_pf_close, }; static inline struct nfp_flower_representor * @@ -858,6 +800,21 @@ app_cleanup: return ret; } +void +nfp_uninit_app_fw_flower(struct nfp_pf_dev *pf_dev) +{ + struct nfp_app_fw_flower *app_fw_flower; + + app_fw_flower = pf_dev->app_fw_priv; + nfp_flower_cleanup_ctrl_vnic(app_fw_flower->ctrl_hw); + nfp_cpp_area_free(app_fw_flower->ctrl_hw->ctrl_area); + nfp_cpp_area_free(pf_dev->ctrl_area); + rte_free(app_fw_flower->pf_hw); + nfp_mtr_priv_uninit(pf_dev); + nfp_flow_priv_uninit(pf_dev); + rte_free(app_fw_flower); +} + int nfp_secondary_init_app_fw_flower(struct nfp_pf_dev *pf_dev) { diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h index 6f27c06acc..8393de66c5 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -106,6 +106,7 @@ nfp_flower_support_decap_v2(const struct nfp_app_fw_flower *app_fw_flower) int nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev, const struct nfp_dev_info *dev_info); +void nfp_uninit_app_fw_flower(struct nfp_pf_dev *pf_dev); int nfp_secondary_init_app_fw_flower(struct nfp_pf_dev *pf_dev); bool nfp_flower_pf_dispatch_pkts(struct nfp_net_hw *hw, struct rte_mbuf *mbuf, diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index 7212d9e024..02089d390e 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -328,12 +328,75 @@ nfp_flower_repr_free(struct nfp_flower_representor *repr, } } +/* Reset and stop device. The device can not be restarted. */ +static int +nfp_flower_repr_dev_close(struct rte_eth_dev *dev) +{ + uint16_t i; + struct nfp_net_hw *hw; + struct nfp_pf_dev *pf_dev; + struct nfp_net_txq *this_tx_q; + struct nfp_net_rxq *this_rx_q; + struct nfp_flower_representor *repr; + struct nfp_app_fw_flower *app_fw_flower; + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + repr = dev->data->dev_private; + app_fw_flower = repr->app_fw_flower; + hw = app_fw_flower->pf_hw; + pf_dev = hw->pf_dev; + + /* + * We assume that the DPDK application is stopping all the + * threads/queues before calling the device close function. + */ + nfp_net_disable_queues(dev); + + /* Clear queues */ + for (i = 0; i < dev->data->nb_tx_queues; i++) { + this_tx_q = dev->data->tx_queues[i]; + nfp_net_reset_tx_queue(this_tx_q); + } + + for (i = 0; i < dev->data->nb_rx_queues; i++) { + this_rx_q = dev->data->rx_queues[i]; + nfp_net_reset_rx_queue(this_rx_q); + } + + if (pf_dev->app_fw_id != NFP_APP_FW_FLOWER_NIC) + return -EINVAL; + + nfp_flower_repr_free(repr, repr->repr_type); + + for (i = 0; i < MAX_FLOWER_VFS; i++) { + if (app_fw_flower->vf_reprs[i] != NULL) + return 0; + } + + for (i = 0; i < NFP_MAX_PHYPORTS; i++) { + if (app_fw_flower->phy_reprs[i] != NULL) + return 0; + } + + if (app_fw_flower->pf_repr != NULL) + return 0; + + /* Now it is safe to free all PF resources */ + nfp_uninit_app_fw_flower(pf_dev); + nfp_pf_uninit(pf_dev); + + return 0; +} + static const struct eth_dev_ops nfp_flower_pf_repr_dev_ops = { .dev_infos_get = nfp_flower_repr_dev_infos_get, .dev_start = nfp_flower_pf_start, .dev_configure = nfp_net_configure, .dev_stop = nfp_net_stop, + .dev_close = nfp_flower_repr_dev_close, .rx_queue_setup = nfp_net_rx_queue_setup, .tx_queue_setup = nfp_net_tx_queue_setup, @@ -356,6 +419,7 @@ static const struct eth_dev_ops nfp_flower_repr_dev_ops = { .dev_start = nfp_flower_repr_dev_start, .dev_configure = nfp_net_configure, .dev_stop = nfp_flower_repr_dev_stop, + .dev_close = nfp_flower_repr_dev_close, .rx_queue_setup = nfp_flower_repr_rx_queue_setup, .tx_queue_setup = nfp_flower_repr_tx_queue_setup, -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-03-05 17:39:33.362451379 +0800 +++ 0078-net-nfp-fix-resource-leak-for-exit-of-flower-firmwar.patch 2024-03-05 17:39:30.823566495 +0800 @@ -1 +1 @@ -From a256a1227dbe0eac576a42b6c336ce55b7713109 Mon Sep 17 00:00:00 2001 +From ddeb9d64a933aa84eb4e2c87d341b04401a5947b Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit a256a1227dbe0eac576a42b6c336ce55b7713109 ] @@ -9 +11,0 @@ -Cc: stable@dpdk.org @@ -21 +23 @@ -index f172c8350d..f950ae233b 100644 +index 6b523d98b0..3698a3d4aa 100644