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

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