Linux Power Management development
 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 2/7] igb: don't touch rings that don't exist when disabling an XSK pool
Date: Thu, 03 Dec 2026 01:04:09 +0000	[thread overview]
Message-ID: <179625984965.3146.15250464225643049078@kernel.org> (raw)
In-Reply-To: <20261202002317.3140591-3-antonio@mandelbit.com>

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

Critical: 0 · High: 0 (1) · Medium: 1 (4) · 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] At this commit, the new `qid < adapter->num_rx_queues` guard
  in igb_xsk_pool_disable() and the num_tx_queues check in…

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch
  rewrites these exact blocks and keeps the faulty assumption.
- [Medium] At this commit, igb_xsk_pool_disable() decides whether to tear
  down and rebuild the queue with only `netif_running() &&…
- [Medium] This problem wasn't introduced by this patch, but
  igb_xsk_wakeup() rejects any qid >= adapter->num_tx_queues and…
- [Medium] This problem wasn't introduced by this patch, but in
  igb_xsk_pool_disable(), if igb_realloc_rx_buffer_info(rx_ring, false)…
- [Medium] This problem wasn't introduced by this patch, but
  igb_txrx_ring_disable() clears RXDCTL/TXDCTL with posted MMIO writes.

--

igb: don't touch rings that don't exist when disabling an XSK pool

This patch adds igb_xsk_tx_ring(), which returns NULL for a qid beyond
num_tx_queues. igb_txrx_ring_disable() and igb_txrx_ring_enable() now
skip the Tx part when there is no Tx ring. igb_xsk_pool_disable() also
skips the ring teardown entirely when qid >= num_rx_queues, which covers
82576 with VFs and the runtime suspended case.

Link: https://lore.kernel.org/netdev/20261116153041.3002666-2-antonio@mandelbit.com/

> diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c b/drivers/net/ethernet/intel/igb/igb_xsk.c
> index ce4a7b58cad2f..b6234e349ef20 100644
> --- a/drivers/net/ethernet/intel/igb/igb_xsk.c
> +++ b/drivers/net/ethernet/intel/igb/igb_xsk.c
> @@ -31,15 +31,22 @@ static int igb_realloc_rx_buffer_info(struct igb_ring *ring, bool pool_present)
>  	return 0;
>  }
>  
> +/* With VFs, the device has a single Tx queue but can have more Rx queues */
> +static struct igb_ring *igb_xsk_tx_ring(struct igb_adapter *adapter, u16 qid)
> +{
> +	return qid < adapter->num_tx_queues ? adapter->tx_ring[qid] : NULL;
> +}

[Severity: Medium]
This is a pre-existing issue, but with this helper an Rx-only queue can
now keep a zero-copy pool. How does igb_xsk_wakeup() handle such a queue?

igb_xsk_wakeup() {
    ...
	if (qid >= adapter->num_tx_queues)
		return -EINVAL;

	ring = adapter->tx_ring[qid];

	if (!READ_ONCE(ring->xsk_pool))
		return -EINVAL;
    ...
}

Take the scenario from the commit message: a pool is bound to queue 1,
then VFs are enabled, so num_tx_queues == 1. igb_configure_rx_ring()
re-attaches the pool to rx_ring[1].

But every ndo_xsk_wakeup for queue 1 returns -EINVAL before the
XDP_WAKEUP_RX branch. Does that mean the Rx need_wakeup kick never
reaches rx_ring[1]->q_vector?

The two paths also check the qid against different counters.
igb_xsk_pool_enable() uses netdev->real_num_tx_queues and
adapter->num_rx_queues, while igb_xsk_wakeup() uses
adapter->num_tx_queues. Should these agree?

> +
>  static void igb_txrx_ring_disable(struct igb_adapter *adapter, u16 qid)
>  {
> -	struct igb_ring *tx_ring = adapter->tx_ring[qid];
> +	struct igb_ring *tx_ring = igb_xsk_tx_ring(adapter, qid);
>  	struct igb_ring *rx_ring = adapter->rx_ring[qid];
>  	struct e1000_hw *hw = &adapter->hw;
>  
> -	set_bit(IGB_RING_FLAG_TX_DISABLED, &tx_ring->flags);
> -
> -	wr32(E1000_TXDCTL(tx_ring->reg_idx), 0);
> +	if (tx_ring) {
> +		set_bit(IGB_RING_FLAG_TX_DISABLED, &tx_ring->flags);
> +		wr32(E1000_TXDCTL(tx_ring->reg_idx), 0);
> +	}
>  	wr32(E1000_RXDCTL(rx_ring->reg_idx), 0);
>  
>  	synchronize_net();

[Severity: Medium]
This isn't a bug introduced by this patch, but these queue disables are
posted MMIO writes that are never flushed or polled. Are synchronize_net()
and napi_disable() enough to make sure the queue has stopped DMA? The rings
are cleaned right after, and igb_xsk_pool_disable() then calls
xsk_pool_dma_unmap().

igb_down() in the same driver does this after disabling Rx and Tx:

	/* flush both disables and wait for them to finish */
	wrfl();
	usleep_range(10000, 11000);

igb_rx_fifo_flush_82575() also polls RXDCTL.

If the queue hasn't actually stopped, could a late descriptor write-back
or packet DMA land in a UMEM buffer already returned to the pool? Could it
hit an IOVA that was just unmapped?

> @@ -47,24 +54,27 @@ static void igb_txrx_ring_disable(struct igb_adapter *adapter, u16 qid)
>  	/* Rx/Tx share the same napi context. */
>  	napi_disable(&rx_ring->q_vector->napi);
>  
> -	igb_clean_tx_ring(tx_ring);
> +	if (tx_ring) {
> +		igb_clean_tx_ring(tx_ring);
> +		memset(&tx_ring->tx_stats, 0, sizeof(tx_ring->tx_stats));
> +	}

[Severity: High]
This is a pre-existing issue, but since these blocks are being rewritten:
does the "Rx/Tx share the same napi context" assumption hold when
IGB_FLAG_QUEUE_PAIRS is clear?

igb_set_flag_queue_pairs() never sets the flag on 82575/i211. On
82576/82580/i350/i354/i210 it clears the flag when
rss_queues <= max_rss_queues / 2.

With the flag clear, igb_set_interrupt_capability() reserves separate Tx
vectors. igb_alloc_q_vectors() then puts rx_ring[qid] and tx_ring[qid] on
different q_vectors.

The driver's own igb_xsk_wakeup() treats the sharing as conditional:

		/* If IGB_FLAG_QUEUE_PAIRS is active, the q_vector
		 * and NAPI is shared between RX and TX.

Only rx_ring->q_vector->napi is disabled here. Can the Tx vector keep
running this:

igb_poll()
  igb_clean_tx_irq(q_vector, budget)

while this path runs igb_clean_tx_ring(tx_ring) on the same ring?
IGB_RING_FLAG_TX_DISABLED only stops igb_xmit_zc() and
igb_xmit_frame_ring(), not the completion loop.

Both loops start from tx_ring->next_to_clean. Could skbs or xdp frames be
freed twice, or the same DMA mapping be unmapped twice? Could
netdev_tx_reset_queue() race netdev_tx_completed_queue() and hit this
BUG_ON in dql_completed():

	BUG_ON(count > num_queued - dql->num_completed);

There is a related problem in igb_txrx_ring_enable().
igb_configure_tx_ring() resets TDH/TDT and memsets tx_buffer_info while
the Tx NAPI is still live.

Could this also napi_disable()/napi_enable() tx_ring->q_vector->napi when
it differs from the Rx one? This is unchanged at the end of the series.

[ ... ]

> @@ -148,7 +158,13 @@ static int igb_xsk_pool_disable(struct igb_adapter *adapter, u16 qid)
>  		return -EINVAL;
>  
>  	rx_ring = adapter->rx_ring[qid];
> -	if_running = netif_running(adapter->netdev) && igb_xdp_is_enabled(adapter);
> +	/* The stack can know more queues than the device has, e.g. while
> +	 * runtime suspended, which frees the rings: skip the rings it
> +	 * doesn't have.
> +	 */
> +	if_running = netif_running(adapter->netdev) &&
> +		     igb_xdp_is_enabled(adapter) &&
> +		     qid < adapter->num_rx_queues;

[Severity: Medium]
This is a pre-existing issue rather than something introduced here. The
new gate catches a missing ring, but not a ring that exists and has no
resources.

What happens if __igb_open() failed earlier? That can happen in
__igb_resume(), or after igb_close() in igb_xdp_setup(),
igb_sriov_reinit() or igb_reinit_queues().

The __igb_open() unwind frees ring->desc and the tx/rx buffer_info arrays.
It leaves these in place:

  - num_rx_queues > 0
  - the ring structs, still allocated
  - __LINK_STATE_START, still set
  - the NAPI, never enabled

Closing a zero-copy socket in that state still calls
igb_txrx_ring_disable(). netif_napi_add() left SCHED|NPSVC set, so
wouldn't napi_disable() spin forever with RTNL held?

If it got past that, igb_txrx_ring_enable() would dereference NULL in two
places:

  - igb_configure_tx_ring(), in the memset of tx_buffer_info
  - igb_configure_rx_ring(), at IGB_RX_DESC(ring, 0)

igb_xsk_pool_enable() has the same gap.

The later patch in this series, "igb: resume the device before changing
XDP or XSK settings", seems to fix both paths:

  - it adds "&& rx_ring->desc" to this gate
  - igb_xsk_pool_enable() returns -ENODEV when
    !adapter->rx_ring[qid]->desc
  - a runtime PM reference is held across igb_xdp()

[Severity: Medium]
Can this check, and the num_tx_queues check in igb_xsk_tx_ring(), change
under a concurrent runtime resume?

This path holds only RTNL. __igb_resume() with rpm=true does not take
RTNL. It rebuilds num_rx_queues, num_tx_queues and
adapter->rx_ring[]/tx_ring[] through igb_init_interrupt_scheme().

igb_set_interrupt_capability() publishes the count first:

	adapter->num_rx_queues = adapter->rss_queues;

The ring pointers are only filled in later by igb_alloc_q_vector(), and
NAPI is enabled later still, in __igb_open(). rx_ring is also loaded
before num_rx_queues is checked.

Suppose a zero-copy socket is closed during that window. Could this check
pass and the code still dereference a NULL rx_ring? Could it call
napi_disable() on a NAPI that isn't enabled yet and spin with RTNL held?

The later patch in this series, "igb: resume the device before changing
XDP or XSK settings", appears to close this. It calls
pm_runtime_get_sync() in igb_xdp() before igb_xsk_pool_setup().

>  	if (if_running)
>  		igb_txrx_ring_disable(adapter, qid);
>  

[Severity: Medium]
This isn't a bug introduced by this patch, but look further down in
igb_xsk_pool_disable():

	if (if_running) {
		err = igb_realloc_rx_buffer_info(rx_ring, false);
		if (err)
			return err;

		igb_txrx_ring_enable(adapter, qid);
	}

When igb_realloc_rx_buffer_info() fails, igb_txrx_ring_disable() and
xsk_pool_dma_unmap() have already run, but igb_txrx_ring_enable() is
skipped. Doesn't that leave the queue in this state?

  - RXDCTL/TXDCTL at 0
  - IGB_RING_FLAG_TX_DISABLED set
  - the q_vector NAPI disabled
  - rx_ring->xsk_pool and tx_ring->xsk_pool pointing at a pool that the
    XSK core then frees

The next igb_down() would then disable the same NAPI again:

igb_down()
  napi_disable(&adapter->q_vector[i]->napi)

That call never returns, and RTNL stays held. igb_xsk_pool_enable() has the
same pattern: on a realloc failure it only unmaps the pool and returns.
This is unchanged at the end of the series.

-- 
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: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  0:23 [PATCH net v7 0/7] igb: fix runtime PM resume issues Antonio Quartulli
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 [this message]
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
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=179625984965.3146.15250464225643049078@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