linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Jander <david@protonic.nl>
To: wg@grandegger.com, mkl@pengutronix.de
Cc: linux-can@vger.kernel.org, David Jander <david@protonic.nl>
Subject: [PATCH 1/3] can: flexcan.c: Correctly initialize mailboxes
Date: Wed, 27 Aug 2014 11:58:05 +0200	[thread overview]
Message-ID: <1409133487-23367-2-git-send-email-david@protonic.nl> (raw)
In-Reply-To: <1409133487-23367-1-git-send-email-david@protonic.nl>

Apparently mailboxes may contain random data at startup, causing some of
them being prepared for message reception. This causes overruns being
missed or even confusing the IRQ check for trasmitted messages, increasing
the transmit counter instead of the error counter.

Signed-off-by: David Jander <david@protonic.nl>
---
 drivers/net/can/flexcan.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 944aa5d..a9700f3 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -801,6 +801,7 @@ static int flexcan_chip_start(struct net_device *dev)
 	struct flexcan_regs __iomem *regs = priv->base;
 	int err;
 	u32 reg_mcr, reg_ctrl;
+	int i;
 
 	/* enable module */
 	err = flexcan_chip_enable(priv);
@@ -867,9 +868,11 @@ static int flexcan_chip_start(struct net_device *dev)
 	netdev_dbg(dev, "%s: writing ctrl=0x%08x", __func__, reg_ctrl);
 	flexcan_write(reg_ctrl, &regs->ctrl);
 
-	/* Abort any pending TX, mark Mailbox as INACTIVE */
-	flexcan_write(FLEXCAN_MB_CNT_CODE(0x4),
-		      &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
+	/* Clear and invalidate all mailboxes first */
+	for (i = 0; i < 64; i++) {
+		flexcan_write(FLEXCAN_MB_CNT_CODE(0),
+		      &regs->cantxfg[i].can_ctrl);
+	}
 
 	/* acceptance mask/acceptance code (accept everything) */
 	flexcan_write(0x0, &regs->rxgmask);
-- 
1.9.1


  reply	other threads:[~2014-08-27 10:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-27  9:58 [PATCH 0/3] Decrease likelyhood of RX overruns David Jander
2014-08-27  9:58 ` David Jander [this message]
2014-09-02 10:24   ` [PATCH 1/3] can: flexcan.c: Correctly initialize mailboxes Marc Kleine-Budde
2014-09-02 10:37     ` David Jander
2014-09-02 10:59       ` Marc Kleine-Budde
2014-09-02 11:15         ` David Jander
2014-09-02 13:54           ` Marc Kleine-Budde
2014-09-02 14:27             ` David Jander
2014-09-02 11:32         ` David Jander
2014-09-02 11:38           ` Marc Kleine-Budde
2014-09-02 14:53             ` Marc Kleine-Budde
2014-08-27  9:58 ` [PATCH 2/3] can: flexcan.c: Re-write receive path to use MB queue instead of FIFO David Jander
2014-09-02 11:30   ` Marc Kleine-Budde
2014-09-02 12:04     ` David Jander
2014-09-02 14:53       ` Marc Kleine-Budde
2014-09-03  7:19         ` David Jander
2014-09-03  9:12           ` Marc Kleine-Budde
2014-09-03 15:42     ` David Jander
2014-08-27  9:58 ` [PATCH 3/3] can: flexcan.c: Implement last step of workaround for errata ERR005829 David Jander
2014-09-02 11:28   ` Marc Kleine-Budde
2014-09-02 11:36     ` David Jander

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=1409133487-23367-2-git-send-email-david@protonic.nl \
    --to=david@protonic.nl \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=wg@grandegger.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).