Blame SOURCES/0001-net-qede-fix-memory-alloc-for-multiple-port-reconfig.patch

a6040a
From 36a62d0d627d4858a97768d5ff1d72b4bd0abd8e Mon Sep 17 00:00:00 2001
a6040a
From: Rasesh Mody <rasesh.mody@cavium.com>
a6040a
Date: Thu, 7 Jun 2018 09:30:20 -0700
a6040a
Subject: [PATCH] net/qede: fix memory alloc for multiple port reconfig
a6040a
a6040a
Multiple port reconfigurations can lead to memory allocation failures
a6040a
due to hitting RTE memzone limit or no more room in config while
a6040a
reserving memzone.
a6040a
a6040a
When freeing memzones, update the memzone mapping and the memzone count.
a6040a
Release Rx and Tx queue rings allocated during queue setup.
a6040a
a6040a
Fixes: a39001d90dbd ("net/qede: fix DMA memory leak")
a6040a
Cc: stable@dpdk.org
a6040a
a6040a
Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
a6040a
Reviewed-by: Kevin Traynor <ktraynor@redhat.com>
a6040a
---
a6040a
 drivers/net/qede/base/bcm_osal.c |  5 +++++
a6040a
 drivers/net/qede/qede_rxtx.c     | 21 +++++++++++----------
a6040a
 2 files changed, 16 insertions(+), 10 deletions(-)
a6040a
a6040a
diff --git a/drivers/net/qede/base/bcm_osal.c b/drivers/net/qede/base/bcm_osal.c
a6040a
index ca1c2b113..72627dfec 100644
a6040a
--- a/drivers/net/qede/base/bcm_osal.c
a6040a
+++ b/drivers/net/qede/base/bcm_osal.c
a6040a
@@ -201,6 +201,11 @@ void osal_dma_free_mem(struct ecore_dev *p_dev, dma_addr_t phys)
a6040a
 			DP_VERBOSE(p_dev, ECORE_MSG_SP,
a6040a
 				"Free memzone %s\n", ecore_mz_mapping[j]->name);
a6040a
 			rte_memzone_free(ecore_mz_mapping[j]);
a6040a
+			while (j < ecore_mz_count - 1) {
a6040a
+				ecore_mz_mapping[j] = ecore_mz_mapping[j + 1];
a6040a
+				j++;
a6040a
+			}
a6040a
+			ecore_mz_count--;
a6040a
 			return;
a6040a
 		}
a6040a
 	}
a6040a
diff --git a/drivers/net/qede/qede_rxtx.c b/drivers/net/qede/qede_rxtx.c
a6040a
index bdb5d6f11..4fa1c615b 100644
a6040a
--- a/drivers/net/qede/qede_rxtx.c
a6040a
+++ b/drivers/net/qede/qede_rxtx.c
a6040a
@@ -192,9 +192,15 @@ static void qede_rx_queue_release_mbufs(struct qede_rx_queue *rxq)
a6040a
 void qede_rx_queue_release(void *rx_queue)
a6040a
 {
a6040a
 	struct qede_rx_queue *rxq = rx_queue;
a6040a
+	struct qede_dev *qdev = rxq->qdev;
a6040a
+	struct ecore_dev *edev = QEDE_INIT_EDEV(qdev);
a6040a
+
a6040a
+	PMD_INIT_FUNC_TRACE(edev);
a6040a
 
a6040a
 	if (rxq) {
a6040a
 		qede_rx_queue_release_mbufs(rxq);
a6040a
+		qdev->ops->common->chain_free(edev, &rxq->rx_bd_ring);
a6040a
+		qdev->ops->common->chain_free(edev, &rxq->rx_comp_ring);
a6040a
 		rte_free(rxq->sw_rx_ring);
a6040a
 		rte_free(rxq);
a6040a
 	}
a6040a
@@ -350,9 +356,14 @@ static void qede_tx_queue_release_mbufs(struct qede_tx_queue *txq)
a6040a
 void qede_tx_queue_release(void *tx_queue)
a6040a
 {
a6040a
 	struct qede_tx_queue *txq = tx_queue;
a6040a
+	struct qede_dev *qdev = txq->qdev;
a6040a
+	struct ecore_dev *edev = QEDE_INIT_EDEV(qdev);
a6040a
+
a6040a
+	PMD_INIT_FUNC_TRACE(edev);
a6040a
 
a6040a
 	if (txq) {
a6040a
 		qede_tx_queue_release_mbufs(txq);
a6040a
+		qdev->ops->common->chain_free(edev, &txq->tx_pbl);
a6040a
 		rte_free(txq->sw_tx_ring);
a6040a
 		rte_free(txq);
a6040a
 	}
a6040a
@@ -441,8 +452,6 @@ void qede_dealloc_fp_resc(struct rte_eth_dev *eth_dev)
a6040a
 	struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev);
a6040a
 	struct ecore_dev *edev = QEDE_INIT_EDEV(qdev);
a6040a
 	struct qede_fastpath *fp;
a6040a
-	struct qede_rx_queue *rxq;
a6040a
-	struct qede_tx_queue *txq;
a6040a
 	uint16_t sb_idx;
a6040a
 	uint8_t i;
a6040a
 
a6040a
@@ -467,21 +476,13 @@ void qede_dealloc_fp_resc(struct rte_eth_dev *eth_dev)
a6040a
 	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
a6040a
 		if (eth_dev->data->rx_queues[i]) {
a6040a
 			qede_rx_queue_release(eth_dev->data->rx_queues[i]);
a6040a
-			rxq = eth_dev->data->rx_queues[i];
a6040a
-			qdev->ops->common->chain_free(edev,
a6040a
-						      &rxq->rx_bd_ring);
a6040a
-			qdev->ops->common->chain_free(edev,
a6040a
-						      &rxq->rx_comp_ring);
a6040a
 			eth_dev->data->rx_queues[i] = NULL;
a6040a
 		}
a6040a
 	}
a6040a
 
a6040a
 	for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
a6040a
 		if (eth_dev->data->tx_queues[i]) {
a6040a
-			txq = eth_dev->data->tx_queues[i];
a6040a
 			qede_tx_queue_release(eth_dev->data->tx_queues[i]);
a6040a
-			qdev->ops->common->chain_free(edev,
a6040a
-						      &txq->tx_pbl);
a6040a
 			eth_dev->data->tx_queues[i] = NULL;
a6040a
 		}
a6040a
 	}
a6040a
-- 
a6040a
2.17.0
a6040a