From: Arbab Haider <arbabhaider649@gmail.com>
To: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
Simon Horman <horms@kernel.org>, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH 7.0.y 5/5] net: stmmac: fix transmit interrupt coalescing
Date: Wed, 5 Aug 2026 15:01:36 +0500 [thread overview]
Message-ID: <20260805100136.59101-5-arbabhaider649@gmail.com> (raw)
In-Reply-To: <20260805100136.59101-1-arbabhaider649@gmail.com>
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
The accounting for transmit frames does not count the descriptors
correctly. It uses:
tx_packets = (tx_q->cur_tx + 1) - first_tx;
however, these are indexes into a circular buffer, so cur_tx can be
less than first_tx, and when that happens, tx_packets becomes a very
large unsigned integer. When this is added to tx_q->tx_count_frames,
it has the effect of reducing the count of frames, possibly causing
it to also wrap to a very large unsigned integer.
Fix this by using CIRC_CNT() to calculate the number of descriptors
used.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/E1vuoIl-0000000Aouz-0ttb@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ Upstream commit dd53a0e85969c6b2a5a4e4e46ba05b3187231017 ]
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 81a6ab19a45b..0266b09f0faf 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -14,6 +14,7 @@
https://bugzilla.stlinux.com/
*******************************************************************************/
+#include <linux/circ_buf.h>
#include <linux/clk.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
@@ -4511,7 +4512,8 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
tx_q->tx_skbuff_dma[tx_q->cur_tx].buf_type = STMMAC_TXBUF_T_SKB;
/* Manage tx mitigation */
- tx_packets = (tx_q->cur_tx + 1) - first_tx;
+ tx_packets = CIRC_CNT(tx_q->cur_tx + 1, first_tx,
+ priv->dma_conf.dma_tx_size);
tx_q->tx_count_frames += tx_packets;
if ((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && priv->hwts_tx_en)
@@ -4789,7 +4791,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
* This approach takes care about the fragments: desc is the first
* element in case of no SG.
*/
- tx_packets = (entry + 1) - first_tx;
+ tx_packets = CIRC_CNT(entry + 1, first_tx, priv->dma_conf.dma_tx_size);
tx_q->tx_count_frames += tx_packets;
if ((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && priv->hwts_tx_en)
--
2.53.0
next prev parent reply other threads:[~2026-08-05 10:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 10:01 [PATCH 7.0.y 1/5] net: mvneta: re-enable percpu interrupt on resume Arbab Haider
2026-08-05 10:01 ` [PATCH 7.0.y 2/5] net: mvneta: support EPROBE_DEFER when reading MAC address Arbab Haider
2026-08-05 10:01 ` [PATCH 7.0.y 3/5] net: macb: drop in-flight Tx SKBs on close Arbab Haider
2026-08-05 10:01 ` [PATCH 7.0.y 4/5] net: cpsw_new: unregister devlink on port registration failure Arbab Haider
2026-08-05 10:01 ` Arbab Haider [this message]
2026-08-05 16:41 ` [PATCH 7.0.y 1/5] net: mvneta: re-enable percpu interrupt on resume Sasha Levin
2026-08-05 18:37 ` Arbab Haider
2026-08-05 18:38 ` Arbab Haider
2026-08-06 4:44 ` Greg KH
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=20260805100136.59101-5-arbabhaider649@gmail.com \
--to=arbabhaider649@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rmk+kernel@armlinux.org.uk \
--cc=stable@vger.kernel.org \
/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