Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: antonio@mandelbit.com
Cc: intel-wired-lan@lists.osuosl.org, anthony.l.nguyen@intel.com,
	przemyslaw.kitszel@intel.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, janislacis06@gmail.com, ast@kernel.org,
	daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
	sdf@fomichev.me, sriram.yagnaraman@ericsson.com,
	kurt@linutronix.de, maciej.fijalkowski@intel.com,
	hkallweit1@gmail.com, joe@dama.to, rafael@kernel.org,
	sven.auhagen@voleatech.de, netdev@vger.kernel.org,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	bpf@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH net v7 3/7] igb: fix RTNL assertion when resuming from runtime suspend
Date: Thu, 03 Dec 2026 01:04:11 +0000	[thread overview]
Message-ID: <179625985176.3146.14979962176226526203@kernel.org> (raw)
In-Reply-To: <20261202002317.3140591-4-antonio@mandelbit.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 (2) · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The patch does not fully fix the RTNL assertion it targets on
  runtime resume, but a later patch in the series closes the gap.

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but
  `igb_save_cbs_params()` and `igb_save_txtime_params()` have an off-by-…
- [High] This problem wasn't introduced by this patch, but the MSI-X to
  MSI fallback in `igb_request_irq()` frees Rx/Tx descriptor rings and…

--

igb: fix RTNL assertion when resuming from runtime suspend

On runtime resume, __igb_open() no longer calls netif_set_real_num_queues()
when RTNL isn't held. A new work item takes RTNL and sets the queue
counts instead. Until that runs, igb_xmit_frame() drops packets whose
queue_mapping is beyond the device's current TX queue count, rather than
folding them onto a shared ring.

Closes: https://bugzilla.ipfire.org/show_bug.cgi?id=13562

> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index 2fb9615d3bab3..5774a4d3c9810 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c

[ ... ]

> @@ -4181,16 +4209,15 @@ static int __igb_open(struct net_device *netdev, bool resuming)
>  	if (err)
>  		goto err_req_irq;
>  

[Severity: High]

This isn't a bug introduced by this patch, but the commit message relies
on the MSI-X to MSI fallback in igb_request_irq(). Is that fallback safe
for the hardware queues that igb_configure() has already enabled?

__igb_open() calls igb_configure() before igb_request_irq(). For each of
the N queues:

- igb_configure_rx_ring() enables RXDCTL and programs the ring base.
- igb_alloc_rx_buffers() advances RDT.
- igb_setup_rctl() sets E1000_RCTL_EN.
- igb_setup_mrqc() spreads RSS over all N queues.

If igb_request_msix() fails:

drivers/net/ethernet/intel/igb/igb_main.c:igb_request_irq() {
    ...
		/* fall back to MSI */
		igb_free_all_tx_resources(adapter);
		igb_free_all_rx_resources(adapter);

		igb_clear_interrupt_scheme(adapter);
		err = igb_init_interrupt_scheme(adapter, false);
    ...
		igb_configure(adapter);
    ...
}

The descriptor rings and Rx pages are freed without any RXDCTL/TXDCTL
write. The second igb_configure() only reconfigures the new, smaller set
of queues. igb_setup_rctl() only disables queue 0:

	/* disable queue 0 to prevent tail write w/o re-config */
	wr32(E1000_RXDCTL(0), 0);

Can queues 1..N-1 stay enabled, with base addresses and posted
descriptors that point at freed memory?

Packets could still be steered there in two ways:

- RSS, until the second igb_setup_mrqc() rewrites RETA.
- ntuple/etype filters with an action queue >= 1, permanently.
  igb_nfc_filter_restore() re-adds them without checking them against the
  new num_rx_queues. The only check is in igb_add_ethtool_nfc_entry().

Would the NIC then DMA packet data and descriptor write-backs into freed
pages?

> -	/* Notify the stack of the actual queue counts. */
> -	err = netif_set_real_num_tx_queues(adapter->netdev,
> -					   adapter->num_tx_queues);
> -	if (err)
> -		goto err_set_queues;
> -
> -	err = netif_set_real_num_rx_queues(adapter->netdev,
> -					   adapter->num_rx_queues);
> -	if (err)
> -		goto err_set_queues;
> +	/* Notify the stack of the actual queue counts. This needs RTNL: on
> +	 * runtime resume igb_rtnl_resume_task() does it.
> +	 */
> +	if (rtnl_held) {
> +		err = netif_set_real_num_queues(netdev, adapter->num_tx_queues,
> +						adapter->num_rx_queues);
> +		if (err)
> +			goto err_set_queues;
> +	}
>  
>  	/* From here on the code is the same as igb_up() */
>  	clear_bit(__IGB_DOWN, &adapter->state);

[Severity: Medium]

Does this fully cover the RTNL assertion on runtime resume? A few lines
further down in __igb_open(), the NAPI loop isn't guarded by rtnl_held:

	for (i = 0; i < adapter->num_q_vectors; i++) {
		napi = &adapter->q_vector[i]->napi;
		napi_enable(napi);
		igb_set_queue_napi(adapter, i, napi);
	}

