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 C6FF6A0A0E for ; Mon, 10 May 2021 18:25:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C13E44003E; Mon, 10 May 2021 18:25:20 +0200 (CEST) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08on2046.outbound.protection.outlook.com [40.107.102.46]) by mails.dpdk.org (Postfix) with ESMTP id 63D9E4003E for ; Mon, 10 May 2021 18:25:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FwNSiDQxJ7q+JuA087W2YhoM4K+OMkWjfMCVniGVsmRFnedsPj6KrOMeGLoRPkSPJbJYy8iQjC3coZF17PVsfN6PRoo8eUPXs4nvBHDw5S8ZYQbiMtA3l/v7TGiiGkwm/nYmfXCk7TpHEjRP5BWcoNlA/PwV2A6PefBw92HWqmHzJEi18gS5KsKkySiNjEE2+wYgfhooabizI5NayOOsSrCTQxGjmB7Sh1ngTKC1PA0lH4G6G5ZaandAfLYFB3Cs7JAyLpoXm6U5H2+VHdYxKS16Is2CBfValgkicwGwhM2GIMyWNW2DJ0tQHu4bWbiqrWI1BhY/4ad1klKlx80WRw== 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-SenderADCheck; bh=HCirgpcqCz+ZSDJ2Wwc3Dp+ArqAwK0BhtvgZ55kESbE=; b=X/+yhsbbF3gvVDYHdy00HQ5AGZHSAivRhI12faK5qiiUYxF6yidpgBPgcUJe0VJeSYw6DQ2bMzqtpYwYxMXn+eWFlAy6ML/eaSARWPhQXsFcAZQWYKf57ShcA9QD5KunF2OGG4erqu8bq1LOMCDeHbsQ39qiQ7sgTYJ0Bsy21dVi6DX2Ou2nJSrSivhJ3hGUPRoLVVoFovgoN7SQvUC7KtGG/rreHLRZqWEX2i+bt1VOJYmO9mQsNcCfs3Udp9XEbovRdNie/V9ZCTQd/7huYFQS+tN9ty77TirvBDOCcc6VmgiAAFPUQoysTmxxLIHxTzL3uBHT11GNMkNIyTzz2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none 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=HCirgpcqCz+ZSDJ2Wwc3Dp+ArqAwK0BhtvgZ55kESbE=; b=AmqyN0wpdyYi/8jzGPrFm98UWW9Q4MaO3Hr8agrfgw/XZhE4g/RFyjEUmYVzudoz969v6H/rAOxKJ3dtxKCmexDbtEW0Zaha6JfNogUksB/3SwawzUr573pnwh3HGlUws4ap/uOoHNzXvq0XsWW8d7lfk/cUOCNrZBQMuOIckntRjHEfoa0OXdTz1eyCKqt+fcUQRYDvejhu89dU33q3vK7RtFARzpVP8vuaoutrqQfOsi5xCFUWSQBS7z4e012Q0XQKR5PHFC+dfUJSwZ2tmwiqLVGOYGumVq3Bz8llcZrZs29jP1sAouVsGD8W5oxufDhd39AS2QMWuxKoHIjs1g== Received: from BN6PR14CA0022.namprd14.prod.outlook.com (2603:10b6:404:79::32) by CH0PR12MB5203.namprd12.prod.outlook.com (2603:10b6:610:ba::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Mon, 10 May 2021 16:25:18 +0000 Received: from BN8NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:404:79:cafe::7a) by BN6PR14CA0022.outlook.office365.com (2603:10b6:404:79::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Mon, 10 May 2021 16:25:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT003.mail.protection.outlook.com (10.13.177.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4108.25 via Frontend Transport; Mon, 10 May 2021 16:25:18 +0000 Received: from nvidia.com (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 10 May 2021 16:25:16 +0000 From: Xueming Li To: Ajit Khaparde CC: Luca Boccassi , dpdk stable Date: Tue, 11 May 2021 00:02:51 +0800 Message-ID: <20210510160258.30982-222-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210510160258.30982-1-xuemingl@nvidia.com> References: <20210510160258.30982-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9a0ef250-6488-4b47-c496-08d913d03326 X-MS-TrafficTypeDiagnostic: CH0PR12MB5203: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gZhQb+ET/3Glq94A3qnd+3J33w5Rasa9paxCDRDf6Vqyj4n7CfR7GuFsQ2tVxXLXhR+iOKpjCi6i3610OGFq87SGNDrQXiowuNMmfJjuq7qukTQk+CTHgBHH1/yxBnr2XcHDj7LTBZ82A43vsUzfz7yC7BZKOadFqpJnToP5CJV4EZmyqUn60XSfVnVJmh245wBQ+y38EhGedy7KECG6JRwAJlE/fcO08ZNayyUMWsHNxugCHofw++WlIK5f5fmTyrhcRPU1BPeCfPX48Cq8gQcZZ4NqTgHWvl2nT8Q38AYZrTDg7MORYw20nfbBI035dB9v8i4j5B1CvVLKLdfk1e0sNny659OPF2KoXpvwgjbz9/zFHTe5FL+7eLZRdBVV6I3VKOGAWAx6Qqyb058AjOl45jOXDfGsKu7jAlzSuJOvTuOdLrUbQxcevEVcUTv95/I3PqQQ0DM/9kzkYt0mgSmoCiqaApNjwaaeBuF23ugBLHl/qK4Gy2OwVk5MpStKuVBG1UCZrUxNI4OwaRGOMo2GkBCqT10DjwFe/sM46ah6POY1u5ptwfeTttA/KpXKgTeeZn1bZKN8WYQfNe00gNluXMffkevwBV1ZeHUUe1Zgk8EgNGEqWJQwnzdz1h6H/qY3n1TRvfUPj1CNCFzqgz6OpeQoirHnhNqp1V+XIht668sXBL8MH2eOnj3SCcYTMIL8//vvA2d7rMfS/UzIBBIh/2SLXF58qW5I7EL6Vp+IfTF02Pkiy2FXPoJtSCDb4fNd5MdLXEDVx8rDSz1DYQ== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(346002)(136003)(39860400002)(376002)(396003)(46966006)(36840700001)(36756003)(47076005)(36860700001)(966005)(478600001)(7696005)(36906005)(53546011)(8936002)(316002)(26005)(54906003)(8676002)(336012)(186003)(16526019)(2616005)(426003)(356005)(83380400001)(55016002)(6666004)(82740400003)(82310400003)(70586007)(6916009)(70206006)(86362001)(6286002)(7636003)(2906002)(1076003)(4326008)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2021 16:25:18.0270 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9a0ef250-6488-4b47-c496-08d913d03326 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5203 Subject: [dpdk-stable] patch 'net/bnxt: fix resource cleanup' has been queued to stable release 20.11.2 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 Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/12/21. 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://github.com/steevenlee/dpdk This queued commit can be viewed at: https://github.com/steevenlee/dpdk/commit/8ffdca19f32d8f6710463c9ee3a3eb5c2d1b4c1b Thanks. Xueming Li --- >From 8ffdca19f32d8f6710463c9ee3a3eb5c2d1b4c1b Mon Sep 17 00:00:00 2001 From: Ajit Khaparde Date: Thu, 8 Apr 2021 13:17:47 -0700 Subject: [PATCH] net/bnxt: fix resource cleanup Cc: Luca Boccassi [ upstream commit e2895305a5b54a596b510f763c61652bf05e81db ] Fix resource cleanup in port close. Once the pointers are freed, set them to NULL. Make sure access to the pointers is validated before use. Fixes: bb81e07323bb ("net/bnxt: support LED on/off") Fixes: 804e746c7b73 ("net/bnxt: add hardware resource manager init code") Fixes: 1d0704f4d793 ("net/bnxt: add device configure operation") Fixes: 698aa7e95325 ("net/bnxt: add code to determine the Tx COS queue") Fixes: 322bd6e70272 ("net/bnxt: add port representor infrastructure") Fixes: 0bf5a0b5ebb8 ("net/bnxt: add a failure log") Signed-off-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_ethdev.c | 39 +++++++++++++++++++++++++--------- drivers/net/bnxt/bnxt_hwrm.c | 3 +++ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 4a3b429dcf..1db2e1efd3 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -229,16 +229,19 @@ uint16_t bnxt_rss_hash_tbl_size(const struct bnxt *bp) static void bnxt_free_parent_info(struct bnxt *bp) { rte_free(bp->parent); + bp->parent = NULL; } static void bnxt_free_pf_info(struct bnxt *bp) { rte_free(bp->pf); + bp->pf = NULL; } static void bnxt_free_link_info(struct bnxt *bp) { rte_free(bp->link_info); + bp->link_info = NULL; } static void bnxt_free_leds_info(struct bnxt *bp) @@ -259,7 +262,9 @@ static void bnxt_free_flow_stats_info(struct bnxt *bp) static void bnxt_free_cos_queues(struct bnxt *bp) { rte_free(bp->rx_cos_queue); + bp->rx_cos_queue = NULL; rte_free(bp->tx_cos_queue); + bp->tx_cos_queue = NULL; } static void bnxt_free_mem(struct bnxt *bp, bool reconfig) @@ -853,9 +858,14 @@ static int bnxt_shutdown_nic(struct bnxt *bp) uint32_t bnxt_get_speed_capabilities(struct bnxt *bp) { - uint32_t link_speed = bp->link_info->support_speeds; + uint32_t link_speed = 0; uint32_t speed_capa = 0; + if (bp->link_info == NULL) + return 0; + + link_speed = bp->link_info->support_speeds; + /* If PAM4 is configured, use PAM4 supported speed */ if (link_speed == 0 && bp->link_info->support_pam4_speeds > 0) link_speed = bp->link_info->support_pam4_speeds; @@ -1288,12 +1298,13 @@ static void bnxt_free_switch_domain(struct bnxt *bp) { int rc = 0; - if (bp->switch_domain_id) { - rc = rte_eth_switch_domain_free(bp->switch_domain_id); - if (rc) - PMD_DRV_LOG(ERR, "free switch domain:%d fail: %d\n", - bp->switch_domain_id, rc); - } + if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) + return; + + rc = rte_eth_switch_domain_free(bp->switch_domain_id); + if (rc) + PMD_DRV_LOG(ERR, "free switch domain:%d fail: %d\n", + bp->switch_domain_id, rc); } /* Unload the driver, release resources */ @@ -1450,11 +1461,9 @@ bnxt_uninit_locks(struct bnxt *bp) static void bnxt_drv_uninit(struct bnxt *bp) { - bnxt_free_switch_domain(bp); bnxt_free_leds_info(bp); bnxt_free_cos_queues(bp); bnxt_free_link_info(bp); - bnxt_free_pf_info(bp); bnxt_free_parent_info(bp); bnxt_uninit_locks(bp); @@ -1464,6 +1473,7 @@ static void bnxt_drv_uninit(struct bnxt *bp) bp->rx_mem_zone = NULL; bnxt_free_vf_info(bp); + bnxt_free_pf_info(bp); rte_free(bp->grp_info); bp->grp_info = NULL; @@ -1616,6 +1626,10 @@ int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete) return rc; memset(&new, 0, sizeof(new)); + + if (bp->link_info == NULL) + goto out; + do { /* Retrieve link info from hardware */ rc = bnxt_get_hwrm_link_config(bp, &new); @@ -5519,7 +5533,10 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev) bnxt_free_mem(bp, reconfig_dev); bnxt_hwrm_func_buf_unrgtr(bp); - rte_free(bp->pf->vf_req_buf); + if (bp->pf != NULL) { + rte_free(bp->pf->vf_req_buf); + bp->pf->vf_req_buf = NULL; + } rc = bnxt_hwrm_func_driver_unregister(bp, 0); bp->flags &= ~BNXT_FLAG_REGISTERED; @@ -5532,6 +5549,8 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev) bnxt_uninit_ctx_mem(bp); bnxt_free_flow_stats_info(bp); + if (bp->rep_info != NULL) + bnxt_free_switch_domain(bp); bnxt_free_rep_info(bp); rte_free(bp->ptp_cfg); bp->ptp_cfg = NULL; diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 2e2460b71a..67509dc8f9 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -677,6 +677,9 @@ void bnxt_free_vf_info(struct bnxt *bp) { int i; + if (bp->pf == NULL) + return; + if (bp->pf->vf_info == NULL) return; -- 2.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-05-10 23:59:32.305223900 +0800 +++ 0223-net-bnxt-fix-resource-cleanup.patch 2021-05-10 23:59:26.700000000 +0800 @@ -1 +1 @@ -From e2895305a5b54a596b510f763c61652bf05e81db Mon Sep 17 00:00:00 2001 +From 8ffdca19f32d8f6710463c9ee3a3eb5c2d1b4c1b Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Luca Boccassi + +[ upstream commit e2895305a5b54a596b510f763c61652bf05e81db ] @@ -16 +18,0 @@ -Cc: stable@dpdk.org @@ -25 +27 @@ -index 20ca57eae5..dc3b04110f 100644 +index 4a3b429dcf..1db2e1efd3 100644 @@ -28 +30 @@ -@@ -219,16 +219,19 @@ uint16_t bnxt_rss_hash_tbl_size(const struct bnxt *bp) +@@ -229,16 +229,19 @@ uint16_t bnxt_rss_hash_tbl_size(const struct bnxt *bp) @@ -48 +50 @@ -@@ -249,7 +252,9 @@ static void bnxt_free_flow_stats_info(struct bnxt *bp) +@@ -259,7 +262,9 @@ static void bnxt_free_flow_stats_info(struct bnxt *bp) @@ -58 +60 @@ -@@ -849,9 +854,14 @@ static int bnxt_shutdown_nic(struct bnxt *bp) +@@ -853,9 +858,14 @@ static int bnxt_shutdown_nic(struct bnxt *bp) @@ -74 +76 @@ -@@ -1293,12 +1303,13 @@ static void bnxt_free_switch_domain(struct bnxt *bp) +@@ -1288,12 +1298,13 @@ static void bnxt_free_switch_domain(struct bnxt *bp) @@ -93,2 +95,2 @@ - static void bnxt_ptp_get_current_time(void *arg) -@@ -1545,11 +1556,9 @@ bnxt_uninit_locks(struct bnxt *bp) + /* Unload the driver, release resources */ +@@ -1450,11 +1461,9 @@ bnxt_uninit_locks(struct bnxt *bp) @@ -106 +108 @@ -@@ -1559,6 +1568,7 @@ static void bnxt_drv_uninit(struct bnxt *bp) +@@ -1464,6 +1473,7 @@ static void bnxt_drv_uninit(struct bnxt *bp) @@ -114 +116 @@ -@@ -1720,6 +1730,10 @@ int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete) +@@ -1616,6 +1626,10 @@ int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete) @@ -125 +127 @@ -@@ -5748,7 +5762,10 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev) +@@ -5519,7 +5533,10 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev) @@ -137 +139 @@ -@@ -5761,6 +5778,8 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev) +@@ -5532,6 +5549,8 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev) @@ -147 +149 @@ -index a119fc3a0b..cb2064dd57 100644 +index 2e2460b71a..67509dc8f9 100644 @@ -150 +152 @@ -@@ -792,6 +792,9 @@ void bnxt_free_vf_info(struct bnxt *bp) +@@ -677,6 +677,9 @@ void bnxt_free_vf_info(struct bnxt *bp)