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 19F4A42D46 for ; Sun, 25 Jun 2023 08:40:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 112EE42D16; Sun, 25 Jun 2023 08:40:49 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2080.outbound.protection.outlook.com [40.107.92.80]) by mails.dpdk.org (Postfix) with ESMTP id 1C1E140A7F for ; Sun, 25 Jun 2023 08:40:48 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EfOIDnUn74G6z2No1MfAKvi6HCtULT97HQ04WutUJBxly7ovhM/vCswLurrbB8Pb8AmeXTA/M6fS7KvUvWL8rKEB/PPZH+SnK3CXlX7pdA5BfmQ8VlCtaXojBPykrhmkbKH0Tbb8Bck+7Vgf7sTJGYIsF7rE8G96RWVWx77O9uO3FDco/vrq7VwlES8Sn2kyJ34CEcx1/JTapj8WFcV/A5I9ni3uLhgvczZ/yiuep2x1fDjq7GHu55XTR5hILKXLHvisGFmTBwaqRR0KtxzPuwa1IjjLUv57Bg31LcB3BaWpk+YMK8AdAovl8ChlaOR5fWz2vvkgbiuf54ULrTFZrw== 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=KCf6MjyS04wb0/5YhLspMqXN8e3DChNaBa02IBX+yno=; b=BN2U7vN5T2piXvjbn9w5B3ZZDIurpZGLUK31eoEtXcx5PMfzuD88Xaml+zYzPx5zb35Ugdh0q4W5UP17z564nxroqL06pLpFMBS4HIJogzRFZDYzuhDRh5X3f2YFlSN3If4UhIAYz3baJnjUwEBdtO+HB80lHPRccDWPtml/wrEOqlKLij/dIWnKdIXIcQZTBWQ8hnBlI//mRaD84HHrTyCg1bthWbmQHHCnnQgJtFhiOCKiT6sWvp8Gev0kZxi2QxLOtlnuaNCBBkFUBbEzyDoFznWhs1d72Gyk6b96/aFb0mH/IdelOTe2PfyWHOlYubAiHHiIYeqvTK3zsY1Lhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=huawei.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 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=KCf6MjyS04wb0/5YhLspMqXN8e3DChNaBa02IBX+yno=; b=arGG+W5LQqaLhc1ODhqHlKGJPfC+yFDiepOZ56pQX52Cn/dvNcwOsS3C6lMCu3oB2KizKg1A6RhmWngiq/5HMLM1BJtPIAYCtMG6bFLP2XGUljmiLnJ8l/yvKwhcln2WouvUF4FXSqJ0xcwAJpkeEyziaGj3/DVxQrFoUidUumbVkXAEVdaOnRsQxKa2FtyCzf/f8peNV0z1JOCZP8ueRpsnTaiJKQofmQC5ORnAuNuf+rHXhguK7Ojui0aAreBhC6Ii0qbcy0vQmv61x7nZJLuZLowaABLprfHGdtHVl/HVFrrSG5x/UhCSwnFC+DREI0kMC+7nKGhkMz667Mq+qQ== Received: from BN6PR17CA0052.namprd17.prod.outlook.com (2603:10b6:405:75::41) by CH2PR12MB4312.namprd12.prod.outlook.com (2603:10b6:610:af::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Sun, 25 Jun 2023 06:40:44 +0000 Received: from BN8NAM11FT069.eop-nam11.prod.protection.outlook.com (2603:10b6:405:75:cafe::d7) by BN6PR17CA0052.outlook.office365.com (2603:10b6:405:75::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.32 via Frontend Transport; Sun, 25 Jun 2023 06:40:44 +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 BN8NAM11FT069.mail.protection.outlook.com (10.13.176.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.47 via Frontend Transport; Sun, 25 Jun 2023 06:40:43 +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.5; Sat, 24 Jun 2023 23:40:27 -0700 Received: from nvidia.com (10.126.230.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.986.37; Sat, 24 Jun 2023 23:40:26 -0700 From: Xueming Li To: Chengwen Feng CC: Dongdong Liu , dpdk stable Subject: patch 'net/hns3: fix mbuf leakage when RxQ started during reset' has been queued to stable release 22.11.3 Date: Sun, 25 Jun 2023 14:34:30 +0800 Message-ID: <20230625063544.11183-53-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230625063544.11183-1-xuemingl@nvidia.com> References: <20230625063544.11183-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.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: BN8NAM11FT069:EE_|CH2PR12MB4312:EE_ X-MS-Office365-Filtering-Correlation-Id: 7164e577-9d72-4df9-90fe-08db75471986 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /bO17oY8t5UcEPCnPgyxUNPoU2a94oBJKmqTMcK2cnZCzwLosUDhwhD2onI63G8RwDNo354qBakp84uNCIxsayldkq+dh3BxcE4xkN4qcRtXXNGJxjuAf9PazHv6JUw+1ZHQPikXhEbev0zkrHWMziN3YyPIkQOsJE8WyBJADAbd+wni46/31zwKlwQZbbmi06u2oLwI+a5W4TqbvWeF+4TtnZR/7vdTxfi8sAt62+sn6mYfSinCJpfsGAxPkjSSB7+J7Zu1T932N9XpC53lOYWBQksZf14qCgG7/wUUm4O/sqc4JW2tf7MYBrY+7SQDHlZZVAYNwwfKq6YwJf35n3MUuQk6MnglSI0hY+BDZrhoePqlL8quKj5Q2DO9GaXHpo4YZbUsN+/wgK0TSz1xTeOVU2b+kf2+pX7qPMzaRAkyPialN872mUAhtho4tLbfE7WOybvh7KtiNYLUbwgYwNWEuFKUgCMuK8AuS0FWOma4HZWGpulggyjxDqh3NKuTArSN419h78cGEZ95wtjTsbv1ZYYQOMahAfjRVd66FEGNJDUdW/7Jqt73Xhsc7FtIfCoDsQqZtcvGgW1prJnGItol/Cwxb4VIpnwodN0mv8MIsqd1oEhtX0Z33ibus8i799Ndd/qSxiKAwsQVka+LjSJ5pxeffJHt7lFoUYFfMQf0x2FcdDLIhDY7gQdRBkWMSEMUxTX37Qra/cFel6MNOzikAExeWohk0hxNaP+3AF5nr4q5w//uNHiaaU3lfOqB2P8poZ22YCMAHWE5HcVEnQ== 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:(13230028)(4636009)(136003)(39860400002)(376002)(346002)(396003)(451199021)(36840700001)(46966006)(40470700004)(8676002)(70206006)(8936002)(70586007)(55016003)(41300700001)(316002)(6916009)(4326008)(1076003)(53546011)(26005)(6286002)(16526019)(186003)(336012)(2616005)(478600001)(54906003)(6666004)(40460700003)(966005)(7696005)(82310400005)(2906002)(5660300002)(40480700001)(82740400003)(356005)(7636003)(36756003)(86362001)(36860700001)(47076005)(83380400001)(426003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2023 06:40:43.2403 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7164e577-9d72-4df9-90fe-08db75471986 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: BN8NAM11FT069.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4312 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 22.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/27/23. 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=22.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=22.11-staging&id=e9ade95ac4ad0a74c74f32eef7b68e1a70edde10 Thanks. Xueming Li --- >From e9ade95ac4ad0a74c74f32eef7b68e1a70edde10 Mon Sep 17 00:00:00 2001 From: Chengwen Feng Date: Fri, 2 Jun 2023 19:41:59 +0800 Subject: [PATCH] net/hns3: fix mbuf leakage when RxQ started during reset Cc: Xueming Li [ upstream commit bbc5a31b8ead8a353da5b1c46e0209d2fa9dae24 ] In the reset restore-conf phase, the reset process will allocate for the Rx ring mbufs unconditionlly. And the rte_eth_dev_rx_queue_start() will also allocate for the Rx ring mbufs unconditionlly. So if the rte_eth_dev_rx_queue_start() is invoked before restore-conf phase, then the mbufs allocated by rte_eth_dev_rx_queue_start() will leak. Because the hw->reset.resetting was always true during the phases from stop-service to restore-conf, so fix it by returning an error if the hw->reset.resetting is set. This patch adds the above logic in both rx_queue_start/rx_queue_stop/ tx_queue_start/tx_queue_stop ops. Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop") Signed-off-by: Chengwen Feng Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_rxtx.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 4065c519c3..10ac4926a8 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -4469,6 +4469,13 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) return -ENOTSUP; rte_spinlock_lock(&hw->lock); + + if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { + hns3_err(hw, "fail to start Rx queue during resetting."); + rte_spinlock_unlock(&hw->lock); + return -EIO; + } + ret = hns3_reset_queue(hw, rx_queue_id, HNS3_RING_TYPE_RX); if (ret) { hns3_err(hw, "fail to reset Rx queue %u, ret = %d.", @@ -4515,6 +4522,13 @@ hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) return -ENOTSUP; rte_spinlock_lock(&hw->lock); + + if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { + hns3_err(hw, "fail to stop Rx queue during resetting."); + rte_spinlock_unlock(&hw->lock); + return -EIO; + } + hns3_enable_rxq(rxq, false); hns3_rx_queue_release_mbufs(rxq); @@ -4537,6 +4551,13 @@ hns3_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) return -ENOTSUP; rte_spinlock_lock(&hw->lock); + + if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { + hns3_err(hw, "fail to start Tx queue during resetting."); + rte_spinlock_unlock(&hw->lock); + return -EIO; + } + ret = hns3_reset_queue(hw, tx_queue_id, HNS3_RING_TYPE_TX); if (ret) { hns3_err(hw, "fail to reset Tx queue %u, ret = %d.", @@ -4563,6 +4584,13 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) return -ENOTSUP; rte_spinlock_lock(&hw->lock); + + if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { + hns3_err(hw, "fail to stop Tx queue during resetting."); + rte_spinlock_unlock(&hw->lock); + return -EIO; + } + hns3_enable_txq(txq, false); hns3_tx_queue_release_mbufs(txq); /* -- 2.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-06-25 14:31:59.915436200 +0800 +++ 0052-net-hns3-fix-mbuf-leakage-when-RxQ-started-during-re.patch 2023-06-25 14:31:58.385773900 +0800 @@ -1 +1 @@ -From bbc5a31b8ead8a353da5b1c46e0209d2fa9dae24 Mon Sep 17 00:00:00 2001 +From e9ade95ac4ad0a74c74f32eef7b68e1a70edde10 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit bbc5a31b8ead8a353da5b1c46e0209d2fa9dae24 ] @@ -24 +26,0 @@ -Cc: stable@dpdk.org @@ -33 +35 @@ -index 6468da903e..2bfc5507e3 100644 +index 4065c519c3..10ac4926a8 100644 @@ -36 +38 @@ -@@ -4523,6 +4523,13 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) +@@ -4469,6 +4469,13 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) @@ -50 +52 @@ -@@ -4569,6 +4576,13 @@ hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) +@@ -4515,6 +4522,13 @@ hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) @@ -64 +66 @@ -@@ -4591,6 +4605,13 @@ hns3_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) +@@ -4537,6 +4551,13 @@ hns3_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) @@ -78 +80 @@ -@@ -4617,6 +4638,13 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) +@@ -4563,6 +4584,13 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)