netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hariprasad Shenai <hariprasad@chelsio.com>
To: netdev@vger.kernel.org, linux-rdma@vger.kernel.org
Cc: davem@davemloft.net, roland@purestorage.com, santosh@chelsio.com,
	dm@chelsio.com, kumaras@chelsio.com, swise@opengridcomputing.com,
	leedom@chelsio.com, nirranjan@chelsio.com,
	hariprasad@chelsio.com
Subject: [PATCHv4 net-next 03/32] cxgb4: Rectify emitting messages about SGE Ingress DMA channels being potentially stuck
Date: Fri,  7 Mar 2014 16:03:00 +0530	[thread overview]
Message-ID: <1394188409-9739-4-git-send-email-hariprasad@chelsio.com> (raw)
In-Reply-To: <1394188409-9739-1-git-send-email-hariprasad@chelsio.com>

From: Kumar Sanghvi <kumaras@chelsio.com>

Based on original work by Casey Leedom <leedom@chelsio.com>

Signed-off-by: Kumar Sanghvi <kumaras@chelsio.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |  9 ++-
 drivers/net/ethernet/chelsio/cxgb4/sge.c   | 90 ++++++++++++++++++++++++------
 2 files changed, 79 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 509c976..50abe1d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -556,8 +556,13 @@ struct sge {
 	u32 pktshift;               /* padding between CPL & packet data */
 	u32 fl_align;               /* response queue message alignment */
 	u32 fl_starve_thres;        /* Free List starvation threshold */
-	unsigned int starve_thres;
-	u8 idma_state[2];
+
+	/* State variables for detecting an SGE Ingress DMA hang */
+	unsigned int idma_1s_thresh;/* SGE same State Counter 1s threshold */
+	unsigned int idma_stalled[2];/* SGE synthesized stalled timers in HZ */
+	unsigned int idma_state[2]; /* SGE IDMA Hang detect state */
+	unsigned int idma_qid[2];   /* SGE IDMA Hung Ingress Queue ID */
+
 	unsigned int egr_start;
 	unsigned int ingr_start;
 	void *egr_map[MAX_EGRQ];    /* qid->queue egress queue map */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 3a2ecd8..054bb03 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -93,6 +93,16 @@
  */
 #define TX_QCHECK_PERIOD (HZ / 2)
 
+/* SGE Hung Ingress DMA Threshold Warning time (in Hz) and Warning Repeat Rate
+ * (in RX_QCHECK_PERIOD multiples).  If we find one of the SGE Ingress DMA
+ * State Machines in the same state for this amount of time (in HZ) then we'll
+ * issue a warning about a potential hang.  We'll repeat the warning as the
+ * SGE Ingress DMA Channel appears to be hung every N RX_QCHECK_PERIODs till
+ * the situation clears.  If the situation clears, we'll note that as well.
+ */
+#define SGE_IDMA_WARN_THRESH (1 * HZ)
+#define SGE_IDMA_WARN_REPEAT (20 * RX_QCHECK_PERIOD)
+
 /*
  * Max number of Tx descriptors to be reclaimed by the Tx timer.
  */
@@ -2008,7 +2018,7 @@ irq_handler_t t4_intr_handler(struct adapter *adap)
 static void sge_rx_timer_cb(unsigned long data)
 {
 	unsigned long m;
-	unsigned int i, cnt[2];
+	unsigned int i, idma_same_state_cnt[2];
 	struct adapter *adap = (struct adapter *)data;
 	struct sge *s = &adap->sge;
 
@@ -2031,21 +2041,64 @@ static void sge_rx_timer_cb(unsigned long data)
 		}
 
 	t4_write_reg(adap, SGE_DEBUG_INDEX, 13);
-	cnt[0] = t4_read_reg(adap, SGE_DEBUG_DATA_HIGH);
-	cnt[1] = t4_read_reg(adap, SGE_DEBUG_DATA_LOW);
-
-	for (i = 0; i < 2; i++)
-		if (cnt[i] >= s->starve_thres) {
-			if (s->idma_state[i] || cnt[i] == 0xffffffff)
-				continue;
-			s->idma_state[i] = 1;
-			t4_write_reg(adap, SGE_DEBUG_INDEX, 11);
-			m = t4_read_reg(adap, SGE_DEBUG_DATA_LOW) >> (i * 16);
-			dev_warn(adap->pdev_dev,
-				 "SGE idma%u starvation detected for "
-				 "queue %lu\n", i, m & 0xffff);
-		} else if (s->idma_state[i])
-			s->idma_state[i] = 0;
+	idma_same_state_cnt[0] = t4_read_reg(adap, SGE_DEBUG_DATA_HIGH);
+	idma_same_state_cnt[1] = t4_read_reg(adap, SGE_DEBUG_DATA_LOW);
+
+	for (i = 0; i < 2; i++) {
+		u32 debug0, debug11;
+
+		/* If the Ingress DMA Same State Counter ("timer") is less
+		 * than 1s, then we can reset our synthesized Stall Timer and
+		 * continue.  If we have previously emitted warnings about a
+		 * potential stalled Ingress Queue, issue a note indicating
+		 * that the Ingress Queue has resumed forward progress.
+		 */
+		if (idma_same_state_cnt[i] < s->idma_1s_thresh) {
+			if (s->idma_stalled[i] >= SGE_IDMA_WARN_THRESH)
+				CH_WARN(adap, "SGE idma%d, queue%u,resumed after %d sec\n",
+					i, s->idma_qid[i],
+					s->idma_stalled[i]/HZ);
+			s->idma_stalled[i] = 0;
+			continue;
+		}
+
+		/* Synthesize an SGE Ingress DMA Same State Timer in the Hz
+		 * domain.  The first time we get here it'll be because we
+		 * passed the 1s Threshold; each additional time it'll be
+		 * because the RX Timer Callback is being fired on its regular
+		 * schedule.
+		 *
+		 * If the stall is below our Potential Hung Ingress Queue
+		 * Warning Threshold, continue.
+		 */
+		if (s->idma_stalled[i] == 0)
+			s->idma_stalled[i] = HZ;
+		else
+			s->idma_stalled[i] += RX_QCHECK_PERIOD;
+
+		if (s->idma_stalled[i] < SGE_IDMA_WARN_THRESH)
+			continue;
+
+		/* We'll issue a warning every SGE_IDMA_WARN_REPEAT Hz */
+		if (((s->idma_stalled[i] - HZ) % SGE_IDMA_WARN_REPEAT) != 0)
+			continue;
+
+		/* Read and save the SGE IDMA State and Queue ID information.
+		 * We do this every time in case it changes across time ...
+		 */
+		t4_write_reg(adap, SGE_DEBUG_INDEX, 0);
+		debug0 = t4_read_reg(adap, SGE_DEBUG_DATA_LOW);
+		s->idma_state[i] = (debug0 >> (i * 9)) & 0x3f;
+
+		t4_write_reg(adap, SGE_DEBUG_INDEX, 11);
+		debug11 = t4_read_reg(adap, SGE_DEBUG_DATA_LOW);
+		s->idma_qid[i] = (debug11 >> (i * 16)) & 0xffff;
+
+		CH_WARN(adap, "SGE idma%u, queue%u, maybe stuck state%u %dsecs (debug0=%#x, debug11=%#x)\n",
+			i, s->idma_qid[i], s->idma_state[i],
+			s->idma_stalled[i]/HZ, debug0, debug11);
+		t4_sge_decode_idma_state(adap, s->idma_state[i]);
+	}
 
 	mod_timer(&s->rx_timer, jiffies + RX_QCHECK_PERIOD);
 }
