From: AnilKumar Ch <anilkumar@ti.com>
To: wg@grandegger.com, mkl@pengutronix.de
Cc: swarren@wwwdotorg.org, linux-can@vger.kernel.org,
anantgole@ti.com, nsekhar@ti.com, AnilKumar Ch <anilkumar@ti.com>
Subject: [PATCH] can: ti_hecc: fix rx wrong sequence issue
Date: Mon, 8 Oct 2012 12:10:36 +0530 [thread overview]
Message-ID: <1349678436-747-1-git-send-email-anilkumar@ti.com> (raw)
Fix "received wrong sequence count. expected: x, got: y" errors
reported by cansequence in a stress test (--verbose).
While processing the receive packets in mailboxes, upper mailboxes
need to enable while processing 12th (RX_BUFFER mailbox) mailbox.
This requires a status check to identify whether the receiving of
packets in progress or not. If the mailboxes are enabled before the
receive packet status is cleared then there is a possibility of
receiving out of order packets.
With this patch mailboxes are enabled once the receive status is
cleared.
Signed-off-by: AnilKumar Ch <anilkumar@ti.com>
---
drivers/net/can/ti_hecc.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index 39293e9..2417a2d 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -169,6 +169,7 @@ MODULE_VERSION(HECC_MODULE_VERSION);
#define HECC_CANES_SMA BIT(5) /* suspend mode ack */
#define HECC_CANES_CCE BIT(4) /* Change config enabled */
#define HECC_CANES_PDA BIT(3) /* Power down mode ack */
+#define HECC_CANES_RM BIT(1) /* Receive Mode bit */
#define HECC_CANBTC_SAM BIT(7) /* sample points */
@@ -194,6 +195,13 @@ MODULE_VERSION(HECC_MODULE_VERSION);
#define HECC_CANGIM_DEF_MASK 0x700 /* only busoff/warning/passive */
#define HECC_CANGIM_SIL BIT(2) /* system interrupts to int line 1 */
+/*
+ * Receive Mode bit reflects what the CAN protocol kernel (CPK) is
+ * actually doing regardless of mailbox configuration. CPK receive
+ * mode timeout. Tried from 1 - 5us and kept 10 as a safety value.
+ */
+#define RM_TIMEOUT_US 10
+
/* CAN Bittiming constants as per HECC specs */
static struct can_bittiming_const ti_hecc_bittiming_const = {
.name = DRV_NAME,
@@ -615,7 +623,7 @@ static int ti_hecc_rx_poll(struct napi_struct *napi, int quota)
struct ti_hecc_priv *priv = netdev_priv(ndev);
u32 num_pkts = 0;
u32 mbx_mask;
- unsigned long pending_pkts, flags;
+ unsigned long pending_pkts, flags, timeout;
if (!netif_running(ndev))
return 0;
@@ -633,6 +641,15 @@ static int ti_hecc_rx_poll(struct napi_struct *napi, int quota)
--priv->rx_next;
if (priv->rx_next == HECC_RX_BUFFER_MBOX) {
/* enable high bank mailboxes */
+ timeout = jiffies + usecs_to_jiffies(RM_TIMEOUT_US);
+ while (hecc_get_bit(priv, HECC_CANES, HECC_CANES_RM)) {
+ cpu_relax();
+ if (time_after(jiffies, timeout)) {
+ netdev_warn(ndev, "receiving pkt\n");
+ break;
+ }
+ }
+
spin_lock_irqsave(&priv->mbx_lock, flags);
mbx_mask = hecc_read(priv, HECC_CANME);
mbx_mask |= HECC_RX_HIGH_MBOX_MASK;
--
1.7.0.4
next reply other threads:[~2012-10-08 6:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-08 6:40 AnilKumar Ch [this message]
2012-10-08 9:12 ` [PATCH] can: ti_hecc: fix rx wrong sequence issue Jan Lübbe
2012-10-11 12:01 ` Jan Lübbe
2012-10-08 9:28 ` Wolfgang Grandegger
2012-11-05 11:34 ` Marc Kleine-Budde
2012-11-05 13:47 ` AnilKumar, Chimata
2012-11-05 13:56 ` Marc Kleine-Budde
2012-11-05 18:15 ` Marc Kleine-Budde
2012-11-05 18:40 ` Marc Kleine-Budde
2014-09-08 10:15 ` Jan Sondhauss
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=1349678436-747-1-git-send-email-anilkumar@ti.com \
--to=anilkumar@ti.com \
--cc=anantgole@ti.com \
--cc=linux-can@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=nsekhar@ti.com \
--cc=swarren@wwwdotorg.org \
--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).