From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6BC0DA0527 for ; Mon, 9 Nov 2020 19:42:53 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6386E69C8; Mon, 9 Nov 2020 19:42:52 +0100 (CET) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by dpdk.org (Postfix) with ESMTP id 9C81669C8 for ; Mon, 9 Nov 2020 19:42:50 +0100 (CET) Received: by mail-wm1-f52.google.com with SMTP id w24so454885wmi.0 for ; Mon, 09 Nov 2020 10:42:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y0ym33g3LhCenjhWr50jCl4lkAMOrqFw3CZqfSydAyQ=; b=BM5EEXGa09UIUXa/+QEEERxaIOjHocVgAa7AflLY/LjL6yDnIa3aGKI5IN80UV/IIf d/69a/hbo8UtyZBewzrFtxWjdpU3xMkpj2LokjgNV+sPTMFZRxPTerzD+eiDcERjle9G EMBoowByk42dhuoUVMuFVucROf7Y1oxdOPShRa80kd4eg2iCplwm6+nOcdKvTUV7MyQG Eyky9vQNnnCc+t8zH9eUOIY0eDVIWil4g+1ItFElVY7vDYL3O+K6wPYepaLjnAG5VtIi 0NJoj5J6tph58F/8UwHlIXs06riKCu+qr0W76q78h3ZTssxUC7uhcnsfP/e0rTU5rF8C 4mQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y0ym33g3LhCenjhWr50jCl4lkAMOrqFw3CZqfSydAyQ=; b=BSNMeatCez46ipktYRAtAL9SmIJyoV4ubuCmTx8FYmxzQFEfeTe+32V7B6BfytmxVh GbJWT5ne2FSnAEMUgfPLnBwrVd+5Y2qS9nMb++7Ncuuwfc42+eG5z86NsRzmshiVlr8f hUZls09NfA9P6JiUQb2E9+OahNBdDnbpDkALRK7qt5tJ7zYZ4YFQqcAKuvlwm1YTvTOs Q0F1jpPGNShnKi6u27RqalXiUYGOwJJA0FBsfdz2S4ZIVNTowlsDsm4IaKChpj+wSA8L wU0gyTeY4zamk5s1VmopgR5vfZ+3CumCFgPrQ2c6GfmQ+74kjBYSDSZKqg5BksumWDfS y0Lw== X-Gm-Message-State: AOAM5322CYZEb6j5SrEoJQDqDbNWUIWmtOA8BNxFyStSCXzl4YthULY5 6NUjjWUYBTrsDp35s9HlFtO738hlMuWQrg== X-Google-Smtp-Source: ABdhPJxdLvG2LPlW6mkFNy/bVrCmWcwa5lseAatYrzscV7Nqpx0oSP7luV7REVXPyiigEKwrjGL8Cg== X-Received: by 2002:a1c:5f45:: with SMTP id t66mr587993wmb.20.1604947369382; Mon, 09 Nov 2020 10:42:49 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id 90sm14079560wrl.30.2020.11.09.10.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 10:42:48 -0800 (PST) From: luca.boccassi@gmail.com To: Somnath Kotur Cc: Ajit Khaparde , dpdk stable Date: Mon, 9 Nov 2020 18:40:15 +0000 Message-Id: <20201109184111.3463090-27-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201109184111.3463090-1-luca.boccassi@gmail.com> References: <20201028104606.3504127-207-luca.boccassi@gmail.com> <20201109184111.3463090-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/bnxt: fix queue release' has been queued to stable release 19.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 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 19.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/11/20. 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/f41c86a38298fb4cb16b7c7409e22ca33ba40cfe Thanks. Luca Boccassi --- >From f41c86a38298fb4cb16b7c7409e22ca33ba40cfe Mon Sep 17 00:00:00 2001 From: Somnath Kotur Date: Tue, 20 Oct 2020 09:41:18 +0530 Subject: [PATCH] net/bnxt: fix queue release [ upstream commit 97c3271781bf1094b0ab0235f472fb5a468b02d3 ] Some of the ring related memory was not being freed in both the release ops. Fix to free them now. Add some more NULL ptr checks in the corresponding queue_release_mbufs() and queue_release_op() respectively. Also call queue_release_op() in the error path of the corresponding queue_setup_op() Fixes: 6133f207970c ("net/bnxt: add Rx queue create/destroy") Fixes: 51c87ebafc7d ("net/bnxt: add Tx queue create/destroy") Signed-off-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_rxq.c | 42 +++++++++++++++++++++++-------------- drivers/net/bnxt/bnxt_txq.c | 36 ++++++++++++++++++------------- 2 files changed, 47 insertions(+), 31 deletions(-) diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c index 682cdb91ad..bb0196670a 100644 --- a/drivers/net/bnxt/bnxt_rxq.c +++ b/drivers/net/bnxt/bnxt_rxq.c @@ -201,7 +201,7 @@ void bnxt_rx_queue_release_mbufs(struct bnxt_rx_queue *rxq) struct bnxt_tpa_info *tpa_info; uint16_t i; - if (!rxq) + if (!rxq || !rxq->rx_ring) return; rte_spinlock_lock(&rxq->lock); @@ -266,12 +266,21 @@ void bnxt_rx_queue_release_op(void *rx_queue) bnxt_rx_queue_release_mbufs(rxq); /* Free RX ring hardware descriptors */ - bnxt_free_ring(rxq->rx_ring->rx_ring_struct); - /* Free RX Agg ring hardware descriptors */ - bnxt_free_ring(rxq->rx_ring->ag_ring_struct); + if (rxq->rx_ring) { + bnxt_free_ring(rxq->rx_ring->rx_ring_struct); + rte_free(rxq->rx_ring->rx_ring_struct); + /* Free RX Agg ring hardware descriptors */ + bnxt_free_ring(rxq->rx_ring->ag_ring_struct); + rte_free(rxq->rx_ring->ag_ring_struct); + rte_free(rxq->rx_ring); + } /* Free RX completion ring hardware descriptors */ - bnxt_free_ring(rxq->cp_ring->cp_ring_struct); + if (rxq->cp_ring) { + bnxt_free_ring(rxq->cp_ring->cp_ring_struct); + rte_free(rxq->cp_ring->cp_ring_struct); + rte_free(rxq->cp_ring); + } bnxt_free_rxq_stats(rxq); rte_memzone_free(rxq->mz); @@ -307,8 +316,7 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, if (!nb_desc || nb_desc > MAX_RX_DESC_CNT) { PMD_DRV_LOG(ERR, "nb_desc %d is invalid\n", nb_desc); - rc = -EINVAL; - goto out; + return -EINVAL; } if (eth_dev->data->rx_queues) { @@ -320,8 +328,7 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, RTE_CACHE_LINE_SIZE, socket_id); if (!rxq) { PMD_DRV_LOG(ERR, "bnxt_rx_queue allocation failed!\n"); - rc = -ENOMEM; - goto out; + return -ENOMEM; } rxq->bp = bp; rxq->mb_pool = mp; @@ -336,8 +343,11 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, PMD_DRV_LOG(DEBUG, "RX Buf MTU %d\n", eth_dev->data->mtu); rc = bnxt_init_rx_ring_struct(rxq, socket_id); - if (rc) - goto out; + if (rc) { + PMD_DRV_LOG(ERR, + "init_rx_ring_struct failed!\n"); + goto err; + } PMD_DRV_LOG(DEBUG, "RX Buf size is %d\n", rxq->rx_buf_size); rxq->queue_id = queue_idx; @@ -352,10 +362,8 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, if (bnxt_alloc_rings(bp, queue_idx, NULL, rxq, rxq->cp_ring, NULL, "rxr")) { PMD_DRV_LOG(ERR, - "ring_dma_zone_reserve for rx_ring failed!\n"); - bnxt_rx_queue_release_op(rxq); - rc = -ENOMEM; - goto out; + "ring_dma_zone_reserve for rx_ring failed!\n"); + goto err; } rte_atomic64_init(&rxq->rx_mbuf_alloc_fail); @@ -379,7 +387,9 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, if (!queue_idx) bnxt_mtu_set_op(eth_dev, eth_dev->data->mtu); -out: + return 0; +err: + bnxt_rx_queue_release_op(rxq); return rc; } diff --git a/drivers/net/bnxt/bnxt_txq.c b/drivers/net/bnxt/bnxt_txq.c index 2d7645eeb0..160e841576 100644 --- a/drivers/net/bnxt/bnxt_txq.c +++ b/drivers/net/bnxt/bnxt_txq.c @@ -27,7 +27,7 @@ static void bnxt_tx_queue_release_mbufs(struct bnxt_tx_queue *txq) struct bnxt_sw_tx_bd *sw_ring; uint16_t i; - if (!txq) + if (!txq || !txq->tx_ring) return; sw_ring = txq->tx_ring->tx_buf_ring; @@ -62,10 +62,18 @@ void bnxt_tx_queue_release_op(void *tx_queue) /* Free TX ring hardware descriptors */ bnxt_tx_queue_release_mbufs(txq); - bnxt_free_ring(txq->tx_ring->tx_ring_struct); + if (txq->tx_ring) { + bnxt_free_ring(txq->tx_ring->tx_ring_struct); + rte_free(txq->tx_ring->tx_ring_struct); + rte_free(txq->tx_ring); + } /* Free TX completion ring hardware descriptors */ - bnxt_free_ring(txq->cp_ring->cp_ring_struct); + if (txq->cp_ring) { + bnxt_free_ring(txq->cp_ring->cp_ring_struct); + rte_free(txq->cp_ring->cp_ring_struct); + rte_free(txq->cp_ring); + } bnxt_free_txq_stats(txq); rte_memzone_free(txq->mz); @@ -99,8 +107,7 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, if (!nb_desc || nb_desc > MAX_TX_DESC_CNT) { PMD_DRV_LOG(ERR, "nb_desc %d is invalid", nb_desc); - rc = -EINVAL; - goto out; + return -EINVAL; } if (eth_dev->data->tx_queues) { @@ -114,8 +121,7 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, RTE_CACHE_LINE_SIZE, socket_id); if (!txq) { PMD_DRV_LOG(ERR, "bnxt_tx_queue allocation failed!"); - rc = -ENOMEM; - goto out; + return -ENOMEM; } txq->free = rte_zmalloc_socket(NULL, @@ -123,9 +129,8 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, RTE_CACHE_LINE_SIZE, socket_id); if (!txq->free) { PMD_DRV_LOG(ERR, "allocation of tx mbuf free array failed!"); - rte_free(txq); rc = -ENOMEM; - goto out; + goto err; } txq->bp = bp; txq->nb_tx_desc = nb_desc; @@ -134,7 +139,7 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, rc = bnxt_init_tx_ring_struct(txq, socket_id); if (rc) - goto out; + goto err; txq->queue_id = queue_idx; txq->port_id = eth_dev->data->port_id; @@ -143,16 +148,14 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, if (bnxt_alloc_rings(bp, queue_idx, txq, NULL, txq->cp_ring, NULL, "txr")) { PMD_DRV_LOG(ERR, "ring_dma_zone_reserve for tx_ring failed!"); - bnxt_tx_queue_release_op(txq); rc = -ENOMEM; - goto out; + goto err; } if (bnxt_init_one_tx_ring(txq)) { PMD_DRV_LOG(ERR, "bnxt_init_one_tx_ring failed!"); - bnxt_tx_queue_release_op(txq); rc = -ENOMEM; - goto out; + goto err; } eth_dev->data->tx_queues[queue_idx] = txq; @@ -161,6 +164,9 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, txq->tx_started = false; else txq->tx_started = true; -out: + + return 0; +err: + bnxt_tx_queue_release_op(txq); return rc; } -- 2.27.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-11-09 18:40:12.305001249 +0000 +++ 0027-net-bnxt-fix-queue-release.patch 2020-11-09 18:40:11.127311220 +0000 @@ -1 +1 @@ -From 97c3271781bf1094b0ab0235f472fb5a468b02d3 Mon Sep 17 00:00:00 2001 +From f41c86a38298fb4cb16b7c7409e22ca33ba40cfe Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 97c3271781bf1094b0ab0235f472fb5a468b02d3 ] + @@ -15 +16,0 @@ -Cc: stable@dpdk.org @@ -25 +26 @@ -index 1003ca6410..78514143e5 100644 +index 682cdb91ad..bb0196670a 100644 @@ -28 +29 @@ -@@ -207,7 +207,7 @@ void bnxt_rx_queue_release_mbufs(struct bnxt_rx_queue *rxq) +@@ -201,7 +201,7 @@ void bnxt_rx_queue_release_mbufs(struct bnxt_rx_queue *rxq) @@ -37 +38 @@ -@@ -273,12 +273,21 @@ void bnxt_rx_queue_release_op(void *rx_queue) +@@ -266,12 +266,21 @@ void bnxt_rx_queue_release_op(void *rx_queue) @@ -63 +64 @@ -@@ -314,8 +323,7 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, +@@ -307,8 +316,7 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, @@ -65 +66 @@ - if (nb_desc < BNXT_MIN_RING_DESC || nb_desc > MAX_RX_DESC_CNT) { + if (!nb_desc || nb_desc > MAX_RX_DESC_CNT) { @@ -73 +74 @@ -@@ -327,8 +335,7 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, +@@ -320,8 +328,7 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, @@ -83 +84 @@ -@@ -344,8 +351,11 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, +@@ -336,8 +343,11 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, @@ -97 +98 @@ -@@ -360,10 +370,8 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, +@@ -352,10 +362,8 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, @@ -110 +111 @@ -@@ -387,7 +395,9 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, +@@ -379,7 +387,9 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, @@ -122 +123 @@ -index c8d75ac951..c9792a2af2 100644 +index 2d7645eeb0..160e841576 100644 @@ -157 +158 @@ - if (nb_desc < BNXT_MIN_RING_DESC || nb_desc > MAX_TX_DESC_CNT) { + if (!nb_desc || nb_desc > MAX_TX_DESC_CNT) { @@ -186 +187 @@ -@@ -138,7 +143,7 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, +@@ -134,7 +139,7 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, @@ -195 +196 @@ -@@ -147,16 +152,14 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, +@@ -143,16 +148,14 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, @@ -214 +215 @@ -@@ -165,6 +168,9 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, +@@ -161,6 +164,9 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,