Michal Suchanek a97f40
From 1c7d45e7b2c29080bf6c8cd0e213cc3cbb62a054 Mon Sep 17 00:00:00 2001
Michal Suchanek a97f40
From: Lijun Pan <ljp@linux.ibm.com>
Michal Suchanek a97f40
Date: Fri, 12 Feb 2021 20:36:10 -0600
Michal Suchanek a97f40
Subject: [PATCH] ibmvnic: simplify reset_long_term_buff function
Michal Suchanek a97f40
Michal Suchanek a97f40
References: bsc#1184114 ltc#192237 bsc#1183023 ltc#191791
Michal Suchanek a97f40
Patch-mainline: v5.12-rc1
Michal Suchanek a97f40
Git-commit: 1c7d45e7b2c29080bf6c8cd0e213cc3cbb62a054
Michal Suchanek a97f40
Michal Suchanek a97f40
The only thing reset_long_term_buff() should do is set
Michal Suchanek a97f40
buffer to zero. After doing that, it is not necessary to
Michal Suchanek a97f40
send_request_map again to VIOS since it actually does not
Michal Suchanek a97f40
change the mapping. So, keep memset function and remove all
Michal Suchanek a97f40
others.
Michal Suchanek a97f40
Michal Suchanek a97f40
Signed-off-by: Lijun Pan <ljp@linux.ibm.com>
Michal Suchanek a97f40
Signed-off-by: David S. Miller <davem@davemloft.net>
Michal Suchanek a97f40
Acked-by: Michal Suchanek <msuchanek@suse.de>
Michal Suchanek a97f40
---
Michal Suchanek a97f40
 drivers/net/ethernet/ibm/ibmvnic.c | 46 ++++++------------------------
Michal Suchanek a97f40
 1 file changed, 8 insertions(+), 38 deletions(-)
Michal Suchanek a97f40
Michal Suchanek a97f40
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
Michal Suchanek a97f40
index 1774fbaab146..7a5e589e7223 100644
Michal Suchanek a97f40
--- a/drivers/net/ethernet/ibm/ibmvnic.c
Michal Suchanek a97f40
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
Michal Suchanek a97f40
@@ -253,40 +253,12 @@ static void free_long_term_buff(struct ibmvnic_adapter *adapter,
Michal Suchanek a97f40
 	dma_free_coherent(dev, ltb->size, ltb->buff, ltb->addr);
Michal Suchanek a97f40
 }
Michal Suchanek a97f40
 
Michal Suchanek a97f40
-static int reset_long_term_buff(struct ibmvnic_adapter *adapter,
Michal Suchanek a97f40
-				struct ibmvnic_long_term_buff *ltb)
Michal Suchanek a97f40
+static int reset_long_term_buff(struct ibmvnic_long_term_buff *ltb)
Michal Suchanek a97f40
 {
Michal Suchanek a97f40
-	struct device *dev = &adapter->vdev->dev;
Michal Suchanek a97f40
-	int rc;
Michal Suchanek a97f40
+	if (!ltb->buff)
Michal Suchanek a97f40
+		return -EINVAL;
Michal Suchanek a97f40
 
Michal Suchanek a97f40
 	memset(ltb->buff, 0, ltb->size);
Michal Suchanek a97f40
-
Michal Suchanek a97f40
-	mutex_lock(&adapter->fw_lock);
Michal Suchanek a97f40
-	adapter->fw_done_rc = 0;
Michal Suchanek a97f40
-
Michal Suchanek a97f40
-	reinit_completion(&adapter->fw_done);
Michal Suchanek a97f40
-	rc = send_request_map(adapter, ltb->addr, ltb->size, ltb->map_id);
Michal Suchanek a97f40
-	if (rc) {
Michal Suchanek a97f40
-		mutex_unlock(&adapter->fw_lock);
Michal Suchanek a97f40
-		return rc;
Michal Suchanek a97f40
-	}
Michal Suchanek a97f40
-
Michal Suchanek a97f40
-	rc = ibmvnic_wait_for_completion(adapter, &adapter->fw_done, 10000);
Michal Suchanek a97f40
-	if (rc) {
Michal Suchanek a97f40
-		dev_info(dev,
Michal Suchanek a97f40
-			 "Reset failed, long term map request timed out or aborted\n");
Michal Suchanek a97f40
-		mutex_unlock(&adapter->fw_lock);
Michal Suchanek a97f40
-		return rc;
Michal Suchanek a97f40
-	}
Michal Suchanek a97f40
-
Michal Suchanek a97f40
-	if (adapter->fw_done_rc) {
Michal Suchanek a97f40
-		dev_info(dev,
Michal Suchanek a97f40
-			 "Reset failed, attempting to free and reallocate buffer\n");
Michal Suchanek a97f40
-		free_long_term_buff(adapter, ltb);
Michal Suchanek a97f40
-		mutex_unlock(&adapter->fw_lock);
Michal Suchanek a97f40
-		return alloc_long_term_buff(adapter, ltb, ltb->size);
Michal Suchanek a97f40
-	}
Michal Suchanek a97f40
-	mutex_unlock(&adapter->fw_lock);
Michal Suchanek a97f40
 	return 0;
Michal Suchanek a97f40
 }
