From: sashiko-bot@kernel.org
To: "Cunhao Lu" <1579567540@qq.com>
Cc: "Oleksij Rempel" <o.rempel@pengutronix.de>,
"Oliver Hartkopp" <socketcan@hartkopp.net>,
"Vincent Mailhol" <mailhol@kernel.org>,
linux-can@vger.kernel.org,
"Marc Kleine-Budde" <mkl@pengutronix.de>
Subject: Re: [PATCH v4 3/3] can: rockchip_canfd: serialize TX state and command writes
Date: Thu, 30 Jul 2026 16:16:54 +0000 [thread overview]
Message-ID: <20260730161655.5C2131F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <tencent_9BBC002BC4013FA9A6559A771980048B9107@qq.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Hardware FIFO and software state desynchronization when can_put_echo_skb fails.
--
--- Patch [3]: [PATCH v4 3/3] can: rockchip_canfd: serialize TX state and command writes ---
commit ab677d838393ae26a8c9bbe2590b03c3dd72671f
Author: Cunhao Lu <1579567540@qq.com>
can: rockchip_canfd: serialize TX state and command writes
This commit adds a tx_lock to serialize TX state and command writes in the
Rockchip CAN FD driver. It addresses races between the transmit and completion
paths, as well as an erratum 12 workaround bypass.
> diff --git a/drivers/net/can/rockchip/rockchip_canfd-tx.c b/drivers/net/can/rockchip/rockchip_canfd-tx.c
> index 2b5cd6aab31b6..c311b6990bc9e 100644
> --- a/drivers/net/can/rockchip/rockchip_canfd-tx.c
> +++ b/drivers/net/can/rockchip/rockchip_canfd-tx.c
[ ... ]
> @@ -124,8 +138,11 @@ netdev_tx_t rkcanfd_start_xmit(struct sk_buff *skb, struct net_device *ndev)
> *(u32 *)(cfd->data + i));
>
> frame_len = can_skb_get_frame_len(skb);
> + spin_lock_irqsave(&priv->tx_lock, flags);
> err = can_put_echo_skb(skb, ndev, tx_head, frame_len);
> if (err) {
> + spin_unlock_irqrestore(&priv->tx_lock, flags);
> +
> ndev->stats.tx_dropped++;
> return NETDEV_TX_OK;
> }
[Severity: High]
Does this error path leave the software and hardware out of sync?
If can_put_echo_skb() fails, the driver returns early from rkcanfd_start_xmit().
However, the frame data has already been written to the memory-mapped FIFO
input port just before this code block. Because the error path skips
advancing tx_head and issuing the TX command, it consumes a hardware buffer
slot and causes the software and hardware pointers to become permanently
out of sync.
On the next transmission, a new frame is pushed to the hardware, but the
un-advanced tx_head command is issued, which transmits the previously dropped
frame instead.
Should the driver only write to the hardware registers after
can_put_echo_skb() succeeds?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260730-master-v4-0-07f7952f761d@qq.com?part=3
prev parent reply other threads:[~2026-07-30 16:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260730-master-v4-0-07f7952f761d@qq.com>
2026-07-30 15:50 ` [PATCH v4 1/3] can: rockchip_canfd: prevent TX stall on echo skb failure Cunhao Lu
2026-07-30 15:50 ` Cunhao Lu
2026-07-30 16:11 ` sashiko-bot
2026-07-30 15:50 ` [PATCH v4 2/3] can: rockchip_canfd: retry the outstanding TX buffer Cunhao Lu
2026-07-30 15:50 ` Cunhao Lu
2026-07-30 16:12 ` sashiko-bot
2026-07-30 15:50 ` [PATCH v4 3/3] can: rockchip_canfd: serialize TX state and command writes Cunhao Lu
2026-07-30 15:50 ` Cunhao Lu
2026-07-30 16:16 ` 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=20260730161655.5C2131F00A3A@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.