From: Jimmy Assarsson <extja@kvaser.com>
To: linux-can@vger.kernel.org, Anssi Hannula <anssi.hannula@bitwise.fi>
Cc: Jimmy Assarsson <jimmyassarsson@gmail.com>,
Jimmy Assarsson <extja@kvaser.com>
Subject: [PATCH v2 13/15] can: kvaser_usb_leaf: Fix bogus restart events
Date: Fri, 8 Jul 2022 13:57:07 +0200 [thread overview]
Message-ID: <20220708115709.232815-14-extja@kvaser.com> (raw)
In-Reply-To: <20220708115709.232815-1-extja@kvaser.com>
From: Anssi Hannula <anssi.hannula@bitwise.fi>
When auto-restart is enabled, the kvaser_usb_leaf driver considers
transition from any state >= CAN_STATE_BUS_OFF as a bus-off recovery
event (restart).
However, these events may occur at interface startup time before
kvaser_usb_open() has set the state to CAN_STATE_ERROR_ACTIVE, causing
restarts counter to increase and CAN_ERR_RESTARTED to be sent despite no
actual restart having occurred.
Fix that by making the auto-restart condition checks more strict so that
they only trigger when the interface was actually in the BUS_OFF state.
Fixes: 080f40a6fa28 ("can: kvaser_usb: Add support for Kvaser CAN/USB devices")
Tested-by: Jimmy Assarsson <extja@kvaser.com>
Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
---
Changes in v2:
- Rebased on b3b6df2c56d8 ("can: kvaser_usb: kvaser_usb_leaf: fix bittiming limits")
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
index dee3ae45a972..5e325bf40c84 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
@@ -901,7 +901,7 @@ static void kvaser_usb_leaf_tx_acknowledge(const struct kvaser_usb *dev,
context = &priv->tx_contexts[tid % dev->max_tx_urbs];
/* Sometimes the state change doesn't come after a bus-off event */
- if (priv->can.restart_ms && priv->can.state >= CAN_STATE_BUS_OFF) {
+ if (priv->can.restart_ms && priv->can.state == CAN_STATE_BUS_OFF) {
struct sk_buff *skb;
struct can_frame *cf;
@@ -1018,7 +1018,7 @@ kvaser_usb_leaf_rx_error_update_can_state(struct kvaser_usb_net_priv *priv,
}
if (priv->can.restart_ms &&
- cur_state >= CAN_STATE_BUS_OFF &&
+ cur_state == CAN_STATE_BUS_OFF &&
new_state < CAN_STATE_BUS_OFF)
priv->can.can_stats.restarts++;
@@ -1111,7 +1111,7 @@ static void kvaser_usb_leaf_rx_error(const struct kvaser_usb *dev,
}
if (priv->can.restart_ms &&
- old_state >= CAN_STATE_BUS_OFF &&
+ old_state == CAN_STATE_BUS_OFF &&
new_state < CAN_STATE_BUS_OFF) {
cf->can_id |= CAN_ERR_RESTARTED;
netif_carrier_on(priv->netdev);
--
2.36.1
next prev parent reply other threads:[~2022-07-08 11:58 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-08 11:56 [PATCH v2 00/15] can: kvaser_usb: Various fixes Jimmy Assarsson
2022-07-08 11:56 ` [PATCH v2 01/15] can: kvaser_usb_leaf: Fix overread with an invalid command Jimmy Assarsson
2022-07-08 11:56 ` [PATCH v2 02/15] can: kvaser_usb: Fix use of uninitialized completion Jimmy Assarsson
2022-07-08 11:56 ` [PATCH v2 03/15] can: kvaser_usb: Fix possible completions during init_completion Jimmy Assarsson
2022-07-08 11:56 ` [PATCH v2 04/15] can: kvaser_usb: kvaser_usb_leaf: Get capabilities from device Jimmy Assarsson
2022-08-12 15:44 ` Anssi Hannula
2022-08-18 18:33 ` Jimmy Assarsson
2022-09-01 12:34 ` Jimmy Assarsson
2022-07-08 11:56 ` [PATCH v2 05/15] can: kvaser_usb: kvaser_usb_leaf: Rename {leaf,usbcan}_cmd_error_event to {leaf,usbcan}_cmd_can_error_event Jimmy Assarsson
2022-07-08 11:57 ` [PATCH v2 06/15] can: kvaser_usb: kvaser_usb_leaf: Handle CMD_ERROR_EVENT Jimmy Assarsson
2022-07-08 11:57 ` [PATCH v2 07/15] can: kvaser_usb_leaf: Set Warning state even without bus errors Jimmy Assarsson
2022-07-08 11:57 ` [PATCH v2 08/15] can: kvaser_usb_leaf: Fix TX queue out of sync after restart Jimmy Assarsson
2022-07-08 11:57 ` [PATCH v2 09/15] can: kvaser_usb_leaf: Fix CAN state " Jimmy Assarsson
2022-07-08 11:57 ` [PATCH v2 10/15] can: kvaser_usb_leaf: Fix improved state not being reported Jimmy Assarsson
2022-07-08 11:57 ` [PATCH v2 11/15] can: kvaser_usb_leaf: Fix wrong CAN state after stopping Jimmy Assarsson
2022-07-08 11:57 ` [PATCH v2 12/15] can: kvaser_usb_leaf: Ignore stale bus-off after start Jimmy Assarsson
2022-07-08 11:57 ` Jimmy Assarsson [this message]
2022-07-08 11:57 ` [PATCH v2 14/15] can: kvaser_usb: Add struct kvaser_usb_busparams Jimmy Assarsson
2022-07-08 11:57 ` [PATCH v2 15/15] can: kvaser_usb: Compare requested bittiming parameters with actual parameters in do_set_{,data}_bittiming Jimmy Assarsson
2022-07-19 18:40 ` [PATCH v2 00/15] can: kvaser_usb: Various fixes Marc Kleine-Budde
2022-07-19 18:59 ` Jimmy Assarsson
2022-08-16 14:50 ` Marc Kleine-Budde
2022-08-18 18:35 ` Jimmy Assarsson
2022-08-12 15:44 ` Anssi Hannula
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=20220708115709.232815-14-extja@kvaser.com \
--to=extja@kvaser.com \
--cc=anssi.hannula@bitwise.fi \
--cc=jimmyassarsson@gmail.com \
--cc=linux-can@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).