Michal Suchanek a97f40
 
Michal Suchanek a97f40
@@ -508,8 +480,7 @@ static int reset_rx_pools(struct ibmvnic_adapter *adapter)
Michal Suchanek a97f40
 						  rx_pool->size *
Michal Suchanek a97f40
 						  rx_pool->buff_size);
Michal Suchanek a97f40
 		} else {
Michal Suchanek a97f40
-			rc = reset_long_term_buff(adapter,
Michal Suchanek a97f40
-						  &rx_pool->long_term_buff);
Michal Suchanek a97f40
+			rc = reset_long_term_buff(&rx_pool->long_term_buff);
Michal Suchanek a97f40
 		}
Michal Suchanek a97f40
 
Michal Suchanek a97f40
 		if (rc)
Michal Suchanek a97f40
@@ -632,12 +603,11 @@ static int init_rx_pools(struct net_device *netdev)
Michal Suchanek a97f40
 	return 0;
Michal Suchanek a97f40
 }
Michal Suchanek a97f40
 
Michal Suchanek a97f40
-static int reset_one_tx_pool(struct ibmvnic_adapter *adapter,
Michal Suchanek a97f40
-			     struct ibmvnic_tx_pool *tx_pool)
Michal Suchanek a97f40
+static int reset_one_tx_pool(struct ibmvnic_tx_pool *tx_pool)
Michal Suchanek a97f40
 {
Michal Suchanek a97f40
 	int rc, i;
Michal Suchanek a97f40
 
Michal Suchanek a97f40
-	rc = reset_long_term_buff(adapter, &tx_pool->long_term_buff);
Michal Suchanek a97f40
+	rc = reset_long_term_buff(&tx_pool->long_term_buff);
Michal Suchanek a97f40
 	if (rc)
Michal Suchanek a97f40
 		return rc;
Michal Suchanek a97f40
 
Michal Suchanek a97f40
@@ -664,10 +634,10 @@ static int reset_tx_pools(struct ibmvnic_adapter *adapter)
Michal Suchanek a97f40
 
Michal Suchanek a97f40
 	tx_scrqs = adapter->num_active_tx_pools;
Michal Suchanek a97f40
 	for (i = 0; i < tx_scrqs; i++) {
Michal Suchanek a97f40
-		rc = reset_one_tx_pool(adapter, &adapter->tso_pool[i]);
Michal Suchanek a97f40
+		rc = reset_one_tx_pool(&adapter->tso_pool[i]);
Michal Suchanek a97f40
 		if (rc)
Michal Suchanek a97f40
 			return rc;
Michal Suchanek a97f40
-		rc = reset_one_tx_pool(adapter, &adapter->tx_pool[i]);
Michal Suchanek a97f40
+		rc = reset_one_tx_pool(&adapter->tx_pool[i]);
Michal Suchanek a97f40
 		if (rc)
Michal Suchanek a97f40
 			return rc;
Michal Suchanek a97f40
 	}
Michal Suchanek a97f40
-- 
Michal Suchanek a97f40
2.26.2
Michal Suchanek a97f40