回复: [PATCH] net: stmmac: Modify the judgment condition of "tx_avail" from 1 to 2
Fan Hailong/范海龙
hailong.fan at siengine.com
Mon Dec 1 17:24:35 PST 2025
Hi Eric
You are right, I will follow your advice to modify the relevant code.
Regards
Hailong
-----邮件原件-----
发件人: Eric Dumazet <edumazet at google.com>
发送时间: 2025年12月1日 20:21
收件人: 2694439648 at qq.com
抄送: andrew+netdev at lunn.ch; davem at davemloft.net; kuba at kernel.org; pabeni at redhat.com; mcoquelin.stm32 at gmail.com; alexandre.torgue at foss.st.com; Fan Hailong/范海龙 <hailong.fan at siengine.com>; netdev at vger.kernel.org; linux-stm32 at st-md-mailman.stormreply.com; linux-arm-kernel at lists.infradead.org; inux-kernel at vger.kernel.org
主题: Re: [PATCH] net: stmmac: Modify the judgment condition of "tx_avail" from 1 to 2
On Sun, Nov 30, 2025 at 6:57 PM <2694439648 at qq.com> wrote:
>
> From: "hailong.fan" <hailong.fan at siengine.com>
>
> Under certain conditions, a WARN_ON will be triggered
> if avail equals 1.
>
> For example, when a VLAN packet is to send,
> stmmac_vlan_insert consumes one unit of space,
> and the data itself consumes another.
> actually requiring 2 units of space in total.
>
> Signed-off-by: hailong.fan <hailong.fan at siengine.com>
> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 7b90ecd3a..b575384cd 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -4529,7 +4529,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
> }
> }
>
> - if (unlikely(stmmac_tx_avail(priv, queue) < nfrags + 1)) {
> + if (unlikely(stmmac_tx_avail(priv, queue) < nfrags + 2)) {
> if (!netif_tx_queue_stopped(netdev_get_tx_queue(dev, queue))) {
> netif_tx_stop_queue(netdev_get_tx_queue(priv->dev,
>
> queue));
Drivers should stop their queues earlier.
NETDEV_TX_BUSY is almost always wrong.
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 7b90ecd3a55e600458b0c87d6125831626f4683d..6dcc7b84a8759763b6471a48a6c80b1f17cd937c
100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4675,7 +4675,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
print_pkt(skb->data, skb->len);
}
- if (unlikely(stmmac_tx_avail(priv, queue) <= (MAX_SKB_FRAGS + 1))) {
+ if (unlikely(stmmac_tx_avail(priv, queue) <= (MAX_SKB_FRAGS +
+ 2))) {
netif_dbg(priv, hw, priv->dev, "%s: stop transmitted packets\n",
__func__);
netif_tx_stop_queue(netdev_get_tx_queue(priv->dev, queue));
More information about the linux-arm-kernel
mailing list