From: GBert <info@gerhard-bertelsmann.de>
To: linux-can@vger.kernel.org
Cc: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
Subject: [PATCH v2] can: sun4i: fix overrun
Date: Fri, 27 Oct 2017 14:46:51 +0200 [thread overview]
Message-ID: <1509108411-9614-1-git-send-email-info@gerhard-bertelsmann.de> (raw)
In-Reply-To: <5511583c-37ac-c6b7-f88d-1fd740fae3f5 () pengutronix ! de>
From: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
SUN4Is CAN IP has a 64 byte deep FIFO buffer. If the buffer is not drained
fast enough (overrun) it's getting mangled. Already received frames are
dropped - the data can't be restored.
V2: no duplicate error reporting
---
drivers/net/can/sun4i_can.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c
index 68ef0a4..bcec511 100644
--- a/drivers/net/can/sun4i_can.c
+++ b/drivers/net/can/sun4i_can.c
@@ -539,6 +539,11 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status)
}
stats->rx_over_errors++;
stats->rx_errors++;
+
+ /* reset the CAN IP by entering reset mode */
+ err = set_reset_mode(dev);
+ err = set_normal_mode(dev);
+
/* clear bit */
sun4i_can_write_cmdreg(priv, SUN4I_CMD_CLEAR_OR_FLAG);
}
@@ -653,8 +658,9 @@ static irqreturn_t sun4i_can_interrupt(int irq, void *dev_id)
netif_wake_queue(dev);
can_led_event(dev, CAN_LED_EVENT_TX);
}
- if (isrc & SUN4I_INT_RBUF_VLD) {
- /* receive interrupt */
+ if ((isrc & SUN4I_INT_RBUF_VLD) &&
+ !(isrc & SUN4I_INT_DATA_OR)) {
+ /* receive interrupt - don't read if overrun occurred */
while (status & SUN4I_STA_RBUF_RDY) {
/* RX buffer is not empty */
sun4i_can_rx(dev);
--
1.7.9.5
next parent reply other threads:[~2017-10-27 12:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5511583c-37ac-c6b7-f88d-1fd740fae3f5 () pengutronix ! de>
2017-10-27 12:46 ` GBert [this message]
2017-11-06 15:03 ` [PATCH v2] can: sun4i: fix overrun Marc Kleine-Budde
2017-11-06 15:57 ` [PATCH v4] " GBert
2017-11-06 16:09 ` Marc Kleine-Budde
2017-11-06 17:16 ` [PATCH v5] " GBert
2017-11-07 8:22 ` Marc Kleine-Budde
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=1509108411-9614-1-git-send-email-info@gerhard-bertelsmann.de \
--to=info@gerhard-bertelsmann.de \
--cc=linux-can@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).