From: netdev-bot+sashiko@kernel.org
To: linusw@kernel.org
Cc: ulli.kroll@googlemail.com, andrew+netdev@lunn.ch,
davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
mirq-linux@rere.qmqm.pl, mhun512@gmail.com, edumazet@kernel.org,
netdev@vger.kernel.org
Subject: Re: [PATCH net-next v9 13/14] net: ethernet: cortina: Release partial RX frames on stop
Date: Tue, 24 Nov 2026 18:29:59 +0000 [thread overview]
Message-ID: <179554499959.3135.10353219127658240816@kernel.org> (raw)
In-Reply-To: <20261120-gemini-ethernet-fixes-3-v9-13-298671d799d5@kernel.org>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit fixes a real lifetime bug but has no Fixes: tag.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but it sits in the
stop path the patch changes.
--
net: ethernet: cortina: Release partial RX frames on stop
This patch frees a partially assembled RX skb held in napi->skb when
gmac_stop() runs, so a reopened interface does not get the stale skb back
from napi_get_frags(). The dropped frame is counted in rx_dropped under
the RX stats seqcount, using the irqsave update helpers.
> diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
> index 5f8f220ad9d73..3d121eec88733 100644
> --- a/drivers/net/ethernet/cortina/gemini.c
> +++ b/drivers/net/ethernet/cortina/gemini.c
> @@ -2269,12 +2269,19 @@ static int gmac_open(struct net_device *netdev)
> static int gmac_stop(struct net_device *netdev)
> {
> struct gemini_ethernet_port *port = netdev_priv(netdev);
> + unsigned long flags;
>
> hrtimer_cancel(&port->rx_coalesce_timer);
[Severity: High]
This isn't a bug introduced by this patch, but it is in the stop path this
patch changes. Can the RX coalesce timer be re-armed after this
hrtimer_cancel()?
The RX interrupt is not masked until gmac_enable_irq(netdev, 0) and
free_irq() run later in gmac_stop(). An RX interrupt in that window goes
through gmac_irq():
if (val & (DEFAULT_Q0_INT_BIT << netdev->dev_id)) {
gmac_enable_rx_irq(netdev, 0);
if (!port->rx_coalesce_nsecs) {
napi_schedule(&port->napi);
} else {
...
hrtimer_start(&port->rx_coalesce_timer, ktime,
HRTIMER_MODE_REL);
}
}
In that case ndo_stop returns with the timer still queued.
gmac_set_coalesce() sets rx_coalesce_nsecs to rx_coalesce_usecs * 1000
with no upper bound, so the timer can stay queued for up to about 4.29
seconds.
If the interface is reopened during that time, gmac_open() calls
hrtimer_setup() on a timer that is still queued. Could that corrupt the
hrtimer timerqueue?
If the device is removed instead, could gmac_coalesce_delay_expired()
fire after the netdev private area is freed and call napi_schedule() on
freed memory?
gmac_open() has a related ordering problem. request_irq(),
gmac_enable_irq(netdev, 1) and gmac_enable_tx_rx() all run before
hrtimer_setup(). gmac_set_coalesce() has no netif_running() check, so
coalescing can be set before the first open.
On that first open, an early RX interrupt would call hrtimer_start() on a
zero-initialized hrtimer whose timer->base is NULL. Would that oops in
lock_hrtimer_base()?
Would it make sense to set up the hrtimer once, at probe or ndo_init
time, and to cancel it only after the RX interrupt is masked or the IRQ
is freed?
> netif_tx_stop_all_queues(netdev);
> gmac_disable_tx_rx(netdev);
> gmac_stop_dma(port);
> napi_disable(&port->napi);
> + if (port->rx_skb) {
> + napi_free_frags(&port->napi);
> + flags = u64_stats_update_begin_irqsave(&port->rx_stats_syncp);
> + port->stats.rx_dropped++;
> + u64_stats_update_end_irqrestore(&port->rx_stats_syncp, flags);
> + }
> port->rx_skb = NULL;
[Severity: Low]
Should this patch have a Fixes: tag?
The port->rx_skb = NULL assignment here was added by commit 06937db21ee3
("net: ethernet: cortina: Make RX SKB per-port"). Before that commit, the
static skb in gmac_rx() kept its value across stop and open. The next SOF
descriptor then freed the leftover frame in gmac_rx():
if (skb) {
napi_free_frags(&port->napi);
port->stats.rx_dropped++;
skb = NULL;
Since 06937db21ee3, that check no longer fires after a reopen.
gmac_skb_if_good_frame()->napi_get_frags() then returns the stale
napi->skb.
Commit ebd8ec2b309e ("net: ethernet: cortina: Carry over frag counter")
later added port->rx_frag_nr = 0 to the same stop path, and the gap
remained.
06937db21ee3 has its own Fixes: tag and was merged through net, so it is
probably in stable trees. This change only touches gmac_stop() and does
not appear to depend on the earlier free-queue rework in the series, so
it could be backported by itself. Would this tag fit?
Fixes: 06937db21ee3 ("net: ethernet: cortina: Make RX SKB per-port")
> port->rx_frag_nr = 0;
> port->rx_dropping = false;
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120-gemini-ethernet-fixes-3-v9-0-298671d799d5%40kernel.org
next prev parent reply other threads:[~2026-11-24 18:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 17:29 [PATCH net-next v9 00/14] net: ethernet: cortina: Fix Gemini RX buffer management Linus Walleij
2026-11-20 17:29 ` [PATCH net-next v9 01/14] net: ethernet: cortina: Keep shared free queue parent-owned Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 02/14] net: ethernet: cortina: Keep ports bound for shared IRQ Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 03/14] net: ethernet: cortina: Drain free queue IRQ before resize Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 04/14] net: ethernet: cortina: Normalize free queue pointers on rebuild Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 05/14] net: ethernet: cortina: Correct free queue DMA mappings Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 06/14] net: ethernet: cortina: Index free queue fragments with XArray Linus Walleij
2026-11-20 17:29 ` [PATCH net-next v9 07/14] net: ethernet: cortina: Preserve in-flight free queue pages Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 08/14] net: ethernet: cortina: Rotate free queue page allocation Linus Walleij
2026-11-20 17:29 ` [PATCH net-next v9 09/14] net: ethernet: cortina: Recycle claimed free queue pages Linus Walleij
2026-11-20 17:29 ` [PATCH net-next v9 10/14] net: ethernet: cortina: Separate RX buffer capacity from free queue size Linus Walleij
2026-11-20 17:29 ` [PATCH net-next v9 11/14] net: ethernet: cortina: Validate RX fragment lengths Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 12/14] net: ethernet: cortina: Account RX buffer size in truesize Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 13/14] net: ethernet: cortina: Release partial RX frames on stop Linus Walleij
2026-11-24 18:29 ` netdev-bot+sashiko [this message]
2026-11-20 17:29 ` [PATCH net-next v9 14/14] net: ethernet: cortina: Scale Gemini RX queues to system memory Linus Walleij
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=179554499959.3135.10353219127658240816@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linusw@kernel.org \
--cc=mhun512@gmail.com \
--cc=mirq-linux@rere.qmqm.pl \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ulli.kroll@googlemail.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