* [PATCH v3] net: stmmac: Modify the judgment condition of "tx_avail" from 1 to 2
@ 2025-12-03 1:31 2694439648
2025-12-05 1:51 ` Jakub Kicinski
0 siblings, 1 reply; 2+ messages in thread
From: 2694439648 @ 2025-12-03 1:31 UTC (permalink / raw)
To: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
alexandre.torgue, hailong.fan
Cc: netdev, linux-stm32, linux-arm-kernel, inux-kernel
From: "hailong.fan" <hailong.fan@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.
Changes from v3:
- format commit message
Changes from v2:
- add fixes tag
- Add stmmac_extra_space to count the additional required space
Changes from v1:
- Stop their queues earlier
Fixes: 30d932279dc2 ("net: stmmac: Add support for VLAN Insertion Offload")
Signed-off-by: hailong.fan <hailong.fan@siengine.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 7b90ecd3a..9a665a3b2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4476,6 +4476,15 @@ static bool stmmac_has_ip_ethertype(struct sk_buff *skb)
(proto == htons(ETH_P_IP) || proto == htons(ETH_P_IPV6));
}
+static inline int stmmac_extra_space(struct stmmac_priv *priv,
+ struct sk_buff *skb)
+{
+ if (!priv->dma_cap.vlins || !skb_vlan_tag_present(skb))
+ return 0;
+
+ return 1;
+}
+
/**
* stmmac_xmit - Tx entry point of the driver
* @skb : the socket buffer
@@ -4529,7 +4538,8 @@ 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 + 1 + stmmac_extra_space(priv, skb))) {
if (!netif_tx_queue_stopped(netdev_get_tx_queue(dev, queue))) {
netif_tx_stop_queue(netdev_get_tx_queue(priv->dev,
queue));
@@ -4675,7 +4685,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));
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] net: stmmac: Modify the judgment condition of "tx_avail" from 1 to 2
2025-12-03 1:31 [PATCH v3] net: stmmac: Modify the judgment condition of "tx_avail" from 1 to 2 2694439648
@ 2025-12-05 1:51 ` Jakub Kicinski
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2025-12-05 1:51 UTC (permalink / raw)
To: 2694439648
Cc: andrew+netdev, davem, edumazet, pabeni, mcoquelin.stm32,
alexandre.torgue, hailong.fan, netdev, linux-stm32,
linux-arm-kernel, inux-kernel
On Wed, 3 Dec 2025 09:31:52 +0800 2694439648@qq.com wrote:
> - if (unlikely(stmmac_tx_avail(priv, queue) <= (MAX_SKB_FRAGS + 1))) {
> + if (unlikely(stmmac_tx_avail(priv, queue) <= (MAX_SKB_FRAGS + 2))) {
Please add a constant for "(MAX_SKB_FRAGS + 2)" and a comment next to
it explaining why the literal 2 is used.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-05 1:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-03 1:31 [PATCH v3] net: stmmac: Modify the judgment condition of "tx_avail" from 1 to 2 2694439648
2025-12-05 1:51 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).