Netdev List
 help / color / mirror / Atom feed
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 v7 16/18] net: ethernet: cortina: Drain RX coalescing timer on stop
Date: Wed, 11 Nov 2026 23:10:52 +0000	[thread overview]
Message-ID: <179443865223.2199510.8707051713281280045@kernel.org> (raw)
In-Reply-To: <20261110-gemini-ethernet-fixes-3-v7-16-9c32a1a46aec@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 message does not explain that moving hrtimer_setup()
  in gmac_open() (drivers/net/ethernet/cortina/gemini.c) fixes a…
- [Low] The commit message's reason for keeping the first
  hrtimer_cancel() in gmac_stop()…

--

net: ethernet: cortina: Drain RX coalescing timer on stop

This patch moves hrtimer_setup() for the RX coalescing timer in
gmac_open() so it runs before request_irq(). It also adds a second
hrtimer_cancel() in gmac_stop() after free_irq(). The aim is that no RX
interrupt can leave the timer queued after the port state has been freed.

> Initialize the timer before requesting the IRQ, and cancel it again
> after free_irq() has drained every handler that can rearm it. Keep the
> first cancellation to prevent the timer callback from scheduling NAPI
> while the poll instance is being disabled.

[Severity: Low]
Is this description of the first cancellation accurate? The paragraph
before it says an RX interrupt racing with that cancellation can rearm
the timer. That still seems possible while napi_disable() runs.

In gmac_stop(), the RX interrupt is only masked after napi_disable():

gmac_stop() {
	hrtimer_cancel(&port->rx_coalesce_timer);
	netif_tx_stop_all_queues(netdev);
	gmac_disable_tx_rx(netdev);
	gmac_stop_dma(port);
	napi_disable(&port->napi);
	...
	gmac_enable_irq(netdev, 0);
	...
}

A NAPI poll that finishes at the same time as the first cancel turns
the RX interrupt back on:

gmac_napi_poll() {
	...
	if (!reschedule && received < budget &&
	    napi_complete_done(napi, received))
		gmac_enable_rx_irq(napi->dev, 1);
	...
}

After that, gmac_irq() can call hrtimer_start() again. Then
gmac_coalesce_delay_expired()->napi_schedule() can run while
napi_disable() is still in progress. When rx_coalesce_nsecs is 0,
gmac_irq() calls napi_schedule() directly in the same window.

This does not cause a functional problem. A napi_schedule() on a NAPI
instance that is being disabled is either a no-op or gets waited out.
Still, the first cancel only handles a timer that is already pending. It
does not handle the rearm case.

Could the commit message say the early cancel is only best-effort?
Another option is to mask the RX interrupt before napi_disable().

> diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
> index 59e6aeb07e0b4..58d6ed81a59c8 100644
> --- a/drivers/net/ethernet/cortina/gemini.c
> +++ b/drivers/net/ethernet/cortina/gemini.c
> @@ -2201,6 +2201,10 @@ static int gmac_open(struct net_device *netdev)
>  	struct gemini_ethernet_port *port = netdev_priv(netdev);
>  	int err;
>  
> +	hrtimer_setup(&port->rx_coalesce_timer,
> +		      &gmac_coalesce_delay_expired,
> +		      CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> +
>  	err = request_irq(netdev->irq, gmac_irq,
>  			  IRQF_SHARED, netdev->name, netdev);
>  	if (err) {
> @@ -2237,9 +2241,6 @@ static int gmac_open(struct net_device *netdev)
>  	gmac_enable_tx_rx(netdev);
>  	netif_tx_start_all_queues(netdev);
>  
> -	hrtimer_setup(&port->rx_coalesce_timer, &gmac_coalesce_delay_expired, CLOCK_MONOTONIC,
> -		      HRTIMER_MODE_REL);
> -
>  	netdev_dbg(netdev, "opened\n");
>  
>  	return 0;

[Severity: Low]
This move also seems to fix a separate race on the open side, and the
commit message does not describe it. Should the commit message mention
it, or should it go in its own patch?

Before this patch, gmac_open() called gmac_enable_irq(netdev, 1) before
hrtimer_setup(). gmac_irq() arms the timer once the RX interrupt is
unmasked, if rx_coalesce_nsecs is non-zero:

	if (!port->rx_coalesce_nsecs) {
		napi_schedule(&port->napi);
	} else {
		...
		hrtimer_start(&port->rx_coalesce_timer, ktime,
			      HRTIMER_MODE_REL);
	}

The default is 0, but gmac_set_coalesce() lets rx-usecs be set while
the interface is down. In that case, an RX interrupt can arrive between
gmac_enable_irq(netdev, 1) and the old hrtimer_setup() call:

- On the first open, it would start a zeroed hrtimer that was never
  initialized.

- On a reopen, it would start a timer that hrtimer_setup() then
  re-initializes while it is still queued.

The stop-side fix does not depend on this move, because ndo_stop only
runs after a successful open. If the commit message does not explain the
move, backporters might treat this hunk as cosmetic.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261110-gemini-ethernet-fixes-3-v7-0-9c32a1a46aec%40kernel.org

  reply	other threads:[~2026-11-11 23:10 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 22:13 [PATCH net-next v7 00/18] net: ethernet: cortina: Fix Gemini RX/TX buffer management Linus Walleij
2026-11-10 22:13 ` [PATCH net-next v7 01/18] net: ethernet: cortina: Keep shared free queue parent-owned Linus Walleij
2026-11-10 22:13 ` [PATCH net-next v7 02/18] net: ethernet: cortina: Keep ports bound for shared IRQ Linus Walleij
2026-11-11 23:10   ` netdev-bot+sashiko
2026-11-10 22:13 ` [PATCH net-next v7 03/18] net: ethernet: cortina: Drain free queue IRQ before resize Linus Walleij
2026-11-10 22:13 ` [PATCH net-next v7 04/18] net: ethernet: cortina: Normalize free queue pointers on rebuild Linus Walleij
2026-11-11 23:10   ` netdev-bot+sashiko
2026-11-10 22:13 ` [PATCH net-next v7 05/18] net: ethernet: cortina: Correct free queue DMA mappings Linus Walleij
2026-11-11 23:10   ` netdev-bot+sashiko
2026-11-10 22:13 ` [PATCH net-next v7 06/18] net: ethernet: cortina: Index free queue fragments with XArray Linus Walleij
2026-11-10 22:13 ` [PATCH net-next v7 07/18] net: ethernet: cortina: Preserve in-flight free queue pages Linus Walleij
2026-11-11 23:10   ` netdev-bot+sashiko
2026-11-10 22:13 ` [PATCH net-next v7 08/18] net: ethernet: cortina: Rotate free queue page allocation Linus Walleij
2026-11-10 22:13 ` [PATCH net-next v7 09/18] net: ethernet: cortina: Recycle claimed free queue pages Linus Walleij
2026-11-10 22:13 ` [PATCH net-next v7 10/18] net: ethernet: cortina: Validate RX fragment lengths Linus Walleij
2026-11-10 22:13 ` [PATCH net-next v7 11/18] net: ethernet: cortina: Account RX buffer size in truesize Linus Walleij
2026-11-10 22:13 ` [PATCH net-next v7 12/18] net: ethernet: cortina: Release partial RX frames on stop Linus Walleij
2026-11-10 22:13 ` [PATCH net-next v7 13/18] net: ethernet: cortina: Scale Gemini RX queues to system memory Linus Walleij
2026-11-10 22:13 ` [PATCH net-next v7 14/18] net: ethernet: cortina: Serialize TX completion statistics Linus Walleij
2026-11-10 22:13 ` [PATCH net-next v7 15/18] net: ethernet: cortina: Scope RX statistics updates Linus Walleij
2026-11-11 23:10   ` netdev-bot+sashiko
2026-11-10 22:13 ` [PATCH net-next v7 16/18] net: ethernet: cortina: Drain RX coalescing timer on stop Linus Walleij
2026-11-11 23:10   ` netdev-bot+sashiko [this message]
2026-11-10 22:13 ` [PATCH net-next v7 17/18] net: ethernet: cortina: Reject TX rings smaller than retained pointers Linus Walleij
2026-11-10 22:13 ` [PATCH net-next v7 18/18] net: ethernet: cortina: Fix ethtool statistics reads 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=179443865223.2199510.8707051713281280045@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