netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael Chan" <mchan@broadcom.com>
To: "Josip Rodin" <joy@entuzijast.net>
Cc: "Ben Hutchings" <bhutchings@solarflare.com>,
	netdev <netdev@vger.kernel.org>,
	mirrors@debian.org
Subject: Re: bnx2_poll panicking kernel
Date: Mon, 16 Jun 2008 16:45:08 -0700	[thread overview]
Message-ID: <1213659908.18055.26.camel@dell> (raw)
In-Reply-To: <20080616214829.GA9334@orion.carnet.hr>

On Mon, 2008-06-16 at 23:48 +0200, Josip Rodin wrote:
> > Crap, it just crashed again, with 2.6.25.6.

Looking at the panic dmesg, I believe it was crashing because skb was
NULL in bnx2_tx_int().

> 
> I should mention that I might have a clue - around the time the crashes
> started, I started using HTB with the following configuration:

This rings a bell.  A similar crash was reported by a user using HTB on
a tg3 device.  After some analysis, my suspicion was that the shinfo
(skb)->nr_frags on the TX packet was corrupted before the SKB was freed
by the driver.  In both the tg3 and bnx2 drivers, we rely on the
nr_frags to locate the TX packet boundaries on the ring to free the
packets.

Please try this debug patch below.  If the theory is correct, the patch
should avoid the crash and will print something to the dmesg log every
time a crash is avoided.  Please run it again with the HTB rules and
send me the dmesg log containing:

bnx2: skb->nr_frags ...

Here's the debug patch below.  It saves the nr_frags from the SKB and
uses it to locate the packet boundaries instead.  It will also compare
the saved value with the one in SKB and print a warning when they don't
match.  Please apply to 2.6.25.6.

diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 4b46e68..f7ecd07 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -2495,14 +2495,20 @@ bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
 		tx_buf = &bp->tx_buf_ring[sw_ring_cons];
 		skb = tx_buf->skb;
 
+		if (tx_buf->nr_frags != skb_shinfo(skb)->nr_frags) {
+			printk(KERN_ALERT "bnx2: skb->nr_frags=%d is corrupted,"
+					  " should be %d\n",
+					  skb_shinfo(skb)->nr_frags,
+					  tx_buf->nr_frags);
+		}
 		/* partial BD completions possible with TSO packets */
 		if (skb_is_gso(skb)) {
 			u16 last_idx, last_ring_idx;
 
 			last_idx = sw_cons +
-				skb_shinfo(skb)->nr_frags + 1;
+				tx_buf->nr_frags + 1;
 			last_ring_idx = sw_ring_cons +
-				skb_shinfo(skb)->nr_frags + 1;
+				tx_buf->nr_frags + 1;
 			if (unlikely(last_ring_idx >= MAX_TX_DESC_CNT)) {
 				last_idx++;
 			}
@@ -2515,7 +2521,7 @@ bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
 			skb_headlen(skb), PCI_DMA_TODEVICE);
 
 		tx_buf->skb = NULL;
-		last = skb_shinfo(skb)->nr_frags;
+		last = tx_buf->nr_frags;
 
 		for (i = 0; i < last; i++) {
 			sw_cons = NEXT_TX_BD(sw_cons);
@@ -4806,7 +4812,7 @@ bnx2_free_tx_skbs(struct bnx2 *bp)
 
 		tx_buf->skb = NULL;
 
-		last = skb_shinfo(skb)->nr_frags;
+		last = tx_buf->nr_frags;
 		for (j = 0; j < last; j++) {
 			tx_buf = &bp->tx_buf_ring[i + j + 1];
 			pci_unmap_page(bp->pdev,
@@ -5859,6 +5865,8 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	last_frag = skb_shinfo(skb)->nr_frags;
 
+	tx_buf->nr_frags = last_frag;
+
 	for (i = 0; i < last_frag; i++) {
 		skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
 
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index 1eaf5bb..aa9fa6f 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -6485,6 +6485,7 @@ struct l2_fhdr {
 struct sw_bd {
 	struct sk_buff		*skb;
 	DECLARE_PCI_UNMAP_ADDR(mapping)
+	unsigned short		nr_frags;
 };
 
 struct sw_pg {



  reply	other threads:[~2008-06-16 23:43 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-16 12:57 bnx2_poll panicking kernel Josip Rodin
2008-06-16 14:04 ` Ben Hutchings
2008-06-16 15:52   ` Michael Chan
2008-06-16 19:13     ` Josip Rodin
2008-06-16 21:38       ` Josip Rodin
2008-06-16 21:48         ` Josip Rodin
2008-06-16 23:45           ` Michael Chan [this message]
2008-06-17 22:37             ` Josip Rodin
2008-06-17 22:47               ` Michael Chan
2008-06-21 11:18                 ` Josip Rodin
2008-06-21 15:34                   ` Bill Fink
2008-06-21 16:11                     ` Michael Chan
2008-06-23 18:04                       ` Josip Rodin
2008-06-23 21:36                         ` Josip Rodin
2008-06-23 22:48                           ` Michael Chan
2008-06-24 22:58                             ` Michael Chan
2008-06-25  0:04                               ` David Miller
2008-06-26 11:01                               ` Josip Rodin
2008-06-26 18:04                                 ` Michael Chan
2008-07-09 16:46                                   ` Josip Rodin
2008-07-09 16:57                                     ` Michael Chan
2008-07-09 23:46                                       ` David Miller
2008-07-10  9:45                                         ` Aviv Greenberg
2008-07-10 10:09                                           ` David Miller
2008-07-10 21:00                                         ` Michael Chan
2008-07-10 21:00                                           ` David Miller
2008-07-10 21:23                                           ` Josip Rodin
2008-07-10 21:38                                             ` Michael Chan
2008-07-10 22:00                                               ` Josip Rodin
2008-07-10 22:26                                                 ` Michael Chan
2008-07-10 22:31                                                   ` Josip Rodin
2008-07-10 23:20                                                     ` David Miller
2008-07-11  9:24                                                       ` Josip Rodin
2008-07-11  9:56                                                         ` David Miller
2008-07-11 12:19                                                           ` Patrick McHardy
2008-07-12  9:49                                                           ` Jarek Poplawski
2008-07-12 13:21                                                             ` Jarek Poplawski
2008-07-14 15:27                                                               ` Patrick McHardy
2008-07-14 17:20                                                                 ` Jarek Poplawski
2008-07-14 17:25                                                                   ` Jarek Poplawski
2008-07-14 20:21                                                                   ` Josip Rodin
2008-07-14 21:22                                                                     ` Jarek Poplawski
2008-07-14 21:26                                                                       ` Josip Rodin
2008-07-14 21:48                                                                         ` Jarek Poplawski
2008-07-17 21:30                                                                           ` Josip Rodin
2008-07-17 21:44                                                                             ` David Miller
2008-07-18  5:12                                                                               ` Jarek Poplawski
2008-08-02 12:28                                                                               ` bad htb_{en,re}queue return codes causing corrupt data in drivers [was Re: bnx2_poll panicking kernel] Josip Rodin
2008-08-03  7:06                                                                                 ` bad htb_{en,re}queue return codes causing corrupt data in drivers David Miller
2008-07-14 22:05                                                                         ` bnx2_poll panicking kernel Jarek Poplawski

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=1213659908.18055.26.camel@dell \
    --to=mchan@broadcom.com \
    --cc=bhutchings@solarflare.com \
    --cc=joy@entuzijast.net \
    --cc=mirrors@debian.org \
    --cc=netdev@vger.kernel.org \
    /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).