From 0999d1b412ea9a95e44e6167149784821d95ddaa Mon Sep 17 00:00:00 2001
From: Vignesh Raghavendra <vigneshr@ti.com>
Date: Mon, 21 Jun 2021 15:47:49 +0530
Subject: [PATCH] net: ti: icssg_prueth: Free desc pool before DMA channel
 release

Release DMA desc pool associated with channel before releasing the
channel itself as the pool is associated with channel's struct device

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
---
 drivers/net/ethernet/ti/icssg_prueth.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/ti/icssg_prueth.c b/drivers/net/ethernet/ti/icssg_prueth.c
index ef7392a2b9da..38d151dca81c 100644
--- a/drivers/net/ethernet/ti/icssg_prueth.c
+++ b/drivers/net/ethernet/ti/icssg_prueth.c
@@ -69,11 +69,11 @@ static void prueth_cleanup_rx_chns(struct prueth_emac *emac,
 				   struct prueth_rx_chn *rx_chn,
 				   int max_rflows)
 {
-	if (rx_chn->rx_chn)
-		k3_udma_glue_release_rx_chn(rx_chn->rx_chn);
-
 	if (rx_chn->desc_pool)
 		k3_cppi_desc_pool_destroy(rx_chn->desc_pool);
+
+	if (rx_chn->rx_chn)
+		k3_udma_glue_release_rx_chn(rx_chn->rx_chn);
 }
 
 static void prueth_cleanup_tx_chns(struct prueth_emac *emac)
@@ -83,12 +83,12 @@ static void prueth_cleanup_tx_chns(struct prueth_emac *emac)
 	for (i = 0; i < emac->tx_ch_num; i++) {
 		struct prueth_tx_chn *tx_chn = &emac->tx_chns[i];
 
-		if (tx_chn->tx_chn)
-			k3_udma_glue_release_tx_chn(tx_chn->tx_chn);
-
 		if (tx_chn->desc_pool)
 			k3_cppi_desc_pool_destroy(tx_chn->desc_pool);
 
+		if (tx_chn->tx_chn)
+			k3_udma_glue_release_tx_chn(tx_chn->tx_chn);
+
 		/* Assume prueth_cleanup_tx_chns() is called at the
 		 * end after all channel resources are freed
 		 */
