netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] tg3: Avoid panic from reserved statblk field access
@ 2012-04-24 23:37 Matt Carlson
  2012-04-25 18:42 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Carlson @ 2012-04-24 23:37 UTC (permalink / raw)
  To: davem; +Cc: netdev, mcarlson, mchan

When RSS is enabled, interrupt vector 0 does not receive any rx traffic.
The rx producer index fields for vector 0's status block should be
considered reserved in this case.  This patch changes the code to
respect these reserved fields, which avoids a kernel panic when these
fields take on non-zero values.

Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/ethernet/broadcom/tg3.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 062ac33..ceeab8e 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -879,8 +879,13 @@ static inline unsigned int tg3_has_work(struct tg3_napi *tnapi)
 		if (sblk->status & SD_STATUS_LINK_CHG)
 			work_exists = 1;
 	}
-	/* check for RX/TX work to do */
-	if (sblk->idx[0].tx_consumer != tnapi->tx_cons ||
+
+	/* check for TX work to do */
+	if (sblk->idx[0].tx_consumer != tnapi->tx_cons)
+		work_exists = 1;
+
+	/* check for RX work to do */
+	if (tnapi->rx_rcb_prod_idx &&
 	    *(tnapi->rx_rcb_prod_idx) != tnapi->rx_rcb_ptr)
 		work_exists = 1;
 
@@ -6124,6 +6129,9 @@ static int tg3_poll_work(struct tg3_napi *tnapi, int work_done, int budget)
 			return work_done;
 	}
 
+	if (!tnapi->rx_rcb_prod_idx)
+		return work_done;
+
 	/* run RX thread, within the bounds set by NAPI.
 	 * All RX "locking" is done by ensuring outside
 	 * code synchronizes with tg3->napi.poll()
@@ -7567,6 +7575,12 @@ static int tg3_alloc_consistent(struct tg3 *tp)
 		 */
 		switch (i) {
 		default:
+			if (tg3_flag(tp, ENABLE_RSS)) {
+				tnapi->rx_rcb_prod_idx = NULL;
+				break;
+			}
+			/* Fall through */
+		case 1:
 			tnapi->rx_rcb_prod_idx = &sblk->idx[0].rx_producer;
 			break;
 		case 2:
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] tg3: Avoid panic from reserved statblk field access
  2012-04-24 23:37 [PATCH net] tg3: Avoid panic from reserved statblk field access Matt Carlson
@ 2012-04-25 18:42 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-04-25 18:42 UTC (permalink / raw)
  To: mcarlson; +Cc: netdev, mchan

From: "Matt Carlson" <mcarlson@broadcom.com>
Date: Tue, 24 Apr 2012 16:37:01 -0700

> When RSS is enabled, interrupt vector 0 does not receive any rx traffic.
> The rx producer index fields for vector 0's status block should be
> considered reserved in this case.  This patch changes the code to
> respect these reserved fields, which avoids a kernel panic when these
> fields take on non-zero values.
> 
> Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
> Signed-off-by: Michael Chan <mchan@broadcom.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-25 18:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-24 23:37 [PATCH net] tg3: Avoid panic from reserved statblk field access Matt Carlson
2012-04-25 18:42 ` David Miller

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).