Blame SOURCES/0004-Revert-netdrv-ice-Removing-hung_queue-variable-to-us.patch

2eb987
From 76a64685e812d8f1de840773358c2ce821ecb370 Mon Sep 17 00:00:00 2001
2eb987
From: Eugene Syromiatnikov <esyr@redhat.com>
2eb987
Date: Thu, 27 Aug 2020 19:10:02 +0200
2eb987
Subject: [PATCH 4/5] Revert "[netdrv] ice: Removing hung_queue variable to use
2eb987
 txqueue function parameter"
2eb987
2eb987
This reverts commit 669e50a2e214aea57e159e9af04196e32dfb2856.
2eb987
---
2eb987
 drivers/net/ethernet/intel/ice/ice_main.c | 41 ++++++++++++++++++++++---------
2eb987
 1 file changed, 30 insertions(+), 11 deletions(-)
2eb987
2eb987
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
2eb987
index 4853a1e0632c..ed66596ba75d 100644
2eb987
--- a/drivers/net/ethernet/intel/ice/ice_main.c
2eb987
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
2eb987
@@ -5447,17 +5447,36 @@ static void ice_tx_timeout(struct net_device *netdev, unsigned int txqueue)
2eb987
 	struct ice_ring *tx_ring = NULL;
2eb987
 	struct ice_vsi *vsi = np->vsi;
2eb987
 	struct ice_pf *pf = vsi->back;
2eb987
+	int hung_queue = -1;
2eb987
 	u32 i;
2eb987
 
2eb987
 	pf->tx_timeout_count++;
2eb987
 
2eb987
-	/* now that we have an index, find the tx_ring struct */
2eb987
-	for (i = 0; i < vsi->num_txq; i++)
2eb987
-		if (vsi->tx_rings[i] && vsi->tx_rings[i]->desc)
2eb987
-			if (txqueue == vsi->tx_rings[i]->q_index) {
2eb987
-				tx_ring = vsi->tx_rings[i];
2eb987
-				break;
2eb987
-			}
2eb987
+	/* find the stopped queue the same way dev_watchdog() does */
2eb987
+	for (i = 0; i < netdev->num_tx_queues; i++) {
2eb987
+		unsigned long trans_start;
2eb987
+		struct netdev_queue *q;
2eb987
+
2eb987
+		q = netdev_get_tx_queue(netdev, i);
2eb987
+		trans_start = q->trans_start;
2eb987
+		if (netif_xmit_stopped(q) &&
2eb987
+		    time_after(jiffies,
2eb987
+			       trans_start + netdev->watchdog_timeo)) {
2eb987
+			hung_queue = i;
2eb987
+			break;
2eb987
+		}
2eb987
+	}
2eb987
+
2eb987
+	if (i == netdev->num_tx_queues)
2eb987
+		netdev_info(netdev, "tx_timeout: no netdev hung queue found\n");
2eb987
+	else
2eb987
+		/* now that we have an index, find the tx_ring struct */
2eb987
+		for (i = 0; i < vsi->num_txq; i++)
2eb987
+			if (vsi->tx_rings[i] && vsi->tx_rings[i]->desc)
2eb987
+				if (hung_queue == vsi->tx_rings[i]->q_index) {
2eb987
+					tx_ring = vsi->tx_rings[i];
2eb987
+					break;
2eb987
+				}
2eb987
 
2eb987
 	/* Reset recovery level if enough time has elapsed after last timeout.
2eb987
 	 * Also ensure no new reset action happens before next timeout period.
2eb987
@@ -5472,19 +5491,19 @@ static void ice_tx_timeout(struct net_device *netdev, unsigned int txqueue)
2eb987
 		struct ice_hw *hw = &pf->hw;
2eb987
 		u32 head, val = 0;
2eb987
 
2eb987
-		head = (rd32(hw, QTX_COMM_HEAD(vsi->txq_map[txqueue])) &
2eb987
+		head = (rd32(hw, QTX_COMM_HEAD(vsi->txq_map[hung_queue])) &
2eb987
 			QTX_COMM_HEAD_HEAD_M) >> QTX_COMM_HEAD_HEAD_S;
2eb987
 		/* Read interrupt register */
2eb987
 		val = rd32(hw, GLINT_DYN_CTL(tx_ring->q_vector->reg_idx));
2eb987
 
2eb987
 		netdev_info(netdev, "tx_timeout: VSI_num: %d, Q %d, NTC: 0x%x, HW_HEAD: 0x%x, NTU: 0x%x, INT: 0x%x\n",
2eb987
-			    vsi->vsi_num, txqueue, tx_ring->next_to_clean,
2eb987
+			    vsi->vsi_num, hung_queue, tx_ring->next_to_clean,
2eb987
 			    head, tx_ring->next_to_use, val);
2eb987
 	}
2eb987
 
2eb987
 	pf->tx_timeout_last_recovery = jiffies;
2eb987
-	netdev_info(netdev, "tx_timeout recovery level %d, txqueue %d\n",
2eb987
-		    pf->tx_timeout_recovery_level, txqueue);
2eb987
+	netdev_info(netdev, "tx_timeout recovery level %d, hung_queue %d\n",
2eb987
+		    pf->tx_timeout_recovery_level, hung_queue);
2eb987
 
2eb987
 	switch (pf->tx_timeout_recovery_level) {
2eb987
 	case 1:
2eb987
-- 
2eb987
2.13.6
2eb987