From: sashiko-bot@kernel.org
To: "Cunhao Lu" <1579567540@qq.com>
Cc: "Vincent Mailhol" <mailhol@kernel.org>,
"Marc Kleine-Budde" <mkl@pengutronix.de>,
"Oleksij Rempel" <o.rempel@pengutronix.de>,
linux-can@vger.kernel.org,
"Oliver Hartkopp" <socketcan@hartkopp.net>
Subject: Re: [PATCH v2 3/3] can: rockchip_canfd: serialize TX state and command writes
Date: Thu, 30 Jul 2026 10:50:46 +0000 [thread overview]
Message-ID: <20260730105047.51EC21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <tencent_73A6685E6540120E468C02F21189FCE69A09@qq.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The `tx_lock` fails to fully serialize `RKCANFD_REG_MODE` writes against the interrupt path, leaving a race that can break the bus-off state.
--
--- Patch [3]: [PATCH v2 3/3] can: rockchip_canfd: serialize TX state and command writes ---
commit 2a5b1a8235e0f295b950d48868b11a6ee290c521
Author: Cunhao Lu <1579567540@qq.com>
can: rockchip_canfd: serialize TX state and command writes
This patch adds a TX state lock to protect tx_head, tx_tail, and the
echo skb ring. It also serializes the MODE/CMD/MODE sequence between
the transmit and interrupt paths to address errata 6 and 12.
Fixes: ae002cc32ec4 ("can: rockchip_canfd: prepare to use full TX-FIFO depth")
Fixes: 83f9bd6bf39d ("can: rockchip_canfd: implement workaround for erratum 12")
Cc: stable@vger.kernel.org
Signed-off-by: Cunhao Lu <1579567540@qq.com>
> diff --git a/drivers/net/can/rockchip/rockchip_canfd-tx.c b/drivers/net/can/rockchip/rockchip_canfd-tx.c
> index c4ecdc9411cc6..c3811d3179b61 100644
> --- a/drivers/net/can/rockchip/rockchip_canfd-tx.c
> +++ b/drivers/net/can/rockchip/rockchip_canfd-tx.c
[ ... ]
> @@ -141,6 +158,7 @@ netdev_tx_t rkcanfd_start_xmit(struct sk_buff *skb, struct net_device *ndev)
> WRITE_ONCE(priv->tx_head, priv->tx_head + 1);
>
> rkcanfd_start_xmit_write_cmd(priv, reg_cmd);
> + spin_unlock_irqrestore(&priv->tx_lock, flags);
[Severity: High]
This is a pre-existing issue and was not introduced by this patch, but since
the commit message mentions using tx_lock to serialize the MODE/CMD/MODE
sequence between the transmit and interrupt paths, does this leave a race with
the bus-off error handler?
Looking at rkcanfd_chip_set_reset_mode() in
drivers/net/can/rockchip/rockchip_canfd-core.c, it places the controller in
reset during a bus-off event by writing 0x0 to RKCANFD_REG_MODE, but it does
so without holding tx_lock.
If a bus-off event occurs concurrently with a packet transmission, could the
following sequence occur?
CPU1 (Interrupt path):
rkcanfd_irq() -> rkcanfd_handle_state_error_int() -> rkcanfd_chip_stop() ->
rkcanfd_chip_set_reset_mode()
rkcanfd_write(priv, RKCANFD_REG_MODE, 0x0);
CPU2 (TX path, holding tx_lock):
rkcanfd_start_xmit_write_cmd()
rkcanfd_write(priv, RKCANFD_REG_MODE, priv->reg_mode_default);
Could this overwrite the bus-off reset mode and bring the controller back out
of reset prematurely, potentially causing the node to continuously disrupt the
CAN bus?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260730-master-v2-0-572974052400@qq.com?part=3
next prev parent reply other threads:[~2026-07-30 10:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260730-master-v2-0-572974052400@qq.com>
2026-07-30 10:11 ` [PATCH v2 1/3] can: rockchip_canfd: prevent TX stall on echo skb failure Cunhao Lu
2026-07-30 10:11 ` Cunhao Lu
2026-07-30 10:26 ` sashiko-bot
2026-07-30 11:38 ` Marc Kleine-Budde
2026-07-30 11:38 ` Marc Kleine-Budde
2026-07-30 12:39 ` Cunhao Lu
2026-07-30 12:39 ` Cunhao Lu
2026-07-30 10:11 ` [PATCH v2 2/3] can: rockchip_canfd: retry the outstanding TX buffer Cunhao Lu
2026-07-30 10:11 ` Cunhao Lu
2026-07-30 10:34 ` sashiko-bot
2026-07-30 10:11 ` [PATCH v2 3/3] can: rockchip_canfd: serialize TX state and command writes Cunhao Lu
2026-07-30 10:11 ` Cunhao Lu
2026-07-30 10:50 ` sashiko-bot [this message]
2026-07-30 10:11 [PATCH v2 0/3] can: rockchip_canfd: fix TX stalls and races Cunhao Lu
2026-07-30 10:11 ` Cunhao Lu
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=20260730105047.51EC21F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=1579567540@qq.com \
--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 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.