All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Claudiu Beznea" <claudiu.beznea+renesas@tuxon.dev>
Cc: conor+dt@kernel.org, robh@kernel.org,
	"Oleksij Rempel" <o.rempel@pengutronix.de>,
	linux-can@vger.kernel.org,
	"Marc Kleine-Budde" <mkl@pengutronix.de>,
	"Vincent Mailhol" <mailhol@kernel.org>,
	wsa+renesas@sang-engineering.com, devicetree@vger.kernel.org,
	"Oliver Hartkopp" <socketcan@hartkopp.net>
Subject: Re: [PATCH v4 4/7] can: rcar_canfd: Do not set registers selecting the CAN mode
Date: Wed, 02 Sep 2026 14:29:12 +0000	[thread overview]
Message-ID: <20260902142912.97F9A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260902141544.565763-5-claudiu.beznea+renesas@tuxon.dev>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] Software state diverges from fixed hardware capabilities due to unvalidated device tree overrides, causing silent data corruption and CAN protocol violations.

Pre-existing issues:
- [High] Race condition on write-0-to-clear status register causes lost TX completion interrupts and permanently frozen TX queues.
--

commit f5c5dd93cfcd4bdec86a8b0c4bc20cba21d7f4dc
Author: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

can: rcar_canfd: Do not set registers selecting the CAN mode

This commit adds a fixed_canfd flag to struct rcar_canfd_hw_info to handle
hardware like the Renesas RZ/G3S SoC that only supports CAN-FD mode. It skips
writing to unavailable CAN mode configuration bits during the reset controller
sequence.

Link: https://lore.kernel.org/all/1d9719e3-10ff-4cd8-b729-55fea93c37ce@wanadoo.fr

> diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
> index 2e84dc5dfa34d..bed7cde1aa01b 100644
> --- a/drivers/net/can/rcar/rcar_canfd.c
> +++ b/drivers/net/can/rcar/rcar_canfd.c

[ ... ]

> @@ -846,6 +852,9 @@ static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv)
>  		}
>  
>  		/* Set the controller into appropriate mode */
> +		if (gpriv->info->fixed_canfd)
> +			continue;
> +

[Severity: High]
Does bypassing the hardware mode setup here create a state mismatch if
the software interface is forced into Classical CAN mode?

If the device tree contains the "renesas,no-can-fd" property, the probe
function sets fdmode = false in rcar_canfd_probe():

drivers/net/can/rcar/rcar_canfd.c:rcar_canfd_probe() {
    ...
	if (of_property_read_bool(dev->of_node, "renesas,no-can-fd"))
		fdmode = false;			/* Classical CAN only mode */
    ...
}

With this patch, if a device with fixed_canfd uses that DT override, the
hardware remains fixed in CAN-FD mode but the software expects Classical CAN.
Could this cause the driver to silently truncate 64-byte CAN-FD frames to
8 bytes while acknowledging CAN-FD frames on the bus?

>  		if (gpriv->info->ch_interface_mode) {
>  			/* Do not set CLOE and FDOE simultaneously */
>  			if (!gpriv->fdmode) {

[ ... ]

This isn't a bug introduced by this patch, but I also noticed a pre-existing
issue in the transmit completion path:

[Severity: High]
Can writing back the stale status mask unintentionally clear newly asserted
interrupt flags?

In rcar_canfd_tx_done():

drivers/net/can/rcar/rcar_canfd.c:rcar_canfd_tx_done() {
    ...
	/* Clear interrupt */
	rcar_canfd_write(priv->base, RCANFD_CFSTS(gpriv, ch, RCANFD_CFFIFO_IDX),
			 sts & ~RCANFD_CFSTS_CFTXIF);
    ...
}

If a new interrupt (like another TX completion or message lost flag) is
asserted by the hardware immediately after the status register is read but
before this write-back, writing the stale sts value with a bitwise AND to
a write-0-to-clear register will write '0' to the newly asserted flag.

Could this cause lost TX completion interrupts and permanently frozen
TX queues?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260902141544.565763-1-claudiu.beznea+renesas@tuxon.dev?part=4

  reply	other threads:[~2026-09-02 14:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02 14:15 [PATCH v4 0/7] can: rcar_canfd: Add support for Renesas RZ/G3S Claudiu Beznea
2026-09-02 14:15 ` [PATCH v4 1/7] dt-bindings: can: renesas,rcar-canfd: Document RZ/G3S SoC Claudiu Beznea
2026-09-02 14:15 ` [PATCH v4 2/7] can: rcar_canfd: Fix typos in macro names Claudiu Beznea
2026-09-02 14:15 ` [PATCH v4 3/7] can: rcar_canfd: Allow the CAN FD clock to be sourced from fck Claudiu Beznea
2026-09-02 14:15 ` [PATCH v4 4/7] can: rcar_canfd: Do not set registers selecting the CAN mode Claudiu Beznea
2026-09-02 14:29   ` sashiko-bot [this message]
2026-09-07 12:37     ` Claudiu Beznea
2026-09-02 14:15 ` [PATCH v4 5/7] can: rcar_canfd: Add support for Renesas RZ/G3S Claudiu Beznea
2026-09-02 14:30   ` sashiko-bot
2026-09-07 12:32     ` Claudiu Beznea
2026-09-02 14:15 ` [PATCH v4 6/7] arm64: dts: renesas: r9a08g045: Add CAN-FD node Claudiu Beznea
2026-09-02 14:15 ` [PATCH v4 7/7] arm64: dts: renesas: rzg3s-smarc: Enable CAN-FD Claudiu Beznea

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=20260902142912.97F9A1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=claudiu.beznea+renesas@tuxon.dev \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol@kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=o.rempel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=socketcan@hartkopp.net \
    --cc=wsa+renesas@sang-engineering.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.