igb_set_queue_napi() calls netif_queue_set_napi(), which runs
netdev_assert_locked_ops_compat_or_invisible(). igb is a registered
netdev without the ops lock, so this becomes ASSERT_RTNL(). The runtime
resume path is:

igb_runtime_resume()
  __igb_resume(dev, true)
    __igb_open(netdev, true, false)
      igb_set_queue_napi()
        netif_queue_set_napi()

Wouldn't this still print "RTNL: assertion failed" and write
rxq->napi/txq->napi without RTNL? igb_rtnl_resume_task() only restores
the queue counts, not the links between queues and NAPIs.

The later patch in this series, "igb: link queues to NAPIs under RTNL
after runtime resume", appears to fix this. It guards
igb_set_queue_napi() with rtnl_held and calls igb_link_queue_napis() from
igb_rtnl_resume_task(). So the gap only exists between these two commits.
Since this patch carries the Fixes: and stable tags, should the two be
combined?

[ ... ]

> @@ -6638,6 +6660,17 @@ static netdev_tx_t igb_xmit_frame(struct sk_buff *skb,
>  	if (skb_put_padto(skb, 17))
>  		return NETDEV_TX_OK;
>  
> +	/* After a fallback to fewer queues on runtime resume, the stack can
> +	 * use more queues than the device has until igb_rtnl_resume_task()
> +	 * updates it: drop those packets instead of sharing a ring between
> +	 * queues, which aren't serialized with each other.
> +	 */
> +	if (unlikely(skb->queue_mapping >= adapter->num_tx_queues)) {
> +		dev_kfree_skb_any(skb);
> +		dev_core_stats_tx_dropped_inc(netdev);
> +		return NETDEV_TX_OK;
> +	}

[Severity: High]

This isn't a bug introduced by this patch, but this check uses >=, while
igb_save_cbs_params() and igb_save_txtime_params() use >:

drivers/net/ethernet/intel/igb/igb_main.c:igb_save_cbs_params() {
    ...
	if (queue < 0 || queue > adapter->num_tx_queues)
		return -EINVAL;

	ring = adapter->tx_ring[queue];

	ring->cbs_enable = enable;
    ...
}

igb_save_txtime_params() has the same check before:

	ring->launchtime_enable = enable;

On i210, igb_offload_cbs() and igb_offload_txtime() accept queue 0 or 1,
whatever num_tx_queues is:

	if (qopt->queue < 0 || qopt->queue > 1)
		return -EINVAL;

num_tx_queues can be 1 in these cases:

- a single online CPU
- after ethtool -L combined 1
- after the MSI-X to MSI fallback discussed in this commit

In that case, can queue 1 pass both checks and dereference a NULL
tx_ring[1]? That entry is either never assigned or set to NULL by
igb_reset_q_vector().

The netdev has 8 allocated TX queues, and mq_queue_get() only rejects
ntx >= dev->num_tx_queues. So these commands reach igb_setup_tc() with
queue 1:

  tc qdisc add dev X root handle 1: mq
  tc qdisc replace dev X parent 1:2 cbs ... offload 1

An etf qdisc with offload takes the same path.

Should both helpers check queue >= adapter->num_tx_queues instead?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202002317.3140591-1-antonio%40mandelbit.com

  reply	other threads:[~2026-12-03  1:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261202002317.3140591-1-antonio@mandelbit.com>
2026-12-02  0:23 ` [PATCH net v7 1/7] igb: don't wait for RTNL when runtime suspending Antonio Quartulli
2026-12-03  1:04   ` netdev-bot+sashiko
2026-12-02  0:23 ` [PATCH net v7 2/7] igb: don't touch rings that don't exist when disabling an XSK pool Antonio Quartulli
2026-12-03  1:04   ` netdev-bot+sashiko
2026-12-02  0:23 ` [PATCH net v7 3/7] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
2026-12-03  1:04   ` netdev-bot+sashiko [this message]
2026-12-02  0:23 ` [PATCH net v7 4/7] igb: keep the stack's Rx queues that still have an XSK pool Antonio Quartulli
2026-12-03  1:04   ` netdev-bot+sashiko
2026-12-02  0:23 ` [PATCH net v7 5/7] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
2026-12-02  0:23 ` [PATCH net v7 6/7] igb: resume the device before changing XDP or XSK settings Antonio Quartulli
2026-12-03  1:04   ` netdev-bot+sashiko
2026-12-02  0:23 ` [PATCH net v7 7/7] igb: only allow runtime PM if the device can wake up 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=179625985176.3146.14979962176226526203@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=antonio@mandelbit.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hawk@kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=janislacis06@gmail.com \
    --cc=joe@dama.to \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kurt@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=rafael@kernel.org \
    --cc=sdf@fomichev.me \
    --cc=sriram.yagnaraman@ericsson.com \
    --cc=stable@vger.kernel.org \
    --cc=sven.auhagen@voleatech.de \
    /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