From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx1.white.stw.pengutronix.de (mx1.white.stw.pengutronix.de [185.203.200.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C94C03BD657; Wed, 26 Aug 2026 12:10:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.200.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787746252; cv=none; b=uErBP4NpYORfDvRLJNd7l16OtyiulT3DEWThupSMXqa+atnMqmuAfZslRNPgcB6uS3CuIpnHZ+NGZgC/jLu1vnllcvyvlOunBMjqO5XtSU/Lp4QiBvaQRpgXeZ1KKYfJTstKEDFch07fcj7+YKHkngPskRmhinSgxglcrtkWP1o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787746252; c=relaxed/simple; bh=X7v2LJnJoDTl/6xgGJhsZSDCm+qtsmjkAVRyGhCrmdM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oRNaOja66Vl3vBhK9/KQLND4y+i/UHzXuCBsl/kGeM8IFF6Xhi7d5vRaHn7aBbSCMpHxBcoHW1dG9hhuf+vyKqNZPyETpdh9o8KPmimExQmqtHfjWbmUKXNAZNUDq90luLnF8bj60/9zOb7XAGMFgukXjrVCoPKeFv5gvdOTbsk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.200.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de (drehscheibe.grey.stw.pengutronix.de [IPv6:2a0a:edc0:0:c01:1d::a2]) (Authenticated sender: relay-from-drehscheibe.grey.stw.pengutronix.de) by mx1.white.stw.pengutronix.de (Postfix) with ESMTPSA id B0AA52021CF; Wed, 26 Aug 2026 14:10:38 +0200 (CEST) Received: from moin.white.stw.pengutronix.de ([2a0a:edc0:0:b01:1d::7b] helo=bjornoya.blackshift.org) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wzCSk-003R90-1v; Wed, 26 Aug 2026 14:10:38 +0200 Received: from blackshift.org (p4ffb23c7.dip0.t-ipconnect.de [79.251.35.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mkl-all@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id 5D6B758CCFC; Wed, 26 Aug 2026 12:10:38 +0000 (UTC) From: Marc Kleine-Budde To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org, kernel@pengutronix.de, Cunhao Lu <1579567540@qq.com>, stable@vger.kernel.org, Marc Kleine-Budde Subject: [PATCH net 05/14] can: rockchip_canfd: prevent TX stall on echo skb failure Date: Wed, 26 Aug 2026 14:02:15 +0200 Message-ID: <20260826121036.2706424-6-mkl@pengutronix.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826121036.2706424-1-mkl@pengutronix.de> References: <20260826121036.2706424-1-mkl@pengutronix.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Cunhao Lu <1579567540@qq.com> rkcanfd_start_xmit() advances tx_head and requests transmission even when can_put_echo_skb() fails. This creates a pending TX entry without the echo skb that the RXSTX completion path needs to match the self-received frame. The entry cannot be completed, and the netdev TX queue can remain stopped after the two-entry software FIFO fills. Install the echo skb before loading the hardware TX buffer. If installation fails, account the frame as dropped and leave both the hardware FIFO and software TX state unchanged. After the echo skb is installed, use the stored echo skb as the source for the hardware frame data. This depends on the standalone can_put_echo_skb() ownership fix. It makes the remaining -EINVAL path consume the skb and was posted at: Link: https://lore.kernel.org/linux-can/tencent_944DADCC4B42C8484EC01DA2B15F42132906@qq.com Fixes: b6661d73290c ("can: rockchip_canfd: add TX PATH") Cc: stable@vger.kernel.org Signed-off-by: Cunhao Lu <1579567540@qq.com> Link: https://patch.msgid.link/tencent_C82C09E7235101CC88A97E154D2534183208@qq.com Signed-off-by: Marc Kleine-Budde --- drivers/net/can/rockchip/rockchip_canfd-tx.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/rockchip/rockchip_canfd-tx.c b/drivers/net/can/rockchip/rockchip_canfd-tx.c index 12200dcfd338..86fa8f2e1c8b 100644 --- a/drivers/net/can/rockchip/rockchip_canfd-tx.c +++ b/drivers/net/can/rockchip/rockchip_canfd-tx.c @@ -88,7 +88,16 @@ netdev_tx_t rkcanfd_start_xmit(struct sk_buff *skb, struct net_device *ndev) return NETDEV_TX_BUSY; } - cfd = (struct canfd_frame *)skb->data; + tx_head = rkcanfd_get_tx_head(priv); + frame_len = can_skb_get_frame_len(skb); + err = can_put_echo_skb(skb, ndev, tx_head, frame_len); + if (err) { + ndev->stats.tx_dropped++; + return NETDEV_TX_OK; + } + + skb = priv->can.echo_skb[tx_head]; + cfd = (const struct canfd_frame *)skb->data; if (cfd->can_id & CAN_EFF_FLAG) { reg_frameinfo = RKCANFD_REG_FD_FRAMEINFO_FRAME_FORMAT; @@ -114,7 +123,6 @@ netdev_tx_t rkcanfd_start_xmit(struct sk_buff *skb, struct net_device *ndev) cfd->len); } - tx_head = rkcanfd_get_tx_head(priv); reg_cmd = RKCANFD_REG_CMD_TX_REQ(tx_head); rkcanfd_write(priv, RKCANFD_REG_FD_TXFRAMEINFO, reg_frameinfo); @@ -123,10 +131,7 @@ netdev_tx_t rkcanfd_start_xmit(struct sk_buff *skb, struct net_device *ndev) rkcanfd_write(priv, RKCANFD_REG_FD_TXDATA0 + i, *(u32 *)(cfd->data + i)); - 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); + netdev_sent_queue(priv->ndev, frame_len); WRITE_ONCE(priv->tx_head, priv->tx_head + 1); -- 2.53.0