From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, linux-can@vger.kernel.org,
kernel@pengutronix.de,
"Ahmed S. Darwish" <ahmed.darwish@valeo.com>,
linux-stable <stable@vger.kernel.org>,
Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH 4/4] can: kvaser_usb: Fix state handling upon BUS_ERROR events
Date: Tue, 27 Jan 2015 09:01:27 +0100 [thread overview]
Message-ID: <1422345687-12839-5-git-send-email-mkl@pengutronix.de> (raw)
In-Reply-To: <1422345687-12839-1-git-send-email-mkl@pengutronix.de>
From: "Ahmed S. Darwish" <ahmed.darwish@valeo.com>
While being in an ERROR_WARNING state, and receiving further
bus error events with error counters still in the ERROR_WARNING
range of 97-127 inclusive, the state handling code erroneously
reverts back to ERROR_ACTIVE.
Per the CAN standard, only revert to ERROR_ACTIVE when the
error counters are less than 96.
Moreover, in certain Kvaser models, the BUS_ERROR flag is
always set along with undefined bits in the M16C status
register. Thus use bitwise operators instead of full equality
for checking that register against bus errors.
Signed-off-by: Ahmed S. Darwish <ahmed.darwish@valeo.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/usb/kvaser_usb.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
index 55407b9663a6..7af379ca861b 100644
--- a/drivers/net/can/usb/kvaser_usb.c
+++ b/drivers/net/can/usb/kvaser_usb.c
@@ -698,9 +698,7 @@ static void kvaser_usb_rx_error(const struct kvaser_usb *dev,
}
new_state = CAN_STATE_ERROR_PASSIVE;
- }
-
- if (status == M16C_STATE_BUS_ERROR) {
+ } else if (status & M16C_STATE_BUS_ERROR) {
if ((priv->can.state < CAN_STATE_ERROR_WARNING) &&
((txerr >= 96) || (rxerr >= 96))) {
cf->can_id |= CAN_ERR_CRTL;
@@ -710,7 +708,8 @@ static void kvaser_usb_rx_error(const struct kvaser_usb *dev,
priv->can.can_stats.error_warning++;
new_state = CAN_STATE_ERROR_WARNING;
- } else if (priv->can.state > CAN_STATE_ERROR_ACTIVE) {
+ } else if ((priv->can.state > CAN_STATE_ERROR_ACTIVE) &&
+ ((txerr < 96) && (rxerr < 96))) {
cf->can_id |= CAN_ERR_PROT;
cf->data[2] = CAN_ERR_PROT_ACTIVE;
--
2.1.4
next prev parent reply other threads:[~2015-01-27 8:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-27 8:01 pull-request: can 2015-01-27 Marc Kleine-Budde
2015-01-27 8:01 ` [PATCH 1/4] can: kvaser_usb: Do not sleep in atomic context Marc Kleine-Budde
2015-01-27 8:01 ` [PATCH 2/4] can: kvaser_usb: Send correct context to URB completion Marc Kleine-Budde
2015-01-27 8:01 ` [PATCH 3/4] can: kvaser_usb: Retry the first bulk transfer on -ETIMEDOUT Marc Kleine-Budde
2015-01-27 8:01 ` Marc Kleine-Budde [this message]
2015-01-27 8:13 ` pull-request: can 2015-01-27 David Miller
2015-01-27 8:14 ` 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=1422345687-12839-5-git-send-email-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=ahmed.darwish@valeo.com \
--cc=davem@davemloft.net \
--cc=kernel@pengutronix.de \
--cc=linux-can@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stable@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).