@@ -2756,8 +2809,9 @@ int t4_sge_init(struct adapter *adap)
 
 	setup_timer(&s->rx_timer, sge_rx_timer_cb, (unsigned long)adap);
 	setup_timer(&s->tx_timer, sge_tx_timer_cb, (unsigned long)adap);
-	s->starve_thres = core_ticks_per_usec(adap) * 1000000;  /* 1 s */
-	s->idma_state[0] = s->idma_state[1] = 0;
+	s->idma_1s_thresh = core_ticks_per_usec(adap) * 1000000;  /* 1 s */
+	s->idma_stalled[0] = 0;
+	s->idma_stalled[1] = 0;
 	spin_lock_init(&s->intrq_lock);
 
 	return 0;
-- 
1.8.4

  parent reply	other threads:[~2014-03-07 10:41 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-07 10:32 [PATCHv4 net-next 00/32] Misc. fixes for cxgb4 and iw_cxgb4 Hariprasad Shenai
2014-03-07 10:32 ` [PATCHv4 net-next 01/32] cxgb4: Fix some small bugs in t4_sge_init_soft() when our Page Size is 64KB Hariprasad Shenai
2014-03-07 10:32 ` [PATCHv4 net-next 02/32] cxgb4: Add code to dump SGE registers when hitting idma hangs Hariprasad Shenai
2014-03-07 10:33 ` Hariprasad Shenai [this message]
2014-03-07 10:33 ` [PATCHv4 net-next 04/32] cxgb4: Updates for T5 SGE's Egress Congestion Threshold Hariprasad Shenai
     [not found] ` <1394188409-9739-1-git-send-email-hariprasad-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
2014-03-07 10:33   ` [PATCHv4 net-next 05/32] cxgb4: use spinlock_irqsave/spinlock_irqrestore for db lock Hariprasad Shenai
     [not found]     ` <1394188409-9739-6-git-send-email-hariprasad-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
2014-03-08  5:43       ` David Miller
2014-03-07 10:33   ` [PATCHv4 net-next 11/32] cxgb4/iw_cxgb4: Doorbell Drop Avoidance Bug Fixes Hariprasad Shenai
2014-03-07 10:33   ` [PATCHv4 net-next 16/32] iw_cxgb4: save the correct map length for fast_reg_page_lists Hariprasad Shenai
2014-03-07 10:33   ` [PATCHv4 net-next 26/32] iw_cxgb4: endpoint timeout fixes Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 06/32] cxgb4: Calculate len properly for LSO path Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 07/32] iw_cxgb4: cap CQ size at T4_MAX_IQ_SIZE Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 08/32] iw_cxgb4: Allow loopback connections Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 09/32] iw_cxgb4: release neigh entry in error paths Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 10/32] iw_cxgb4: Treat CPL_ERR_KEEPALV_NEG_ADVICE as negative advice Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 12/32] iw_cxgb4: use the BAR2/WC path for kernel QPs and T5 devices Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 13/32] iw_cxgb4: Fix incorrect BUG_ON conditions Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 14/32] iw_cxgb4: Mind the sq_sig_all/sq_sig_type QP attributes Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 15/32] iw_cxgb4: default peer2peer mode to 1 Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 17/32] iw_cxgb4: don't leak skb in c4iw_uld_rx_handler() Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 18/32] iw_cxgb4: fix possible memory leak in RX_PKT processing Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 19/32] iw_cxgb4: ignore read reponse type 1 CQEs Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 20/32] iw_cxgb4: connect_request_upcall fixes Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 21/32] iw_cxgb4: adjust tcp snd/rcv window based on link speed Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 22/32] iw_cxgb4: update snd_seq when sending MPA messages Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 23/32] iw_cxgb4: lock around accept/reject downcalls Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 24/32] iw_cxgb4: drop RX_DATA packets if the endpoint is gone Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 25/32] iw_cxgb4: rx_data() needs to hold the ep mutex Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 27/32] iw_cxgb4: rmb() after reading valid gen bit Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 28/32] iw_cxgb4: wc_wmb() needed after DB writes Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 29/32] iw_cxgb4: SQ flush fix Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 30/32] iw_cxgb4: minor fixes Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 31/32] iw_cxgb4: Max fastreg depth depends on DSGL support Hariprasad Shenai
2014-03-07 10:33 ` [PATCHv4 net-next 32/32] iw_cxgb4: Use pr_warn_ratelimited Hariprasad Shenai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1394188409-9739-4-git-send-email-hariprasad@chelsio.com \
    --to=hariprasad@chelsio.com \
    --cc=davem@davemloft.net \
    --cc=dm@chelsio.com \
    --cc=kumaras@chelsio.com \
    --cc=leedom@chelsio.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nirranjan@chelsio.com \
    --cc=roland@purestorage.com \
    --cc=santosh@chelsio.com \
    --cc=swise@opengridcomputing.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).