From: David Miller <davem@davemloft.net>
To: narmstrong@neotion.com
Cc: nicolas.ferre@atmel.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] net: macb: Handle errors in RX path
Date: Sun, 20 Jul 2014 21:11:17 -0700 (PDT) [thread overview]
Message-ID: <20140720.211117.1625702942607731036.davem@davemloft.net> (raw)
In-Reply-To: <53C91658.208@neotion.com>
From: Neil Armstrong <narmstrong@neotion.com>
Date: Fri, 18 Jul 2014 14:43:04 +0200
> @@ -872,12 +890,22 @@ static int macb_poll(struct napi_struct *napi, int budget)
> status = macb_readl(bp, RSR);
> macb_writel(bp, RSR, status);
>
> - work_done = 0;
> + work_done = -EIO;
>
> netdev_vdbg(bp->dev, "poll: status = %08lx, budget = %d\n",
> - (unsigned long)status, budget);
> + (unsigned long)status, budget);
> +
> + if (status & (MACB_BIT(OVR) | MACB_BIT(BNA)) ||
> + !(status & MACB_BIT(REC))) {
> + netdev_err(bp->dev, "RX error, status = %02lx\n",
> + (unsigned long)status);
> + goto rx_out;
...
> @@ -892,7 +920,23 @@ static int macb_poll(struct napi_struct *napi, int budget)
> }
> }
>
> - /* TODO: Handle errors */
> + return work_done;
> +
> +rx_out:
> + /* In case of error, disable RX and reset
> + * the descriptor ring before re-enabling RX.
> + */
> + macb_writel(bp, NCR, macb_readl(bp, NCR) & ~MACB_BIT(RE));
> +
> + bp->macbgem_ops.mog_init_rx_rings(bp);
> + macb_writel(bp, RBQP, bp->rx_ring_dma);
> +
> + /* Re-enable RX and get notified for new packets */
> + macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(RE));
> +
> + napi_complete(napi);
> +
> + macb_writel(bp, IER, MACB_RX_INT_FLAGS);
>
> return work_done;
Do not return negative error codes, as you will in this path due to the
work_done = -EIO initialization, from the NAPI poll method.
You must always return the amount of work you processed, which you can
force to zero on errors that caused the chip to be reset and you thus
want polling to force terminate.
prev parent reply other threads:[~2014-07-21 4:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-18 12:43 [PATCH v2 2/2] net: macb: Handle errors in RX path Neil Armstrong
2014-07-21 4:11 ` David Miller [this message]
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=20140720.211117.1625702942607731036.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=narmstrong@neotion.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;
as well as URLs for NNTP newsgroup(s).