Commit a9ca6e13 authored by Ahmed S. Darwish's avatar Ahmed S. Darwish Committed by Marc Kleine-Budde

can: kvaser_usb: Ignore spurious error events after a busoff

Sending data in high speed then introducing a busoff results
in spurious BUS_ERROR events from the USBCan-II firmware directly
_after_ the triggered BUS_OFF event.

In the current CAN state handling code, this will lead to an
invalid can state of ACTIVE, ERROR, or PASSIVE even though the
CAN controller has been already shut down due to the busoff.

Guard the state handling code from such invalid events.
Signed-off-by: default avatarAhmed S. Darwish <ahmed.darwish@valeo.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 8a00785e
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* Copyright (C) 2002-2006 KVASER AB, Sweden. All rights reserved. * Copyright (C) 2002-2006 KVASER AB, Sweden. All rights reserved.
* Copyright (C) 2010 Matthias Fuchs <matthias.fuchs@esd.eu>, esd gmbh * Copyright (C) 2010 Matthias Fuchs <matthias.fuchs@esd.eu>, esd gmbh
* Copyright (C) 2012 Olivier Sobrie <olivier@sobrie.be> * Copyright (C) 2012 Olivier Sobrie <olivier@sobrie.be>
* Copyright (C) 2015 Valeo A.S. * Copyright (C) 2015 Valeo S.A.
*/ */
#include <linux/completion.h> #include <linux/completion.h>
...@@ -824,15 +824,16 @@ static void kvaser_usb_rx_error_update_can_state(struct kvaser_usb_net_priv *pri ...@@ -824,15 +824,16 @@ static void kvaser_usb_rx_error_update_can_state(struct kvaser_usb_net_priv *pri
else if (es->status & M16C_STATE_BUS_PASSIVE) else if (es->status & M16C_STATE_BUS_PASSIVE)
new_state = CAN_STATE_ERROR_PASSIVE; new_state = CAN_STATE_ERROR_PASSIVE;
else if (es->status & M16C_STATE_BUS_ERROR) { else if (es->status & M16C_STATE_BUS_ERROR) {
if ((es->txerr >= 256) || (es->rxerr >= 256)) /* Guard against spurious error events after a busoff */
new_state = CAN_STATE_BUS_OFF; if (cur_state < CAN_STATE_BUS_OFF) {
else if ((es->txerr >= 128) || (es->rxerr >= 128)) if ((es->txerr >= 128) || (es->rxerr >= 128))
new_state = CAN_STATE_ERROR_PASSIVE; new_state = CAN_STATE_ERROR_PASSIVE;
else if ((es->txerr >= 96) || (es->rxerr >= 96)) else if ((es->txerr >= 96) || (es->rxerr >= 96))
new_state = CAN_STATE_ERROR_WARNING; new_state = CAN_STATE_ERROR_WARNING;
else if (cur_state > CAN_STATE_ERROR_ACTIVE) else if (cur_state > CAN_STATE_ERROR_ACTIVE)
new_state = CAN_STATE_ERROR_ACTIVE; new_state = CAN_STATE_ERROR_ACTIVE;
} }
}
if (!es->status) if (!es->status)
new_state = CAN_STATE_ERROR_ACTIVE; new_state = CAN_STATE_ERROR_ACTIVE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment