mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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>,
	Heiner Kallweit <hkallweit1@gmail.com>, Joe Damato <joe@dama.to>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Sven Auhagen <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: [PATCH net v6 4/7] igb: keep the stack's Rx queues that still have an XSK pool
Date: Mon, 30 Nov 2026 22:37:34 +0100	[thread overview]
Message-ID: <20261130213740.3323814-5-antonio@mandelbit.com> (raw)
In-Reply-To: <20261130213740.3323814-1-antonio@mandelbit.com>

When igb lowers its queue counts by itself, after a fallback from MSI-X
to MSI on resume or when enabling VFs, xsk_get_pool_from_qid() doesn't
find the pool of a socket bound to a removed queue anymore. Disabling
it then fails ("Failed to disable zero-copy!") and the pool's DMA
mappings are never unmapped.

ethtool refuses to remove a queue that still has an XSK pool, but igb
can't refuse a VF enable or a resume fallback. Keep the real Rx queue
count up to the highest queue that still has a zero-copy XSK pool
instead, so that the pool can still be disabled, and lower it at the
next open. Copy mode pools don't need the driver to be disabled. The
Tx count follows the device: an XSK pool is always bound to both an Rx
and a Tx queue, and the lookup finds it through the Rx one.

Tested with the 82576 emulated by QEMU and a zero-copy AF_XDP socket,
bound to queue 2 when enabling a VF, and to queue 1 across a runtime
resume forced to use MSI with a single queue (with a test hook): closing
it warned and leaked before, not anymore.

Fixes: 80f6ccf9f116 ("igb: Introduce XSK data structures and helpers")
Cc: stable@vger.kernel.org # 6.14+
Reported-by: Janis Edvarts Lacis <janislacis06@gmail.com>
Closes: https://lore.kernel.org/netdev/xupy6jbpnziq2qji54zjbvm7neggrwkxg3sfrhlolmrd6ysifl@zptk6ynkbu5f/
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
v6: only zero-copy pools keep a queue: copy mode pools don't need the
driver to be disabled (Sashiko); dropped Janis's Reviewed-by
v5: new patch (Janis)

 drivers/net/ethernet/intel/igb/igb_main.c | 30 +++++++++++++++++++----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index bf24768..8b8e8c3 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -4129,6 +4129,29 @@ static int igb_sw_init(struct igb_adapter *adapter)
 	return 0;
 }
 
+/* ethtool refuses to remove a queue that still has an XSK pool. igb can't
+ * refuse when it lowers its queue counts by itself, so keep the stack's Rx
+ * queue instead, or a zero-copy pool couldn't be disabled anymore: lower the
+ * count once it's gone, at the next open.
+ */
+static int igb_set_real_num_queues(struct igb_adapter *adapter)
+{
+	struct net_device *netdev = adapter->netdev;
+	unsigned int rxq = adapter->num_rx_queues;
+	struct xsk_buff_pool *pool;
+	unsigned int i;
+
+	for (i = netdev->real_num_rx_queues; i > rxq; i--) {
+		pool = xsk_get_pool_from_qid(netdev, i - 1);
+		if (pool && pool->umem->zc) {
+			rxq = i;
+			break;
+		}
+	}
+
+	return netif_set_real_num_queues(netdev, adapter->num_tx_queues, rxq);
+}
+
 /* Some settings need RTNL, which isn't held when resuming from runtime
  * suspend: apply them from here instead, if the device is still up.
  * Resuming the device first waits for a resume or suspend in progress.
@@ -4142,9 +4165,7 @@ static void igb_rtnl_resume_task(struct work_struct *work)
 	pm_runtime_get_sync(&adapter->pdev->dev);
 	if (!test_bit(__IGB_DOWN, &adapter->state) &&
 	    netif_running(adapter->netdev)) {
-		if (netif_set_real_num_queues(adapter->netdev,
-					      adapter->num_tx_queues,
-					      adapter->num_rx_queues))
+		if (igb_set_real_num_queues(adapter))
 			netdev_err(adapter->netdev,
 				   "error setting real queue count\n");
 	}
@@ -4214,8 +4235,7 @@ static int __igb_open(struct net_device *netdev, bool resuming,
 	 * 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);
+		err = igb_set_real_num_queues(adapter);
 		if (err)
 			goto err_set_queues;
 	}
-- 
2.56.1


  parent reply	other threads:[~2026-11-30 21:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 21:37 [PATCH net v6 0/7] igb: fix runtime PM resume issues Antonio Quartulli
2026-11-30 21:37 ` [PATCH net v6 1/7] igb: don't wait for RTNL when runtime suspending Antonio Quartulli
2026-11-30 21:37 ` [PATCH net v6 2/7] igb: don't touch rings that don't exist when disabling an XSK pool Antonio Quartulli
2026-11-30 21:37 ` [PATCH net v6 3/7] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
2026-11-30 21:37 ` Antonio Quartulli [this message]
2026-11-30 21:37 ` [PATCH net v6 5/7] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
2026-11-30 21:37 ` [PATCH net v6 6/7] igb: resume the device before changing XDP or XSK settings Antonio Quartulli
2026-11-30 21:37 ` [PATCH net v6 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=20261130213740.3323814-5-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=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

all inboxes | Powered by JetHome®