All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Chemparathy <cyril@ti.com>
To: netdev@vger.kernel.org,
	davinci-linux-open-source@linux.davincidsp.com,
	linux-omap@vger.kernel.org
Cc: michael.williamson@criticallink.com, caglarakyuz@gmail.com,
	bparrot@ti.com, Cyril Chemparathy <cyril@ti.com>
Subject: [PATCH 4/9] net: davinci_emac: fix rx error handling
Date: Mon, 13 Sep 2010 14:07:26 -0400	[thread overview]
Message-ID: <1284401251-8846-5-git-send-email-cyril@ti.com> (raw)
In-Reply-To: <1284401251-8846-1-git-send-email-cyril@ti.com>

This patch adds the following fixes to the emac receive handler:

1. WARN_ON during interface shutdown.
   Although harmless, these complaints were quite disconcerting.  With this
   patch, the receive handler explicitly checks for the shutdown condition, in
   which case is bails quietly.

2. Update rx_error stats on dma receive error

3. Rate limit error messages on buffer allocation failures

Signed-off-by: Cyril Chemparathy <cyril@ti.com>
Signed-off-by: Michael Williamson <michael.williamson@criticallink.com>
Signed-off-by: Caglar Akyuz <caglarakyuz@gmail.com>
---
 drivers/net/davinci_emac.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 363c970..9e866ae 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -1002,13 +1002,22 @@ static void emac_rx_handler(void *token, int len, int status)
 	struct sk_buff		*skb = token;
 	struct net_device	*ndev = skb->dev;
 	struct emac_priv	*priv = netdev_priv(ndev);
+	struct device		*emac_dev = &ndev->dev;
 	int			ret;
 
+	/* free and bail if we are shutting down */
+	if (unlikely(!netif_running(ndev))) {
+		dev_kfree_skb_any(skb);
+		return;
+	}
+
+	/* recycle on recieve error */
 	if (status < 0) {
-		/* error */
+		ndev->stats.rx_errors++;
 		goto recycle;
 	}
 
+	/* feed received packet up the stack */
 	skb_put(skb, len);
 	skb->protocol = eth_type_trans(skb, ndev);
 	netif_receive_skb(skb);
@@ -1017,13 +1026,17 @@ static void emac_rx_handler(void *token, int len, int status)
 
 	/* alloc a new packet for receive */
 	skb = emac_rx_alloc(priv);
+	if (!skb) {
+		if (netif_msg_rx_err(priv) && net_ratelimit())
+			dev_err(emac_dev, "failed rx buffer alloc\n");
+		return;
+	}
 
 recycle:
-	if (skb) {
-		ret = cpdma_chan_submit(priv->rxchan, skb, skb->data,
-					skb_tailroom(skb), GFP_KERNEL);
-		WARN_ON(ret < 0);
-	}
+	ret = cpdma_chan_submit(priv->rxchan, skb, skb->data,
+			skb_tailroom(skb), GFP_KERNEL);
+	if (WARN_ON(ret < 0))
+		dev_kfree_skb_any(skb);
 }
 
 static void emac_tx_handler(void *token, int len, int status)
-- 
1.7.0.4


  parent reply	other threads:[~2010-09-13 18:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-13 18:07 [PATCH 0/9] post cpdma/mdio refactoring fixes Cyril Chemparathy
     [not found] ` <1284401251-8846-1-git-send-email-cyril-l0cyMroinI0@public.gmane.org>
2010-09-13 18:07   ` [PATCH 1/9] net: davinci_emac: allow forced 100/full via phy_id Cyril Chemparathy
2010-09-13 18:07 ` [PATCH 2/9] davinci: specify phy_id rather than auto-detect Cyril Chemparathy
2010-09-13 18:07 ` [PATCH 3/9] net: davinci_cpdma: requeue on early end-of-queue Cyril Chemparathy
2010-09-13 18:07 ` Cyril Chemparathy [this message]
2010-09-13 18:07 ` [PATCH 5/9] net: davinci_mdio: separate out controller reset Cyril Chemparathy
2010-09-13 18:07 ` [PATCH 6/9] net: davinci_mdio: use calculated bus access times Cyril Chemparathy
2010-09-13 18:07 ` [PATCH 7/9] net: davinci_mdio: work around emac soft-reset during i/o Cyril Chemparathy
2010-09-13 18:07 ` [PATCH 8/9] net: davinci_cpdma: add register dump routines Cyril Chemparathy
2010-09-13 18:07 ` [PATCH 9/9] net: davinci_emac: extended register dumps on tx timeout Cyril Chemparathy
2010-09-14 18:50 ` [PATCH 0/9] post cpdma/mdio refactoring fixes Kevin Hilman

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=1284401251-8846-5-git-send-email-cyril@ti.com \
    --to=cyril@ti.com \
    --cc=bparrot@ti.com \
    --cc=caglarakyuz@gmail.com \
    --cc=davinci-linux-open-source@linux.davincidsp.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=michael.williamson@criticallink.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.