Linux CAN drivers development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Marc Kleine-Budde" <mkl@pengutronix.de>
Cc: "Oliver Hartkopp" <socketcan@hartkopp.net>,
	"Oleksij Rempel" <o.rempel@pengutronix.de>,
	linux-can@vger.kernel.org, "Vincent Mailhol" <mailhol@kernel.org>,
	"Marc Kleine-Budde" <mkl@pengutronix.de>
Subject: Re: [PATCH can-next 13/13] can: gs_usb: implement CAN bus off recovery
Date: Mon, 20 Jul 2026 14:28:31 +0000	[thread overview]
Message-ID: <20260720142831.B766D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260720-gs_usb-new-features-v1-13-427a8013c380@pengutronix.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The CAN_ERR_RESTARTED bit check in gs_update_state() is always false because the bit is unconditionally cleared at the beginning of the function.
--

--- Patch [13]: [PATCH can-next 13/13] can: gs_usb: implement CAN bus off recovery ---
commit 7b5dd8a47b695ccb806d9d65e91f427368f07215
Author: Marc Kleine-Budde <mkl@pengutronix.de>

can: gs_usb: implement CAN bus off recovery

This patch implements manual CAN bus off recovery for gs_usb devices that
support the GS_CAN_FEATURE_BUS_OFF_RECOVERY feature. It allows the USB host
to control bus off recovery instead of relying on the hardware's automatic
recovery.

Link: https://github.com/candle-usb/candleLight_fw/pull/317

> diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
> --- a/drivers/net/can/usb/gs_usb.c
> +++ b/drivers/net/can/usb/gs_usb.c

[ ... ]

> @@ -573,14 +579,22 @@ static void gs_update_state(struct gs_can *dev, struct can_frame *cf,
>  		return;
>  
>  	/* some firmware does automatically CAN bus off recovery, account for this */
> -	if (cf->can_id & CAN_ERR_RESTARTED ||
> -	    (dev->can.state == CAN_STATE_BUS_OFF && new_state < CAN_STATE_BUS_OFF)) {
> +	if (!(dev->feature & GS_CAN_FEATURE_BUS_OFF_RECOVERY) &&
> +	    (cf->can_id & CAN_ERR_RESTARTED ||
> +	     (dev->can.state == CAN_STATE_BUS_OFF && new_state < CAN_STATE_BUS_OFF))) {

[Severity: Medium]
Will the check for CAN_ERR_RESTARTED ever evaluate to true in this
condition?

Looking earlier in gs_update_state(), the CAN_ERR_RESTARTED bit is
unconditionally cleared from cf->can_id:

	cf->can_id &= ~(CAN_ERR_CRTL | CAN_ERR_BUSOFF | CAN_ERR_RESTARTED);

Because of this, the check for CAN_ERR_RESTARTED here appears to be
structurally guaranteed to be false. Could this cause the driver to miss
bus-off restart events if the cached state was not already CAN_STATE_BUS_OFF?

>  		can_stats->restarts++;
>  		/* some firmware doesn't set CAN_ERR_RESTARTED, fixup */
>  		cf->can_id |= CAN_ERR_RESTARTED;
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260720-gs_usb-new-features-v1-0-427a8013c380@pengutronix.de?part=13

      reply	other threads:[~2026-07-20 14:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20 13:48 [PATCH can-next 00/13] can: gs_usb: implement new features recently added to candleLight firmware Marc Kleine-Budde
2026-07-20 13:48 ` [PATCH can-next 01/13] can: gs_usb: remove unused define GS_CAN_MODE_NORMAL Marc Kleine-Budde
2026-07-20 13:48 ` [PATCH can-next 02/13] can: gs_usb: replace all GS_CAN_MODE_* by GS_CAN_FEATURE_* Marc Kleine-Budde
2026-07-20 13:48 ` [PATCH can-next 03/13] can: gs_usb: update USB protocol definitions contributed by Elmue firmware Marc Kleine-Budde
2026-07-20 13:48 ` [PATCH can-next 04/13] can: gs_usb: document GS_CAN_FEATURE_FILTER Marc Kleine-Budde
2026-07-20 13:48 ` [PATCH can-next 05/13] can: gs_usb: gs_make_candev(): reduce scope of variable bt_const_extended Marc Kleine-Budde
2026-07-20 13:48 ` [PATCH can-next 06/13] can: gs_usb: gs_make_candev(): sort evaluation of device features Marc Kleine-Budde
2026-07-20 13:48 ` [PATCH can-next 07/13] can: gs_usb: gs_usb_receive_bulk_callback(): reduce scope of several variables Marc Kleine-Budde
2026-07-20 14:00   ` sashiko-bot
2026-07-20 15:07     ` Marc Kleine-Budde
2026-07-20 13:48 ` [PATCH can-next 08/13] can: gs_usb: gs_update_state(): convert CAN state handling to can_change_state() Marc Kleine-Budde
2026-07-20 14:10   ` sashiko-bot
2026-07-20 13:48 ` [PATCH can-next 09/13] can: gs_usb: gs_usb_state_get_by_hf(): optionally print recived CAN error frames Marc Kleine-Budde
2026-07-20 14:15   ` sashiko-bot
2026-07-20 13:48 ` [PATCH can-next 10/13] can: gs_usb: gs_update_state(): set CAN_ERR_CNT if device sends CAN error counters Marc Kleine-Budde
2026-07-20 14:11   ` sashiko-bot
2026-07-20 13:48 ` [PATCH can-next 11/13] can: gs_usb: implement CAN_CTRLMODE_BERR_REPORTING for devices without native support Marc Kleine-Budde
2026-07-20 14:19   ` sashiko-bot
2026-07-20 13:48 ` [PATCH can-next 12/13] can: gs_usb: implement Transceiver Delay Compensation Marc Kleine-Budde
2026-07-20 13:48 ` [PATCH can-next 13/13] can: gs_usb: implement CAN bus off recovery Marc Kleine-Budde
2026-07-20 14:28   ` sashiko-bot [this message]

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=20260720142831.B766D1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol@kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=o.rempel@pengutronix.de \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=socketcan@hartkopp.net \
    /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