linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@systec-electronic.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>,
	Wolfgang Grandegger <wg@grandegger.com>,
	"linux-can@vger.kernel.org" <linux-can@vger.kernel.org>
Subject: Re: [PATCH] c_can: Add support for eg20t (pch_can)
Date: Thu, 03 Apr 2014 17:47:53 +0200	[thread overview]
Message-ID: <1497730.QLQMESBtqQ@ws-stein> (raw)
In-Reply-To: <alpine.DEB.2.02.1404031703120.14882@ionos.tec.linutronix.de>

On Thursday 03 April 2014 17:11:18, Thomas Gleixner wrote:
> > > based on tag 'linux-can-fixes-for-3.15-20140401' on repository git://gitorious.org/linux-can/linux-can I have noticed message losts(only one message each time). Interestingly 'candump any,0~0,#FFFFFFFF' didn't show yn error frames.
> > > From 500000 CAN frames I lost 72 frames.
> 
> The split RX buffer handling is causing the hardware to drop frames
> without giving any notice. We debugged that in the last days and can
> prove that it is an hardware issue. Fun, isn't it ?
> 
> The package drop happens always at the point where the 8th message
> buffer is read out and all the lower buffers are reenabled. So
> something confuses the state machine of the message handler here.
> 
> If we disable the split buffer handling, then the drop out stops. That
> might cause packet reordering though. Find below a test patch.

I had to modify your patch slightly, but It didn't show any reordering though. Just the lost messages as before.
Regarding http://marc.info/?l=linux-can&m=139403207713987&w=2 it seems there is a race, when reenabling the lower buffers, bewteen reading current state and hardware inserting new message.

Alexander

Here is my used patch:
diff --git a/drivers/net/can/c_can/Kconfig b/drivers/net/can/c_can/Kconfig
index 61ffc12..fdca6a9 100644
--- a/drivers/net/can/c_can/Kconfig
+++ b/drivers/net/can/c_can/Kconfig
@@ -14,6 +14,12 @@ config CAN_C_CAN_PLATFORM
 	  SPEAr1310 and SPEAr320 evaluation boards & TI (www.ti.com)
 	  boards like am335x, dm814x, dm813x and dm811x.
 
+config CAN_C_CAN_NO_RX_SPLIT
+	bool "Disable RX Split buffer"
+	---help---
+	  RX Split buffer prevents packet reordering but can cause packet
+	  loss. Select the lesser of the two evils.
+
 config CAN_C_CAN_PCI
 	tristate "Generic PCI Bus based C_CAN/D_CAN driver"
 	depends on PCI
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 01dc494..d9dbac4 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -808,8 +808,12 @@ static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv,
 	while ((obj = ffs(pend)) && quota > 0) {
 		pend &= ~BIT(obj - 1);
 
+#ifndef CONFIG_CAN_C_CAN_NO_RX_SPLIT
 		mcmd = obj < C_CAN_MSG_RX_LOW_LAST ?
 			IF_COMM_RCV_LOW : IF_COMM_RCV_HIGH;
+#else
+		mcmd = IF_COMM_RCV_HIGH;
+#endif
 
 		c_can_object_get(dev, IF_RX, obj, mcmd);
 		ctrl = priv->read_reg(priv, C_CAN_IFACE(MSGCTRL_REG, IF_RX));
@@ -833,10 +837,11 @@ static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv,
 		/* read the data from the message object */
 		c_can_read_msg_object(dev, IF_RX, ctrl);
 
+#ifndef CONFIG_CAN_C_CAN_NO_RX_SPLIT
 		if (obj == C_CAN_MSG_RX_LOW_LAST)
 			/* activate all lower message objects */
 			c_can_activate_all_lower_rx_msg_obj(dev, IF_RX, ctrl);
-
+#endif
 		pkts++;
 		quota--;
 	}

-- 
Dipl.-Inf. Alexander Stein

SYS TEC electronic GmbH
Am Windrad 2
08468 Heinsdorfergrund
Tel.: 03765 38600-1156
Fax: 03765 38600-4100
Email: alexander.stein@systec-electronic.com
Website: www.systec-electronic.com
 
Managing Director: Dipl.-Phys. Siegmar Schmidt
Commercial registry: Amtsgericht Chemnitz, HRB 28082


  reply	other threads:[~2014-04-03 15:49 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-03 14:14 [PATCH] c_can: Add support for eg20t (pch_can) Alexander Stein
2014-04-03 14:55 ` Alexander Stein
2014-04-03 14:59   ` Marc Kleine-Budde
2014-04-03 15:11     ` Thomas Gleixner
2014-04-03 15:47       ` Alexander Stein [this message]
2014-04-03 19:28         ` Oliver Hartkopp
2014-04-03 20:59           ` Thomas Gleixner
2014-04-03 20:28         ` Thomas Gleixner
2014-04-03 18:41 ` Wolfgang Grandegger
2014-04-07  9:47   ` Alexander Stein
2014-04-07 10:19     ` Wolfgang Grandegger
2014-04-07 12:06     ` Thomas Gleixner
2014-04-07 12:07       ` Marc Kleine-Budde
2014-04-07 12:24         ` Alexander Stein
2014-04-07 12:34           ` Thomas Gleixner
2014-04-07 12:48             ` Alexander Stein
2014-04-07 12:56               ` Thomas Gleixner
2014-04-07 12:58                 ` Alexander Stein
2014-04-07 13:31                   ` Thomas Gleixner
2014-04-07 14:27                     ` Alexander Stein
2014-04-07 15:24                       ` Thomas Gleixner
2014-04-07 15:36                         ` Alexander Stein
2014-04-07 15:53                           ` Thomas Gleixner
2014-04-07 16:06                             ` Alexander Stein
2014-04-07 16:27                               ` Thomas Gleixner
2014-04-08  7:07                                 ` Alexander Stein
2014-04-08  8:26                                   ` Thomas Gleixner
2014-04-08  8:36                                     ` Alexander Stein
2014-04-08  7:18                                 ` Alexander Stein
2014-04-08  7:35                                   ` Thomas Gleixner
2014-04-07 16:27                             ` Wolfgang Grandegger
2014-04-07 20:03                               ` Thomas Gleixner
2014-04-08  6:17                                 ` Alexander Stein
2014-04-08  8:04                                   ` Thomas Gleixner
2014-04-07 18:11                         ` Marc Kleine-Budde
2014-04-07 18:15                           ` Thomas Gleixner
2014-04-17 19:53   ` 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=1497730.QLQMESBtqQ@ws-stein \
    --to=alexander.stein@systec-electronic.com \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=tglx@linutronix.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).