Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3C85606A69E for ; Mon, 30 Nov 2026 21:38:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=Ui/QYSTC; dkim=pass (2048-bit key, unprotected) header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=tPGt9tvs Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 966EC607CC; Mon, 30 Nov 2026 21:38:02 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 0c7Qrro3OYAS; Mon, 30 Nov 2026 21:38:01 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp3.osuosl.org 72494607B9 Authentication-Results: smtp3.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1796074681; b=OUcRKKxloQOLXKARAgbQiKmxEImkIrjaTkOR2AoVVodBjFERwd5QcWloVOVPkPJPwNRv RsxAWHjunS2cPSPNxSJ5Yo3MX4quECfhRvWAhOL1n6IBEsFSaCE6jJ0daijFxyDN+rc7Q LF5U105ZzZoPPdc99By5sjqWxp70ybEx7TPNiUOwPkgAtAbmEv8ki/nfkOeLVCPscBa/0 RnhYl5FwOFRN4Nl48T8GdaxShhgYW5JRY3GhvlQjR5DVkA17+KXnN5Ebif604+fwu1jK/ K6yNQy4JwFYHaMFDvN3fsSHdG/5mIjbTBfQfYyQrRCb+UUP+fuUtsL4wcxRHPIfDjqQ== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796074681; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received:Received: DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: X-Rspamd-Queue-Id:X-BeenThere:X-Mailman-Version:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Errors-To; bh=XEYI+GiavhdEaBlenPNtD0YeUYaaVRemvBXNbdB6Qbw=; b=XbVac7SOELG9PKqGZN2R5ZJIn3MHQrH2hn48lzq4ceUVxuwHjtFdiaRooCVJG1F6PWLd rhcRYOlGN9TlfSaD3VpX7n8q4xO+AdiEqVqqUSXV36/znYTU/UpFUpukIcoilTdngpgPg GOfRa4sESYWYrhgZaFsCNhA1NIWkcpy7x9/mSjN4alzfNBH9WdW/0ywpGWkkdmDCBz59h vhk8BEVNjzHS886mQVqKK+FtaV+00+VTE4TwoGO1Rqe6ZnobbShXhz3Cy6Mavv3b2c+sf DeVBeAGJL+3RK/4vxG688a9BuuVRDfwBoQwZwNXDq8OyJLg8dr+RySzWqOHODUx9fFA== ARC-Authentication-Results: i=1; smtp3.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1796074681; bh=XEYI+GiavhdEaBlenPNtD0YeUYaaVRemvBXNbdB6Qbw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Ui/QYSTCGF+08WJlETgabqGqFItndAlvB5ZtuPWNuf8tjg73saIaJ/XAHrVxGYRbL ewyJbxCzFa8M+K76ra+XHzXU6iP9h8oQ51v+CIUAux1t9kZTp7rM11A8G/LISuebFM HVQ640hUvo2D9xBgBP6+rfuqo4kErKFC5u5U0XsSIKRI57fb2DQ/RwYyoYVAEkgKGV cv5X2uOWnEZ9k9b0qkfqwnICEgJNUOzlvNsOffeRjTy+cYFB3aAtZnab//Zdf1Nkdq DF9rfFAx3XUmo+pzCdxk4nSNOzdX39lIIy1b52hImmVDy0LRHi7V0KzCuT43rkwD65 01jbvz7jR3S3w== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp3.osuosl.org (Postfix) with ESMTP id 72494607B9; Mon, 30 Nov 2026 21:38:01 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists1.osuosl.org (Postfix) with ESMTP id B9E29158 for ; Mon, 30 Nov 2026 21:38:00 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 9FBE780F4A for ; Mon, 30 Nov 2026 21:38:00 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 8MffdQdaEUdo for ; Mon, 30 Nov 2026 21:37:59 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp1.osuosl.org 4204880F3C Authentication-Results: smtp1.osuosl.org; arc=none smtp.remote-ip="2001:67c:2050:102:465::112" Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2001:67c:2050:102:465::112; helo=mout-b-112.mailbox.org; envelope-from=antonio@mandelbit.com; receiver= Authentication-Results: smtp1.osuosl.org; dmarc=none (p=none dis=none) header.from=mandelbit.com Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=tPGt9tvs Received: from mout-b-112.mailbox.org (mout-b-112.mailbox.org [IPv6:2001:67c:2050:102:465::112]) by smtp1.osuosl.org (Postfix) with ESMTPS id 4204880F3C for ; Mon, 30 Nov 2026 21:37:58 +0000 (UTC) Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-112.mailbox.org (Postfix) with ESMTPS id 4jdcnZ4C1Wz5wV5; Mon, 30 Nov 2026 22:37:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1796074674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XEYI+GiavhdEaBlenPNtD0YeUYaaVRemvBXNbdB6Qbw=; b=tPGt9tvskHLqCdNITSJEzNpT1ciU0uksGeC/nXT7TzuG8ixc3pYLOpf0riFCPveImHt/OP HH/3Q1n9HkQIa/47KkyLhDpnbqgCuyFreEmswnwAoVhcUsZcSehp9l4qnOZtte7GLBBMO9 gTI0oFOsZr24lFdtHavuvqiTlCSwIGrsnbQEyRvmT6tWiZJVaVud0DcdkmXT6hm536y0+W Vz8mqELaP1M4td99DC/Yfyo8OEVJv6vva3UanRGJ4y72bF33ffO1W4QwyVEMe59aC/PoN7 vwF+xjDv36bbE13IRngWneWFHsvHf+m9VhVogLLxzfyWmWjOc/5orS0VKxlShA== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of antonio@mandelbit.com designates 2001:67c:2050:b231:465::202 as permitted sender) smtp.mailfrom=antonio@mandelbit.com From: Antonio Quartulli To: intel-wired-lan@lists.osuosl.org Cc: Antonio Quartulli , Tony Nguyen , Przemek Kitszel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Janis Edvarts Lacis , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Sriram Yagnaraman , Kurt Kanzenbach , Maciej Fijalkowski , Heiner Kallweit , Joe Damato , "Rafael J. Wysocki" , Sven Auhagen , 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 Message-ID: <20261130213740.3323814-5-antonio@mandelbit.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130213740.3323814-1-antonio@mandelbit.com> References: <20261130213740.3323814-1-antonio@mandelbit.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4jdcnZ4C1Wz5wV5 X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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 Closes: https://lore.kernel.org/netdev/xupy6jbpnziq2qji54zjbvm7neggrwkxg3sfrhlolmrd6ysifl@zptk6ynkbu5f/ Signed-off-by: Antonio Quartulli --- 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