From: "Cunhao Lu" <1579567540@qq.com>
To: netdev-bot+sashiko <netdev-bot+sashiko@kernel.org>
Cc: mkl <mkl@pengutronix.de>, mailhol <mailhol@kernel.org>,
heiko <heiko@sntech.de>, davem <davem@davemloft.net>,
wg <wg@grandegger.com>, socketcan <socketcan@hartkopp.net>,
kernel <kernel@pengutronix.de>,
linux-can <linux-can@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
linux-rockchip <linux-rockchip@lists.infradead.org>,
stable <stable@vger.kernel.org>, kuba <kuba@kernel.org>
Subject: Re: [PATCH net v5 5/6] can: rockchip_canfd: serialize TX with bus-off and restart
Date: Sat, 17 Oct 2026 11:54:03 +0800 [thread overview]
Message-ID: <tencent_C91338471C02F811B1FC329B56683265FE09@qq.com> (raw)
In-Reply-To: <179219884425.1406898.18319979032484933416@kernel.org>
Hi,
> [Severity: Low]
> This lock stays held with hard IRQs disabled until the end of
> rkcanfd_start_xmit(). The locked region includes the echo skb handling:
>
> drivers/net/can/rockchip/rockchip_canfd-tx.c:rkcanfd_start_xmit() {
> ...
> 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);
> ...
> }
>
> can_put_echo_skb()->can_create_echo_skb() clones the skb and then calls
> consume_skb() on the original. If the clone fails, it calls kfree_skb()
> instead. can_put_echo_skb() also calls kfree_skb() in three cases: IFF_ECHO
> is clear, the protocol check fails, or the echo slot is still occupied.
>
> Freeing the original skb runs the socket destructor (sock_wfree()). If this
> is the last TX skb of a closed socket, that can continue into __sk_free().
>
> The comment above dev_kfree_skb_irq() in include/linux/netdevice.h says
> kfree_skb() and consume_skb() must not be called with hardware interrupts
> disabled. Before this patch, ndo_start_xmit() ran with only BH disabled.
You are right. On non-PREEMPT_RT kernels, the new locking places the
original skb's release inside an IRQ-disabled section. I will fix this
in the next revision while preserving the synchronization with bus-off
and close.
> [Severity: Medium]
> This is a pre-existing issue that this patch did not introduce. What
> happens when can_put_echo_skb() fails earlier in this function?
Yes, the existing code still advances tx_head and submits the frame after
echo allocation fails. When tx_tail reaches the empty slot, completion
matching fails and tx_tail cannot advance, which can stall TX.
This predates the series. I have recorded it as a separate follow-up fix
and will keep it outside this restart/close series.
Regards,
Cunhao Lu
pw-bot: cr
next prev parent reply other threads:[~2026-10-17 3:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 9:45 [PATCH net v5 0/6] can: fix bus-off restart and device close races Cunhao Lu via B4 Relay
2026-10-15 9:45 ` [PATCH net v5 1/6] can: dev: prevent bus-off recovery when the interface is not running Cunhao Lu via B4 Relay
2026-10-17 1:00 ` netdev-bot+sashiko
2026-10-17 3:27 ` Cunhao Lu
2026-10-15 9:45 ` [PATCH net v5 2/6] can: dev: add close_candev_cancel_restart_sync() Cunhao Lu via B4 Relay
2026-10-17 1:00 ` netdev-bot+sashiko
2026-10-17 3:42 ` Cunhao Lu
2026-10-15 9:45 ` [PATCH net v5 3/6] can: rockchip_canfd: cancel bus-off restart before closing the device Cunhao Lu via B4 Relay
2026-10-15 9:45 ` [PATCH net v5 4/6] can: rockchip_canfd: prevent timestamp work from rearming after bus-off Cunhao Lu via B4 Relay
2026-10-15 9:45 ` [PATCH net v5 5/6] can: rockchip_canfd: serialize TX with bus-off and restart Cunhao Lu via B4 Relay
2026-10-17 1:00 ` netdev-bot+sashiko
2026-10-17 3:54 ` Cunhao Lu [this message]
2026-10-15 9:45 ` [PATCH net v5 6/6] can: rockchip_canfd: serialize timecounter timestamp conversion Cunhao Lu via B4 Relay
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=tencent_C91338471C02F811B1FC329B56683265FE09@qq.com \
--to=1579567540@qq.com \
--cc=davem@davemloft.net \
--cc=heiko@sntech.de \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev-bot+sashiko@kernel.org \
--cc=socketcan@hartkopp.net \
--cc=stable@vger.kernel.org \
--cc=wg@grandegger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®