From: sashiko-bot@kernel.org
To: "Cunhao Lu" <1579567540@qq.com>
Cc: "Oleksij Rempel" <o.rempel@pengutronix.de>,
"Marc Kleine-Budde" <mkl@pengutronix.de>,
"Oliver Hartkopp" <socketcan@hartkopp.net>,
linux-can@vger.kernel.org, "Vincent Mailhol" <mailhol@kernel.org>
Subject: Re: [PATCH v3 1/3] can: rockchip_canfd: prevent TX stall on echo skb failure
Date: Thu, 30 Jul 2026 14:01:36 +0000 [thread overview]
Message-ID: <20260730140136.C3DF21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <tencent_1BD50002C4093F92A6181A5D99D004949107@qq.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Incorrect Transmit Retry Target Index causes hardware to retry the wrong buffer, leading to a permanent TX stall.
- [High] Missing memory barriers in the lockless ring buffer logic between the TX path and RX IRQ handler allow concurrent CPUs to read a NULL `echo_skb`, stalling the TX queue.
--
--- Patch [1]: [PATCH v3 1/3] can: rockchip_canfd: prevent TX stall on echo skb failure ---
commit 39312269693a856e9d3d6b063ae673598025f7df
Author: Cunhao Lu <1579567540@qq.com>
can: rockchip_canfd: prevent TX stall on echo skb failure
rkcanfd_start_xmit() advances tx_head and requests transmission even when
can_put_echo_skb() fails. This patch halts tx_head advancement and
transmission request if the echo skb cannot be installed, dropping the frame
instead. It also makes can_put_echo_skb() consume the skb on its -EINVAL
error path.
Fixes: b6661d73290c ("can: rockchip_canfd: add TX PATH")
Cc: stable@vger.kernel.org
> diff --git a/drivers/net/can/dev/skb.c b/drivers/net/can/dev/skb.c
> index 95fcdc1026f80..44ebeba998370 100644
> --- a/drivers/net/can/dev/skb.c
> +++ b/drivers/net/can/dev/skb.c
[ ... ]
> @@ -54,6 +54,7 @@ int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
> if (idx >= priv->echo_skb_max) {
> netdev_err(dev, "%s: BUG! Trying to access can_priv::echo_skb out of bounds (%u/max %u)\n",
> __func__, idx, priv->echo_skb_max);
> + kfree_skb(skb);
> return -EINVAL;
> }
>
> diff --git a/drivers/net/can/rockchip/rockchip_canfd-tx.c b/drivers/net/can/rockchip/rockchip_canfd-tx.c
> index 12200dcfd3389..b1954b72560cf 100644
> --- a/drivers/net/can/rockchip/rockchip_canfd-tx.c
> +++ b/drivers/net/can/rockchip/rockchip_canfd-tx.c
[ ... ]
> @@ -125,8 +125,11 @@ netdev_tx_t rkcanfd_start_xmit(struct sk_buff *skb, struct net_device *ndev)
>
> frame_len = can_skb_get_frame_len(skb);
> err = can_put_echo_skb(skb, ndev, tx_head, frame_len);
> - if (!err)
> - netdev_sent_queue(priv->ndev, frame_len);
> + if (err) {
> + ndev->stats.tx_dropped++;
> + return NETDEV_TX_OK;
> + }
> + netdev_sent_queue(priv->ndev, frame_len);
>
> WRITE_ONCE(priv->tx_head, priv->tx_head + 1);
[Severity: High]
This isn't a bug introduced by this patch, but missing memory barriers in the
lockless ring buffer logic between the TX path and RX IRQ handler might allow
concurrent CPUs to read a NULL echo_skb.
When CPU 0 calls rkcanfd_start_xmit(), it sets echo_skb[idx] = skb inside
can_put_echo_skb() and then advances tx_head. Without an smp_wmb() or
smp_store_release() here, could an ARM CPU reorder the tx_head store to
become globally visible before the echo_skb store?
If CPU 1 processes an RX interrupt, reads the updated tx_head, and proceeds
into rkcanfd_rxstx_filter():
drivers/net/can/rockchip/rockchip_canfd-rx.c:rkcanfd_rxstx_filter() {
...
tx_tail = rkcanfd_get_tx_tail(priv);
skb = priv->can.echo_skb[tx_tail];
if (!skb) { ... }
...
}
Without an smp_rmb() or smp_load_acquire(), would CPU 1 observe a NULL
pointer, triggering an error and causing the TX frame to never be completed,
permanently stopping the netdev queue?
I also noticed a separate pre-existing issue in the transmit retry path.
[Severity: High]
This isn't a bug introduced by this patch, but it looks like the hardware
might retry the wrong buffer during an erratum recovery, leading to a
permanent TX stall.
Looking at rkcanfd_xmit_retry() in
drivers/net/can/rockchip/rockchip_canfd-tx.c:
const unsigned int tx_head = rkcanfd_get_tx_head(priv);
const u32 reg_cmd = RKCANFD_REG_CMD_TX_REQ(tx_head);
Does this function incorrectly use tx_head (the next free, unpopulated buffer
index) instead of tx_tail (the index of the failed frame that actually needs
retrying)?
Since rkcanfd_start_xmit() has already advanced tx_head, would the driver
request transmission for an empty buffer, leaving the correct buffer
unacknowledged and the TX queue permanently stalled?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260730-master-v3-0-91cf030c337d@qq.com?part=1
next prev parent reply other threads:[~2026-07-30 14:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260730-master-v3-0-91cf030c337d@qq.com>
2026-07-30 13:48 ` [PATCH v3 1/3] can: rockchip_canfd: prevent TX stall on echo skb failure Cunhao Lu
2026-07-30 13:48 ` Cunhao Lu
2026-07-30 13:54 ` Marc Kleine-Budde
2026-07-30 13:54 ` Marc Kleine-Budde
2026-07-30 14:01 ` sashiko-bot [this message]
2026-07-30 13:48 ` [PATCH v3 2/3] can: rockchip_canfd: retry the outstanding TX buffer Cunhao Lu
2026-07-30 13:48 ` Cunhao Lu
2026-07-30 14:05 ` sashiko-bot
2026-07-30 13:48 ` [PATCH v3 3/3] can: rockchip_canfd: serialize TX state and command writes Cunhao Lu
2026-07-30 13:48 ` Cunhao Lu
2026-07-30 14:09 ` Marc Kleine-Budde
2026-07-30 14:09 ` Marc Kleine-Budde
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=20260730140136.C3DF21F000E9@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.