From: Antonio Quartulli <antonio@mandelbit.com>
To: intel-wired-lan@lists.osuosl.org
Cc: Antonio Quartulli <antonio@mandelbit.com>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.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>,
Janis Edvarts Lacis <janislacis06@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Stanislav Fomichev <sdf@fomichev.me>,
Sriram Yagnaraman <sriram.yagnaraman@ericsson.com>,
Kurt Kanzenbach <kurt@linutronix.de>,
Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH net v4 1/4] igb: don't touch rings that don't exist when disabling an XSK pool
Date: Fri, 20 Nov 2026 22:01:29 +0100 [thread overview]
Message-ID: <20261120210134.133238-2-antonio@mandelbit.com> (raw)
In-Reply-To: <20261120210134.133238-1-antonio@mandelbit.com>
xsk_get_pool_from_qid() checks the queue id against the stack's real
queue counts, which can be higher than the number of rings the device
has: on 82576, enabling VFs leaves a single Tx queue while keeping two
Rx queues, and igb can fall back from MSI-X to MSI with a single queue
on resume. Disabling the pool of such a queue, e.g. one bound to queue 1
before enabling VFs, then passes a NULL Tx ring to
igb_txrx_ring_disable().
Only disable and re-enable the rings the device has: skip the queue if
it has no Rx ring, and only the Tx part if it has no Tx ring, so that
an Rx ring using the pool still stops using it.
Tested with the 82576 emulated by QEMU and a zero-copy AF_XDP socket on
queue 1: closing it after enabling a VF no longer oopses and the Rx ring
no longer references the pool afterwards (checked with a debug print, as
QEMU doesn't spread traffic over the PF queues with VFs), and without
VFs queue 1 keeps receiving after the close. Not run under KASAN.
Fixes: 80f6ccf9f116 ("igb: Introduce XSK data structures and helpers")
Cc: stable@vger.kernel.org # 6.14+
Link: https://lore.kernel.org/netdev/20261116153041.3002666-2-antonio@mandelbit.com/
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
v4: also handle queues with an Rx but no Tx ring, as with VFs (Sashiko):
tear down the Rx ring and skip only the Tx part; tested with a
zero-copy AF_XDP socket; subject was "don't disable rings that don't exist
..."
v3: new patch.
drivers/net/ethernet/intel/igb/igb_xsk.c | 37 +++++++++++++++++-------
1 file changed, 26 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c b/drivers/net/ethernet/intel/igb/igb_xsk.c
index ce4a7b5..3b4212a 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;
+}
+
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();
@@ -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));
+ }
igb_clean_rx_ring(rx_ring);
-
memset(&rx_ring->rx_stats, 0, sizeof(rx_ring->rx_stats));
- memset(&tx_ring->tx_stats, 0, sizeof(tx_ring->tx_stats));
}
static void igb_txrx_ring_enable(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];
- igb_configure_tx_ring(adapter, tx_ring);
+ if (tx_ring)
+ igb_configure_tx_ring(adapter, tx_ring);
igb_configure_rx_ring(adapter, rx_ring);
synchronize_net();
- clear_bit(IGB_RING_FLAG_TX_DISABLED, &tx_ring->flags);
+ if (tx_ring)
+ clear_bit(IGB_RING_FLAG_TX_DISABLED, &tx_ring->flags);
/* call igb_desc_unused which always leaves
* at least 1 descriptor unused to make sure
@@ -148,7 +158,12 @@ 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. after a
+ * fallback to fewer queues on resume: skip the rings it doesn't have.
+ */
+ if_running = netif_running(adapter->netdev) &&
+ igb_xdp_is_enabled(adapter) &&
+ qid < adapter->num_rx_queues;
if (if_running)
igb_txrx_ring_disable(adapter, qid);
--
2.56.1
next prev parent reply other threads:[~2026-11-20 21:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 21:01 [PATCH net v4 0/4] igb: fix runtime PM resume issues Antonio Quartulli
2026-11-20 21:01 ` Antonio Quartulli [this message]
2026-11-20 21:01 ` [PATCH net v4 2/4] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
2026-11-20 21:01 ` [PATCH net v4 3/4] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
2026-11-20 21:01 ` [PATCH net v4 4/4] 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=20261120210134.133238-2-antonio@mandelbit.com \
--to=antonio@mandelbit.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.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=intel-wired-lan@lists.osuosl.org \
--cc=janislacis06@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=kurt@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=sdf@fomichev.me \
--cc=sriram.yagnaraman@ericsson.com \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®