Netdev List
 help / color / mirror / Atom feed
From: "Gerard Kam" <gerardk5@verizon.net>
To: "'Haavard Skinnemoen'" <haavard.skinnemoen@atmel.com>,
	<netdev@vger.kernel.org>
Cc: "'Nicolas Ferre'" <nicolas.ferre@atmel.com>,
	"'Erik Waling'" <erik.waling@konftel.com>
Subject: RE: [PATCH 2/2] macb: process the RX ring regardless of interrupt status
Date: Thu, 16 Apr 2009 11:41:57 -0700	[thread overview]
Message-ID: <4C1740923F034ABB8BFCC03E69B8E3AC@hobbes> (raw)
In-Reply-To: <1239874331-9431-2-git-send-email-haavard.skinnemoen@atmel.com>

Hi there

> From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org]
> Sent: Thursday, April 16, 2009 2:32 AM

> Fix this by scanning the ring no matter what flags are set in the
> interrupt status register.

I've been using a similar patch to macb, however, it's to fix an issue with
rotting packets.  I'm using kernel 2.6.25, and haven't updated this patch to
a more recent kernel version.  Patch was developed with input from Travis
Stratman, tstratman@emacinc.com.


Fix for RX rotting packets.

diff -pruN a/drivers/net/macb.c b/drivers/net/macb.c
--- a/drivers/net/macb.c	2008-05-18 22:21:53.000000000 -0700
+++ b/drivers/net/macb.c	2008-08-28 11:36:42.000000000 -0700
@@ -508,40 +508,29 @@ static int macb_poll(struct napi_struct 
 	u32 status;
 
 	status = macb_readl(bp, RSR);
-	macb_writel(bp, RSR, status);
-
-	work_done = 0;
-	if (!status) {
-		/*
-		 * This may happen if an interrupt was pending before
-		 * this function was called last time, and no packets
-		 * have been received since.
-		 */
-		netif_rx_complete(dev, napi);
-		goto out;
-	}
+	macb_writel(bp, RSR, status);	/* not atomic read-clear! */
 
 	dev_dbg(&bp->pdev->dev, "poll: status = %08lx, budget = %d\n",
 		(unsigned long)status, budget);
 
-	if (!(status & MACB_BIT(REC))) {
-		dev_warn(&bp->pdev->dev,
-			 "No RX buffers complete, status = %02lx\n",
-			 (unsigned long)status);
-		netif_rx_complete(dev, napi);
-		goto out;
-	}
-
 	work_done = macb_rx(bp, budget);
-	if (work_done < budget)
+	if ((work_done < budget) && !macb_readl(bp, RSR)) {
+		/*
+		 * We've done what we can to clean the buffers.
+		 * Make sure there's no new RX activity during transition
+		 * from poll mode back to interrupt mode.
+		 */
 		netif_rx_complete(dev, napi);
-
-	/*
-	 * We've done what we can to clean the buffers. Make sure we
-	 * get notified when new packets arrive.
-	 */
-out:
-	macb_writel(bp, IER, MACB_RX_INT_FLAGS);
+		macb_writel(bp, IER, MACB_RX_INT_FLAGS);
+		status = macb_readl(bp, RSR);
+		if (status) {
+			/* new RX, undo the polling-done operations */
+			macb_writel(bp, IDR, MACB_RX_INT_FLAGS);
+			netif_rx_reschedule(dev, napi);
+			dev_dbg(&bp->pdev->dev, "poll: undo status =
%08lx\n",
+				(unsigned long)status);
+		}
+	}
 
 	/* TODO: Handle errors */
 
@@ -554,7 +543,7 @@ static irqreturn_t macb_interrupt(int ir
 	struct macb *bp = netdev_priv(dev);
 	u32 status;
 
-	status = macb_readl(bp, ISR);
+	status = macb_readl(bp, ISR) & ~macb_readl(bp, IMR);
 
 	if (unlikely(!status))
 		return IRQ_NONE;
@@ -578,7 +567,9 @@ static irqreturn_t macb_interrupt(int ir
 				dev_dbg(&bp->pdev->dev,
 					"scheduling RX softirq\n");
 				__netif_rx_schedule(dev, &bp->napi);
-			}
+			} else
+				printk(KERN_ERR "%s: sched RX poll
failed\n",
+					dev->name);
 		}
 
 		if (status & (MACB_BIT(TCOMP) | MACB_BIT(ISR_TUND)))
@@ -598,7 +589,7 @@ static irqreturn_t macb_interrupt(int ir
 			       dev->name);
 		}
 
-		status = macb_readl(bp, ISR);
+		status = macb_readl(bp, ISR) & ~macb_readl(bp, IMR);
 	}
 
 	spin_unlock(&bp->lock);
--



 


  reply	other threads:[~2009-04-16 18:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-16  9:32 [PATCH 1/2] macb: Handle Retry Limit Exceeded errors Haavard Skinnemoen
2009-04-16  9:32 ` [PATCH 2/2] macb: process the RX ring regardless of interrupt status Haavard Skinnemoen
2009-04-16 18:41   ` Gerard Kam [this message]
2009-04-17  8:31   ` David Miller
2009-04-17  8:30 ` [PATCH 1/2] macb: Handle Retry Limit Exceeded errors David Miller

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=4C1740923F034ABB8BFCC03E69B8E3AC@hobbes \
    --to=gerardk5@verizon.net \
    --cc=erik.waling@konftel.com \
    --cc=haavard.skinnemoen@atmel.com \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@atmel.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