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 D18ED43B86 for ; Tue, 5 Mar 2024 10:55:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CB45C4026B; Tue, 5 Mar 2024 10:55:11 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2056.outbound.protection.outlook.com [40.107.92.56]) by mails.dpdk.org (Postfix) with ESMTP id DF2164014F for ; Tue, 5 Mar 2024 10:55:10 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RXNEeDmRT7nNPfSaaRtHPtPW5KAjqoQz++s2W7vax4kkqxU6Za9P5DWA7DZDN7J+Ozy8dKecuaVEl5vhmm9vpT/lNoqZJpJLmSSiKsMovXp9Gdy0S5X8retsvUCZkYJ+vUHEhYfce3lMkf6bntFoDatxiFqE2iQrOsxEemXTWCfhxoPfdVS6TNd2p5dtzo3R7HqDF82Ba9py2elh04lzbe5a+hFuJTrnR4mh4wOu0basuivygABtAgddwmheZJCPvOh57WdvDOokC29S1pmfrAnU9eenThI22kSUXxgwv3gqxDuSybu8to429exZztO0iNqnCnMY/ZvzaSMgMhWlvw== 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=7h434GWJOdtkbNs8MbKyRBDk2fZnYSKYcPWdnt4ETZw=; b=gs/JJ4oFT760KODvKwYWy76k89pf2zjsv9ODORejdWN9qc6eU9kCkkVUMTAdJzYd2t9H2POMOK5Kr6HNb2iwGDU37fkqEZyXq59dlJJ7jkfOWTrSxFjZErVvfPn4Wqiz3u7btb0XjQczD5sJVbS81cRDlFGb3CxiSH9/Wz8wSXzsvR7MOb8uVlfg0KGBdv9L7vSQ27apXrzyxmINcJkpY8yyhxaoyxo9U74bSvHizanP2e8tIhH5PCfU2RZpFkw8hlmRPvo2Vzx0ySIpUFTxr3DqxaNyi249whu4pzkaU3uNs3QwkmbECeG99lSkcn+BcKGpDnIDo4+nHipVQY5HzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=7h434GWJOdtkbNs8MbKyRBDk2fZnYSKYcPWdnt4ETZw=; b=h48XwOontJf87Q9KEFZc4u4FmtHy+BeWk2cAVRLaU8fCWfirYmog9vdB4JhJ6efLpXnLfasWTEcdo7WdzQh8bmBejnsd94TIkpz2C07ZRJBhp6DCDKZ5s1fnGCD491M8frClE2Q7VTciJnZny+3x9KM6J9JLXaVjRH63/pmsgvHtbE+XQxDH7vcf+q5zwXgfuzNHdALl8k6cvraamCFsQC3eNf1ncL1WASyVO4MQvgaC0hA+8bOP/lAivYd4MLTFk0isjuQoRPd9KZnfVqFiKlcg6LNkpDx3175euiwjKQgHA8WC+ll1WPzUAEVom64V+1wK4LBEZWIiMXxQQxCbqQ== Received: from BYAPR01CA0030.prod.exchangelabs.com (2603:10b6:a02:80::43) by LV2PR12MB5726.namprd12.prod.outlook.com (2603:10b6:408:17e::9) 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:08 +0000 Received: from SJ5PEPF000001D3.namprd05.prod.outlook.com (2603:10b6:a02:80:cafe::71) by BYAPR01CA0030.outlook.office365.com (2603:10b6:a02:80::43) 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:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SJ5PEPF000001D3.mail.protection.outlook.com (10.167.242.55) 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:07 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) 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:55 -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:53 -0800 From: Xueming Li To: Chaoyong He CC: Long Wu , Peng Zhang , "dpdk stable" Subject: patch 'net/nfp: fix resource leak for flower firmware' has been queued to stable release 23.11.1 Date: Tue, 5 Mar 2024 17:46:57 +0800 Message-ID: <20240305094757.439387-77-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: SJ5PEPF000001D3:EE_|LV2PR12MB5726:EE_ X-MS-Office365-Filtering-Correlation-Id: 0571c8a5-5277-48f1-7c65-08dc3cfa5711 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5U7PFPy3uH6XCQqumhPVwizW5Oy65TM6NPwfznHs7BMcsEkg+7dZNM/EsL4L16Fuyxigx/C/hI6ayzxEo8njqSPydr8GxPxK4dKOSDxhn4Jh6NlpslCMpBdNVHMvl8yQmzYlU878V8kJAFmovT4CevlBSVckuHDnLUJzitehx3Pe2IUUn1h9m6ooLSV5ghqwhn+aAAgG/ud87hK2HnJEpRwtznCHpHf6Gj20BOvNEumST2jdt1nQU3JO3aNjZEjixOMLIznwgyf9qdf7pwRohMM8ikrxjKOw0oCUA75GcqDL3OdcWluapE2wfL47dvEeqPSeyGwBZa4M6QjGwQSA6JhosK37rv+Xu5hcJ369oiEuHsGQxFArKjXYlcRs0rvcnGeKsLdLd2o7YptyeXxtWowPbAkmXXy4O2LaFiSUFJfqSww4Tcdx1ruLC7knLJWVfzntOXckb7Xl8KgFnXQj/YWER+hP1TKccNA0KOEorGxI88LwvR+jZ/OSAIYSWTo2xHimZH7gCY2IzuLywT7PPANPaeZPNsflR6/zcicKWIhvBjtk57wE87QnHMf/H3HA2gAvp+2pLia8cVa0H0gFeLPWozaI/k/Q3UG9nhvB4m9tAg0sbJGb9Py1h3dz9Q5+T3t6RkkAnSnC6n9V0xV8l0/zcWFDr7ZyT7k/JbwC7ywl/8nNBkTfk1WyupI3ATxMiq2RyVnNUyTQTjMsf50MiI72/PnkNL0yVvdrEceJAurbQXEEpl7Bm1KdLmLVexpU X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(82310400014)(36860700004)(376005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2024 09:55:07.9709 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0571c8a5-5277-48f1-7c65-08dc3cfa5711 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001D3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5726 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=09e1df883afa97ba2d37c8c4a69a0273c962a7b9 Thanks. Xueming Li --- >From 09e1df883afa97ba2d37c8c4a69a0273c962a7b9 Mon Sep 17 00:00:00 2001 From: Chaoyong He Date: Mon, 4 Dec 2023 09:57:15 +0800 Subject: [PATCH] net/nfp: fix resource leak for flower firmware Cc: Xueming Li [ upstream commit 7c596721ae5f41d1dbab8b936a4983928d6b5603 ] Fix the resource leak problem in the logic of flower firmware application. Fixes: e1124c4f8a45 ("net/nfp: add flower representor framework") Signed-off-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang --- .../net/nfp/flower/nfp_flower_representor.c | 89 ++++++++++++++++++- .../net/nfp/flower/nfp_flower_representor.h | 1 + 2 files changed, 86 insertions(+), 4 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index 0f0e63aae0..7212d9e024 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -291,6 +291,43 @@ nfp_flower_repr_tx_burst(void *tx_queue, return sent; } +static int +nfp_flower_repr_uninit(struct rte_eth_dev *eth_dev) +{ + struct nfp_flower_representor *repr; + + repr = eth_dev->data->dev_private; + rte_ring_free(repr->ring); + + return 0; +} + +static int +nfp_flower_pf_repr_uninit(__rte_unused struct rte_eth_dev *eth_dev) +{ + return 0; +} + +static void +nfp_flower_repr_free(struct nfp_flower_representor *repr, + enum nfp_repr_type repr_type) +{ + switch (repr_type) { + case NFP_REPR_TYPE_PHYS_PORT: + rte_eth_dev_destroy(repr->eth_dev, nfp_flower_repr_uninit); + break; + case NFP_REPR_TYPE_PF: + rte_eth_dev_destroy(repr->eth_dev, nfp_flower_pf_repr_uninit); + break; + case NFP_REPR_TYPE_VF: + rte_eth_dev_destroy(repr->eth_dev, nfp_flower_repr_uninit); + break; + default: + PMD_DRV_LOG(ERR, "Unsupported repr port type."); + break; + } +} + static const struct eth_dev_ops nfp_flower_pf_repr_dev_ops = { .dev_infos_get = nfp_flower_repr_dev_infos_get, @@ -410,6 +447,7 @@ nfp_flower_pf_repr_init(struct rte_eth_dev *eth_dev, repr->app_fw_flower->pf_repr = repr; repr->app_fw_flower->pf_hw->eth_dev = eth_dev; + repr->eth_dev = eth_dev; return 0; } @@ -501,6 +539,8 @@ nfp_flower_repr_init(struct rte_eth_dev *eth_dev, app_fw_flower->vf_reprs[index] = repr; } + repr->eth_dev = eth_dev; + return 0; mac_cleanup: @@ -511,6 +551,35 @@ ring_cleanup: return ret; } +static void +nfp_flower_repr_free_all(struct nfp_app_fw_flower *app_fw_flower) +{ + uint32_t i; + struct nfp_flower_representor *repr; + + for (i = 0; i < MAX_FLOWER_VFS; i++) { + repr = app_fw_flower->vf_reprs[i]; + if (repr != NULL) { + nfp_flower_repr_free(repr, NFP_REPR_TYPE_VF); + app_fw_flower->vf_reprs[i] = NULL; + } + } + + for (i = 0; i < NFP_MAX_PHYPORTS; i++) { + repr = app_fw_flower->phy_reprs[i]; + if (repr != NULL) { + nfp_flower_repr_free(repr, NFP_REPR_TYPE_PHYS_PORT); + app_fw_flower->phy_reprs[i] = NULL; + } + } + + repr = app_fw_flower->pf_repr; + if (repr != NULL) { + nfp_flower_repr_free(repr, NFP_REPR_TYPE_PF); + app_fw_flower->pf_repr = NULL; + } +} + static int nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower) { @@ -585,7 +654,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower) } if (i < app_fw_flower->num_phyport_reprs) - return ret; + goto repr_free; /* * Now allocate eth_dev's for VF representors. @@ -614,9 +683,14 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower) } if (i < app_fw_flower->num_vf_reprs) - return ret; + goto repr_free; return 0; + +repr_free: + nfp_flower_repr_free_all(app_fw_flower); + + return ret; } int @@ -635,7 +709,7 @@ nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower) /* Allocate a switch domain for the flower app */ if (app_fw_flower->switch_domain_id == RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID && - rte_eth_switch_domain_alloc(&app_fw_flower->switch_domain_id)) { + rte_eth_switch_domain_alloc(&app_fw_flower->switch_domain_id) != 0) { PMD_INIT_LOG(WARNING, "failed to allocate switch domain for device"); } @@ -677,8 +751,15 @@ nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower) ret = nfp_flower_repr_alloc(app_fw_flower); if (ret != 0) { PMD_INIT_LOG(ERR, "representors allocation failed"); - return -EINVAL; + ret = -EINVAL; + goto domain_free; } return 0; + +domain_free: + if (rte_eth_switch_domain_free(app_fw_flower->switch_domain_id) != 0) + PMD_INIT_LOG(WARNING, "failed to free switch domain for device"); + + return ret; } diff --git a/drivers/net/nfp/flower/nfp_flower_representor.h b/drivers/net/nfp/flower/nfp_flower_representor.h index bcb4c3cdb5..8053617562 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.h +++ b/drivers/net/nfp/flower/nfp_flower_representor.h @@ -20,6 +20,7 @@ struct nfp_flower_representor { struct rte_ring *ring; struct rte_eth_link link; struct rte_eth_stats repr_stats; + struct rte_eth_dev *eth_dev; }; int nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower); -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-03-05 17:39:33.309506877 +0800 +++ 0076-net-nfp-fix-resource-leak-for-flower-firmware.patch 2024-03-05 17:39:30.813566494 +0800 @@ -1 +1 @@ -From 7c596721ae5f41d1dbab8b936a4983928d6b5603 Mon Sep 17 00:00:00 2001 +From 09e1df883afa97ba2d37c8c4a69a0273c962a7b9 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 7c596721ae5f41d1dbab8b936a4983928d6b5603 ] @@ -10 +12,0 @@ -Cc: stable@dpdk.org