From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.10.208.40 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796074681; b=cf4CUdtuqBiZRSyyoerIqc2YwxVETzoUzypncFDVSEq/QU49wEc0N3B5UakETBK6SYu6 NcoP0vs3BqTudDy5OC/OHGvOpgJLuhXJ5DwRJmcWsi53Bm3Kau3VBIJKbrjNvok0syAn3 b0YcYKDkX9ADYd8L+hL2a61r2me8Jss2+qviIqWD1WXwaChp5xqbVU5j+8OJxLWiVIbor DzxDiEAoUchoDqjEt5iHLJmzl+UhCdVuG1PjXSC1zxnAzQrgMVGKcv18j3Lb0cmswdgVb QjGHZcCWKcsxLRrEIrnMrrWW+kSKGNNnd51NzPX1wNx8s8CF6xbV2QlQMLCSsgzPxlA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796074681; h=DMARC-Filter: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; bh=MEqkuIH0Uttlf4pInxz7Ok5UHDLyQVoc0vrAlDMlGVY=; b=OmYXf0FeFTNfGpl6SDrtgT7kfFnAoh5+97r7O/A3zpvsNKN09n32MyldBfBDa/oNFdzz H73bwMWKPgwVeq5SsRr1Z5M2YZbt19IXkPZsMk1MbUVVZmLXOwCwO6qFhdVNMmlJAlUgv HgmaMUd3dV7FcWAFRy3BGFHhyTW5xrZdnDbDfEZ+G3y0gUGU1KvxuEDE7QEDYLbxY99hy 2IjTN6WEGP2sf4vgTiefSy57GG6EtrA4xzsHnw2Jfpj+csM9D3kx8M2QctcNMrBF11oym ilB/y7IDv1hJdcquEYXHyDM7akMx6yzcb7aM/xi4e3qYHaS1MebFeXEuemFKY+q5zOA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=mandelbit.com; spf=pass smtp.mailfrom=mandelbit.com; dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=YH9Cq6HV; arc=none smtp.remote-ip=195.10.208.40 Received: from mout-b-210.mailbox.org (mout-b-210.mailbox.org [195.10.208.40]) (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 7636F606A686; Mon, 30 Nov 2026 21:38:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7636F606A686 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mandelbit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mandelbit.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=YH9Cq6HV 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-210.mailbox.org (Postfix) with ESMTPS id 4jdcnV4yldzFqYy; Mon, 30 Nov 2026 22:37:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1796074670; 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=MEqkuIH0Uttlf4pInxz7Ok5UHDLyQVoc0vrAlDMlGVY=; b=YH9Cq6HVLQICLzJ4o1uqMcOUSqrgowVyCtzjq2wAK3+v2RJWYn3LPAzJlrBncEdksPNWSO bc7X9OGCuNIBwy8XbNPn6W58gqdAj3EL23L8T7jyFJMWoamIqH+N6YAvZzJSaQaSCbMPAY zipVn+UdsSYJzTl0bTWDBRB4Quj8BUY/yZkREeTl1NbVx5UEoNCVwMtkEuqpM3B1yb5m4e cI4Mo1OwXPLgiE3ByS11uy7pEGpkxAJtINzA70u1mpvkW1joiP63L1K45wfj3eCJg9pkL4 HFOqbW0PxTuvxA2HY/ZCdSO+23gvfNlqjqmthlukeg9xS7N8C9O7qdVgZHQegw== 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 2/7] igb: don't touch rings that don't exist when disabling an XSK pool Date: Mon, 30 Nov 2026 22:37:32 +0100 Message-ID: <20261130213740.3323814-3-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-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4jdcnV4yldzFqYy 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 a runtime suspend frees all rings. 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(), and a NULL Rx ring too if the socket is closed while the device is runtime suspended. 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/ Reviewed-by: Janis Edvarts Lacis Signed-off-by: Antonio Quartulli --- v6: the message and comment name the runtime suspended case instead of the MSI fallback, which only reaches this check with patch 4 (Sashiko); no code changes v5: the message also mentions the runtime suspended case (no code changes) 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 | 38 +++++++++++++++++------- 1 file changed, 27 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..b6234e3 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,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; if (if_running) igb_txrx_ring_disable(adapter, qid); -- 2.56.1