From: Antonio Quartulli <antonio@mandelbit.com>
To: netdev@vger.kernel.org
Cc: Subash Abhinov Kasiviswanathan
<subash.a.kasiviswanathan@oss.qualcomm.com>,
Sean Tranchetti <sean.tranchetti@oss.qualcomm.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Daniele Palmas <dnlplm@gmail.com>,
Taehee Yoo <ap420073@gmail.com>,
koen.vandeputte@citymesh.com,
Antonio Quartulli <antonio@mandelbit.com>
Subject: [PATCH net 2/6] net: qualcomm: rmnet: always arm the flush timer for a new aggregate
Date: Thu, 26 Nov 2026 17:32:15 +0100 [thread overview]
Message-ID: <20261126163219.1744750-3-antonio@mandelbit.com> (raw)
In-Reply-To: <20261126163219.1744750-1-antonio@mandelbit.com>
On flush, rmnet_map_tx_aggregate() resets agg_state and drops agg_lock
before cancelling the flush timer. A CPU starting a new aggregate in
that window finds the old timer active, so it neither arms it nor sets
agg_state. Once the old timer is cancelled, the new aggregate waits for
the next packet, and rmnet_map_tx_aggregate_exit() leaks it because
agg_state is not -EINPROGRESS.
To make reproducing this bug easier, a udelay(2000) was added
after agg_lock is dropped in the flush paths. Then, with two vnds on one
port, tx-aggr-max-frames 2 and tx-aggr-time-usecs 100000, one CPU sends
3 packets on the first vnd (bypass, new aggregate, flush) and another
sends 1 packet on the second vnd 0.5 ms later: that packet stays queued
past the timeout.
Cancel the timer under agg_lock, so a timer armed for a newer aggregate
cannot be cancelled, and arm it whenever agg_state is not -EINPROGRESS;
hrtimer_start() copes with a timer that is still enqueued or running.
If the cancel races with a running callback, the flush work it queued
finds either no aggregate or the new one, which it flushes early.
Fixes: 64b5d1f8f2d1 ("net: qualcomm: rmnet: add tx packets aggregation")
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
index 73b04fe386df..fdfc65c7c5e5 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
@@ -635,8 +635,8 @@ unsigned int rmnet_map_tx_aggregate(struct sk_buff *skb, struct rmnet_port *port
if (skb->len > size) {
agg_skb = port->skbagg_head;
reset_aggr_params(port);
+ hrtimer_try_to_cancel(&port->hrtimer);
spin_unlock_bh(&port->agg_lock);
- hrtimer_cancel(&port->hrtimer);
rmnet_send_skb(port, agg_skb);
spin_lock_bh(&port->agg_lock);
goto new_packet;
@@ -658,14 +658,14 @@ unsigned int rmnet_map_tx_aggregate(struct sk_buff *skb, struct rmnet_port *port
port->skbagg_head->len == port->egress_agg_params.bytes) {
agg_skb = port->skbagg_head;
reset_aggr_params(port);
+ hrtimer_try_to_cancel(&port->hrtimer);
spin_unlock_bh(&port->agg_lock);
- hrtimer_cancel(&port->hrtimer);
rmnet_send_skb(port, agg_skb);
return len;
}
schedule:
- if (!hrtimer_active(&port->hrtimer) && port->agg_state != -EINPROGRESS) {
+ if (port->agg_state != -EINPROGRESS) {
port->agg_state = -EINPROGRESS;
hrtimer_start(&port->hrtimer,
ns_to_ktime(port->egress_agg_params.time_nsec),
--
2.56.1
next prev parent reply other threads:[~2026-11-26 16:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 16:32 [PATCH net 0/6] net: qualcomm: rmnet: fix TX aggregation and teardown bugs Antonio Quartulli
2026-11-26 16:32 ` [PATCH net 1/6] net: qualcomm: rmnet: recheck the aggregate after flushing it Antonio Quartulli
2026-11-26 16:32 ` Antonio Quartulli [this message]
2026-11-26 16:32 ` [PATCH net 3/6] net: qualcomm: rmnet: fix TX aggregation timeout overflow on 32-bit Antonio Quartulli
2026-11-26 16:32 ` [PATCH net 4/6] net: qualcomm: rmnet: stop TX aggregation after detaching the port Antonio Quartulli
2026-11-26 16:32 ` [PATCH net 5/6] net: qualcomm: rmnet: account linearization failures on the real device Antonio Quartulli
2026-11-26 16:32 ` [PATCH net 6/6] net: qualcomm: rmnet: unlink the bridge from the vnd it is attached to Antonio Quartulli
2026-11-26 16:47 ` [PATCH net 0/6] net: qualcomm: rmnet: fix TX aggregation and teardown bugs Antonio Quartulli
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=20261126163219.1744750-3-antonio@mandelbit.com \
--to=antonio@mandelbit.com \
--cc=andrew+netdev@lunn.ch \
--cc=ap420073@gmail.com \
--cc=davem@davemloft.net \
--cc=dnlplm@gmail.com \
--cc=edumazet@kernel.org \
--cc=koen.vandeputte@citymesh.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sean.tranchetti@oss.qualcomm.com \
--cc=subash.a.kasiviswanathan@oss.qualcomm.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