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 4304342CBC for ; Thu, 15 Jun 2023 03:34:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2FFCD42D3F; Thu, 15 Jun 2023 03:34:42 +0200 (CEST) Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by mails.dpdk.org (Postfix) with ESMTP id E3B7940DDA for ; Thu, 15 Jun 2023 03:34:40 +0200 (CEST) Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-3f8d65ecdbbso11267695e9.0 for ; Wed, 14 Jun 2023 18:34:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686792880; x=1689384880; 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=uPB0tUtIjyTr5nkyEMoVjDptzruNfG+yEQDaFcIDpkA=; b=dB6mRwJ0dBxuiwRJ6GwUYxZBzoi54DoQTjpej0QA6EE6dlkVnKZKgO2eZR09svNzdz zb9LfSgaSyqTzOz5Enl4bflZ7l3vTIy0IyH4TnG6nIrvDou/BmEDDko8+8+ec6hknIkH UW3BJURG0ZJtkYFVSnZZdIlyn7/jbUX6qG1roDzsicyBKxE0/OZObptui5rpT7vRou1R lyrNWQbCD6OtyuahkVBpRL/zI3D0uqBoWV7VeQ+q7w0ZiKR8Q89V+gx+4nu1t4+OX7e3 Jgcl6H+tR19Wse6Cpm+QO7PfSdFKscpsDVG5QxN7DGJKWSY3wwUddhslt1o8t5YJTzRZ UKaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686792880; x=1689384880; 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=uPB0tUtIjyTr5nkyEMoVjDptzruNfG+yEQDaFcIDpkA=; b=aQV0smUrzRW3f5/CnNiCai8DRzt/OUMGnaBtqX2aNK41mS0iX4TCSerB37DSD5WIVt j+aB6swdgF3WIn7FxaNNpzVp/EakO1DJ9oLOSuSsx0mUQ1S3BkovdlvB9x0FYqWm/LXI 89LQNWvzSwXPeUhvwTXBh1KwwvgIskweEOa1YRUHHlRXTV2xiJe5SkxY56njVnFh/f7S 4nkiuQkeXenLw1DHqmdB2LWYZLN4fhVocyu1JIfDcjqP8RY5H3IFvsZa7gTG+aaXLvv8 VPbMnfG7x1jh65AhmAOYLFTAgwKCVikpFr1BqjCTaAfI5iDAq9FkxUgVEvH7QWBP1qG9 Qn7w== X-Gm-Message-State: AC+VfDzC+hVWtI3Cv/KfCv/sNhe2s5Wr8+DEi2sZ2o9lLHv5PVf4DUb1 1VCxvgxVPXbAB2fKFFO2vrfFSvipqbWcuxc0 X-Google-Smtp-Source: ACHHUZ7BTNEc+MU+ime6NFKwYiV2TMlhWtizXwN147yo/hAwim0fNyd1D+J03R/eAjeAoFbgtDpWwA== X-Received: by 2002:a05:600c:2212:b0:3f6:cfc7:8bc7 with SMTP id z18-20020a05600c221200b003f6cfc78bc7mr10788021wml.17.1686792880509; Wed, 14 Jun 2023 18:34:40 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id k6-20020a5d6286000000b0030903371ef9sm19385960wru.22.2023.06.14.18.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 18:34:39 -0700 (PDT) From: luca.boccassi@gmail.com 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 20.11.9 Date: Thu, 15 Jun 2023 02:32:27 +0100 Message-Id: <20230615013258.1439718-32-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230615013258.1439718-1-luca.boccassi@gmail.com> References: <20230615013258.1439718-1-luca.boccassi@gmail.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 Hi, FYI, your patch has been queued to stable release 20.11.9 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/17/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://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/dea7a629dfa59c9e051e75e8f64a526e83562f01 Thanks. Luca Boccassi --- >From dea7a629dfa59c9e051e75e8f64a526e83562f01 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 [ 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 18b2b42508..86fac45d5f 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -3997,6 +3997,13 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) return -ENOTSUP; rte_spinlock_lock(&hw->lock); + + if (rte_atomic16_read(&hw->reset.resetting)) { + 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.", @@ -4043,6 +4050,13 @@ hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) return -ENOTSUP; rte_spinlock_lock(&hw->lock); + + if (rte_atomic16_read(&hw->reset.resetting)) { + 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); @@ -4065,6 +4079,13 @@ hns3_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) return -ENOTSUP; rte_spinlock_lock(&hw->lock); + + if (rte_atomic16_read(&hw->reset.resetting)) { + 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.", @@ -4091,6 +4112,13 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) return -ENOTSUP; rte_spinlock_lock(&hw->lock); + + if (rte_atomic16_read(&hw->reset.resetting)) { + 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.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-06-15 01:56:36.406305518 +0100 +++ 0032-net-hns3-fix-mbuf-leakage-when-RxQ-started-during-re.patch 2023-06-15 01:56:34.607542177 +0100 @@ -1 +1 @@ -From bbc5a31b8ead8a353da5b1c46e0209d2fa9dae24 Mon Sep 17 00:00:00 2001 +From dea7a629dfa59c9e051e75e8f64a526e83562f01 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit bbc5a31b8ead8a353da5b1c46e0209d2fa9dae24 ] + @@ -24 +25,0 @@ -Cc: stable@dpdk.org @@ -33 +34 @@ -index 6468da903e..2bfc5507e3 100644 +index 18b2b42508..86fac45d5f 100644 @@ -36 +37 @@ -@@ -4523,6 +4523,13 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) +@@ -3997,6 +3997,13 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) @@ -41 +42 @@ -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { ++ if (rte_atomic16_read(&hw->reset.resetting)) { @@ -50 +51 @@ -@@ -4569,6 +4576,13 @@ hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) +@@ -4043,6 +4050,13 @@ hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) @@ -55 +56 @@ -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { ++ if (rte_atomic16_read(&hw->reset.resetting)) { @@ -64 +65 @@ -@@ -4591,6 +4605,13 @@ hns3_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) +@@ -4065,6 +4079,13 @@ hns3_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) @@ -69 +70 @@ -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { ++ if (rte_atomic16_read(&hw->reset.resetting)) { @@ -78 +79 @@ -@@ -4617,6 +4638,13 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) +@@ -4091,6 +4112,13 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) @@ -83 +84 @@ -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { ++ if (rte_atomic16_read(&hw->reset.resetting)) {