Thread View: linux.kernel.netdev
11 messages
11 total messages
Started by Antonio Quartulli
Tue, 24 Nov 2026 23:57
[PATCH net v5 0/6] igb: fix runtime PM resume issues
Author: Antonio Quartulli
Date: Tue, 24 Nov 2026 23:57
Date: Tue, 24 Nov 2026 23:57
80 lines
13153 bytes
13153 bytes
igb can be runtime suspended when the link goes down (with power/control set to auto). Resuming it calls functions that need RTNL without holding it (patches 2 and 4), XDP and XSK changes race with a resume (patch 5), and devices that can't signal a wake-up are suspended anyway, so their port stays down when the link comes back (patch 6). Patch 1 fixes the XSK pool disable path when the device has fewer rings than the stack has queues: a NULL dereference with VFs (a single Tx queue on 82576), or after a fallback from MSI-X to MSI on resume. Patch 3 keeps such queues while they still have an XSK pool, so that the pool can still be disabled. Tested with the 82576 emulated by QEMU, including, with test-only hooks, a runtime resume and a simulated system sleep (the suspend/resume callbacks called directly, as the test kernel has no CONFIG_SUSPEND) with the device forced to come back with MSI and a single queue. Patches 1 and 3 were tested with a zero-copy AF_XDP socket: closing it after enabling a VF oopses (queue 1, stock igb and v3) or warns and leaks (queue 2, v4), and warns after a resume forced to use MSI (v4); patch 5 by closing a socket and attaching an XDP program while runtime suspended. Not tested: real hardware and PME wake-up, a real system sleep, the MSI-X allocation failure itself, the window before the work item runs, SR-IOV with runtime PM, and a device that can wake up. Not run under KASAN. Sashiko also found two pre-existing issues in the XSK queue disable/ enable paths (the Tx NAPI isn't stopped when Rx and Tx don't share a vector; a failed buffer reallocation leaves the queue half torn down); they will be fixed separately. igc has the same issues (see the notes); Joe Damato offered to test on igc, so its fix will be sent separately. Changes in v5: - new patch 3: keep the stack's Rx queues that still have an XSK pool (Janis) - patch 4: cancel the work item before a suspend (Sashiko) - new patch 5: resume the device before changing XDP or XSK settings (Sashiko) - patch 6: check pci_dev_run_wake() when scheduling the suspend (Sashiko) Changes in v4: - patch 1: also handle queues with an Rx but no Tx ring, as with VFs: tear down the Rx ring and skip only the Tx part (Sashiko); subject changed from "don't disable rings ..." to "don't touch rings ..." Changes in v3: - new patch 1 - patch 2: set the real queue counts on system sleep resume and from a work item on runtime resume, and drop packets for queues the device doesn't have until then (Janis, Sashiko) - patch 3 (now 4): link the NAPIs from the same work item Changes in v2: - patch 2 (v2 patch 1): keep setting the queue counts in __igb_open(), only skipping them on resume (Sashiko) - mention the tested hardware in the commit messages v4: https://lore.kernel.org/netdev/20261120210134.133238-1-antonio@mandelbit.com/ v3: https://lore.kernel.org/netdev/20261119140412.163202-1-antonio@mandelbit.com/ v2: https://lore.kernel.org/netdev/20261116153041.3002666-1-antonio@mandelbit.com/ v1: https://lore.kernel.org/netdev/20261113105835.3821433-1-antonio@mandelbit.com/ Antonio Quartulli (6): igb: don't touch rings that don't exist when disabling an XSK pool igb: fix RTNL assertion when resuming from runtime suspend igb: keep the stack's Rx queues that still have an XSK pool igb: link queues to NAPIs under RTNL after runtime resume igb: resume the device before changing XDP or XSK settings igb: only allow runtime PM if the device can wake up drivers/net/ethernet/intel/igb/igb.h | 1 + drivers/net/ethernet/intel/igb/igb_main.c | 144 +++++++++++++++++----- drivers/net/ethernet/intel/igb/igb_xsk.c | 37 ++++-- 3 files changed, 143 insertions(+), 39 deletions(-) -- 2.56.1
[PATCH net v5 1/6] igb: don't touch rings that don't exist when disabling an XSK pool
Author: Antonio Quartulli
Date: Tue, 24 Nov 2026 23:57
Date: Tue, 24 Nov 2026 23:57
118 lines
14212 bytes
14212 bytes
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. This also stops a NULL
dereference when the socket is closed while the device is runtime
suspended, which frees its rings.
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>
---
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 | 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
[PATCH net v5 4/6] igb: link queues to NAPIs under RTNL after runtime resume
Author: Antonio Quartulli
Date: Tue, 24 Nov 2026 23:57
Date: Tue, 24 Nov 2026 23:57
90 lines
12695 bytes
12695 bytes
__igb_open() links queues to NAPIs with netif_queue_set_napi(), which
requires RTNL, but RTNL isn't held when resuming from runtime suspend:
this triggers "RTNL: assertion failed".
Link them in __igb_open() only when RTNL is held, and from the work
item that sets the real queue counts on runtime resume. The links can't
be kept across a suspend, because __igb_shutdown() frees the q_vectors.
A suspend now cancels the work item before freeing them, so it only runs
after the resume that scheduled it allocated them, and it checks
__IGB_DOWN under RTNL for a close in the meantime.
Tested with the 82576 emulated by QEMU.
Fixes: b75a1dea500f ("igb: Link queues to NAPI instances")
Cc: stable@vger.kernel.org # 6.16+
Closes: https://bugzilla.ipfire.org/show_bug.cgi?id=13562
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
v5: cancel the work item before a suspend (Sashiko)
v4: no changes
v3: link the NAPIs from the work item added by the previous patch, and
in __igb_open() whenever RTNL is held (also on system sleep resume);
dropped Joe's Reviewed-by, as the patch changed
v2: no code changes; mention the tested hardware
Note: igc has the same issue: __igc_open() also links queues to NAPIs
(igc_set_queue_napi()) on the RTNL-less runtime resume path. A fix will
follow separately once it has been tested on igc hardware.
drivers/net/ethernet/intel/igb/igb_main.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 6961646..acd9a33 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -4146,8 +4146,19 @@ static int igb_set_real_num_queues(struct igb_adapter *adapter)
return netif_set_real_num_queues(netdev, adapter->num_tx_queues, rxq);
}
+static void igb_link_queue_napis(struct igb_adapter *adapter)
+{
+ int i;
+
+ for (i = 0; i < adapter->num_q_vectors; i++)
+ igb_set_queue_napi(adapter, i, &adapter->q_vector[i]->napi);
+}
+
/* Some settings need RTNL, which isn't held when resuming from runtime
- * suspend: apply them from here instead, if the device is still up.
+ * suspend: apply them from here instead, if the device is still up. A
+ * suspend cancels this work before freeing the q_vectors, so it only runs
+ * after the resume that scheduled it allocated them; checking __IGB_DOWN
+ * under RTNL covers a close in the meantime.
*/
static void igb_rtnl_resume_task(struct work_struct *work)
{
@@ -4160,6 +4171,7 @@ static void igb_rtnl_resume_task(struct work_struct *work)
if (igb_set_real_num_queues(adapter))
netdev_err(adapter->netdev,
"error setting real queue count\n");
+ igb_link_queue_napis(adapter);
}
rtnl_unlock();
}
@@ -4237,7 +4249,8 @@ static int __igb_open(struct net_device *netdev, bool resuming,
for (i = 0; i < adapter->num_q_vectors; i++) {
napi = &adapter->q_vector[i]->napi;
napi_enable(napi);
- igb_set_queue_napi(adapter, i, napi);
+ if (rtnl_held)
+ igb_set_queue_napi(adapter, i, napi);
}
/* Clear any pending interrupts. */
@@ -9548,6 +9561,11 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol;
bool wake;
+ /* Don't let a work item queued by an earlier resume run once the
+ * q_vectors are freed or reallocated
+ */
+ cancel_work_sync(&adapter->rtnl_resume_task);
+
rtnl_lock();
netif_device_detach(netdev);
--
2.56.1
[PATCH net v5 5/6] igb: resume the device before changing XDP or XSK settings
Author: Antonio Quartulli
Date: Tue, 24 Nov 2026 23:57
Date: Tue, 24 Nov 2026 23:57
67 lines
11911 bytes
11911 bytes
igb_xdp() can run while the device is runtime suspended or resuming,
and __igb_resume() rebuilds the queue counts and the rings without
RTNL. igb_xdp_setup() and igb_xsk_pool_setup() can then see a queue
count whose rings don't exist yet (NULL dereference), or a NAPI that
isn't enabled yet (napi_disable() never returns). Changing the XDP
program of a runtime suspended device also opened it twice.
Resume the device for the duration of igb_xdp(), as ethtool does. Like
the other resumes done with RTNL held, this can still deadlock with a
runtime suspend already in progress, which takes RTNL itself; closing
an AF_XDP socket or changing the XDP program is now one of them.
Tested with the 82576 emulated by QEMU by closing a zero-copy AF_XDP
socket and attaching an XDP program while the device is runtime
suspended; the latter no longer warns in __netif_napi_del_locked()
because of the double open. The races themselves weren't reproduced.
Fixes: 9cbc948b5a20 ("igb: add XDP support")
Fixes: 80f6ccf9f116 ("igb: Introduce XSK data structures and helpers")
Cc: stable@vger.kernel.org
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
v5: new patch (Sashiko)
drivers/net/ethernet/intel/igb/igb_main.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index acd9a33..80ae03d 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -2942,16 +2942,28 @@ static int igb_xdp_setup(struct net_device *dev, struct netdev_bpf *bpf)
static int igb_xdp(struct net_device *dev, struct netdev_bpf *xdp)
{
struct igb_adapter *adapter = netdev_priv(dev);
+ int err;
+
+ /* The rings only exist while the device is resumed, and resuming
+ * rebuilds them without RTNL
+ */
+ pm_runtime_get_sync(&adapter->pdev->dev);
switch (xdp->command) {
case XDP_SETUP_PROG:
- return igb_xdp_setup(dev, xdp);
+ err = igb_xdp_setup(dev, xdp);
+ break;
case XDP_SETUP_XSK_POOL:
- return igb_xsk_pool_setup(adapter, xdp->xsk.pool,
- xdp->xsk.queue_id);
+ err = igb_xsk_pool_setup(adapter, xdp->xsk.pool,
+ xdp->xsk.queue_id);
+ break;
default:
- return -EINVAL;
+ err = -EINVAL;
}
+
+ pm_runtime_put(&adapter->pdev->dev);
+
+ return err;
}
int igb_xdp_xmit_back(struct igb_adapter *adapter, struct xdp_buff *xdp)
--
2.56.1
Re: [PATCH net v5 0/6] igb: fix runtime PM resume issues
Author: Janis Edvarts Lacis
Date: Sat, 28 Nov 2026 13:32
Date: Sat, 28 Nov 2026 13:32
83 lines
15215 bytes
15215 bytes
On 25 Nov 00:57, Antonio Quartulli wrote: >igb can be runtime suspended when the link goes down (with >power/control set to auto). Resuming it calls functions that need RTNL >without holding it (patches 2 and 4), XDP and XSK changes race with a >resume (patch 5), and devices that can't signal a wake-up are suspended >anyway, so their port stays down when the link comes back (patch 6). > >Patch 1 fixes the XSK pool disable path when the device has fewer rings >than the stack has queues: a NULL dereference with VFs (a single Tx >queue on 82576), or after a fallback from MSI-X to MSI on resume. Patch >3 keeps such queues while they still have an XSK pool, so that the pool >can still be disabled. > >Tested with the 82576 emulated by QEMU, including, with test-only hooks, >a runtime resume and a simulated system sleep (the suspend/resume >callbacks called directly, as the test kernel has no CONFIG_SUSPEND) >with the device forced to come back with MSI and a single queue. >Patches 1 and 3 were tested with a zero-copy AF_XDP socket: closing it >after enabling a VF oopses (queue 1, stock igb and v3) or warns and >leaks (queue 2, v4), and warns after a resume forced to use MSI (v4); >patch 5 by closing a socket and attaching an XDP program while runtime >suspended. Not tested: real hardware and PME wake-up, a real system >sleep, the MSI-X allocation failure itself, the window before the work >item runs, SR-IOV with runtime PM, and a device that can wake up. Not >run under KASAN. > >Sashiko also found two pre-existing issues in the XSK queue disable/ >enable paths (the Tx NAPI isn't stopped when Rx and Tx don't share a >vector; a failed buffer reallocation leaves the queue half torn down); >they will be fixed separately. > >igc has the same issues (see the notes); Joe Damato offered to test on >igc, so its fix will be sent separately. > >Changes in v5: >- new patch 3: keep the stack's Rx queues that still have an XSK pool > (Janis) >- patch 4: cancel the work item before a suspend (Sashiko) >- new patch 5: resume the device before changing XDP or XSK settings > (Sashiko) >- patch 6: check pci_dev_run_wake() when scheduling the suspend > (Sashiko) > >Changes in v4: >- patch 1: also handle queues with an Rx but no Tx ring, as with VFs: > tear down the Rx ring and skip only the Tx part (Sashiko); subject > changed from "don't disable rings ..." to "don't touch rings ..." > >Changes in v3: >- new patch 1 >- patch 2: set the real queue counts on system sleep resume and from a > work item on runtime resume, and drop packets for queues the device > doesn't have until then (Janis, Sashiko) >- patch 3 (now 4): link the NAPIs from the same work item > >Changes in v2: >- patch 2 (v2 patch 1): keep setting the queue counts in __igb_open(), > only skipping them on resume (Sashiko) >- mention the tested hardware in the commit messages > >v4: https://lore.kernel.org/netdev/20261120210134.133238-1-antonio@mandelbit.com/ >v3: https://lore.kernel.org/netdev/20261119140412.163202-1-antonio@mandelbit.com/ >v2: https://lore.kernel.org/netdev/20261116153041.3002666-1-antonio@mandelbit.com/ >v1: https://lore.kernel.org/netdev/20261113105835.3821433-1-antonio@mandelbit.com/ > >Antonio Quartulli (6): > igb: don't touch rings that don't exist when disabling an XSK pool > igb: fix RTNL assertion when resuming from runtime suspend > igb: keep the stack's Rx queues that still have an XSK pool > igb: link queues to NAPIs under RTNL after runtime resume > igb: resume the device before changing XDP or XSK settings > igb: only allow runtime PM if the device can wake up > > drivers/net/ethernet/intel/igb/igb.h | 1 + > drivers/net/ethernet/intel/igb/igb_main.c | 144 +++++++++++++++++----- > drivers/net/ethernet/intel/igb/igb_xsk.c | 37 ++++-- > 3 files changed, 143 insertions(+), 39 deletions(-) > >-- >2.56.1 > Reviewed-by: Janis Edvarts Lacis <janislacis06@gmail.com>
Re: [PATCH net v5 1/6] igb: don't touch rings that don't exist when disabling an XSK pool
Author: Janis Edvarts Lacis
Date: Sat, 28 Nov 2026 13:36
Date: Sat, 28 Nov 2026 13:36
121 lines
16545 bytes
16545 bytes
On 25 Nov 00:57, Antonio Quartulli wrote:
>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. This also stops a NULL
>dereference when the socket is closed while the device is runtime
>suspended, which frees its rings.
>
>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>
>---
>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 | 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
>
Reviewed-by: Janis Edvarts Lacis <janislacis06@gmail.com>
Re: [PATCH net v5 4/6] igb: link queues to NAPIs under RTNL after runtime resume
Author: Janis Edvarts Lacis
Date: Sat, 28 Nov 2026 13:38
Date: Sat, 28 Nov 2026 13:38
93 lines
15055 bytes
15055 bytes
On 25 Nov 00:57, Antonio Quartulli wrote:
>__igb_open() links queues to NAPIs with netif_queue_set_napi(), which
>requires RTNL, but RTNL isn't held when resuming from runtime suspend:
>this triggers "RTNL: assertion failed".
>
>Link them in __igb_open() only when RTNL is held, and from the work
>item that sets the real queue counts on runtime resume. The links can't
>be kept across a suspend, because __igb_shutdown() frees the q_vectors.
>A suspend now cancels the work item before freeing them, so it only runs
>after the resume that scheduled it allocated them, and it checks
>__IGB_DOWN under RTNL for a close in the meantime.
>
>Tested with the 82576 emulated by QEMU.
>
>Fixes: b75a1dea500f ("igb: Link queues to NAPI instances")
>Cc: stable@vger.kernel.org # 6.16+
>Closes: https://bugzilla.ipfire.org/show_bug.cgi?id=13562
>Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
>---
>v5: cancel the work item before a suspend (Sashiko)
>v4: no changes
>v3: link the NAPIs from the work item added by the previous patch, and
>in __igb_open() whenever RTNL is held (also on system sleep resume);
>dropped Joe's Reviewed-by, as the patch changed
>v2: no code changes; mention the tested hardware
>
>Note: igc has the same issue: __igc_open() also links queues to NAPIs
>(igc_set_queue_napi()) on the RTNL-less runtime resume path. A fix will
>follow separately once it has been tested on igc hardware.
>
> drivers/net/ethernet/intel/igb/igb_main.c | 22 ++++++++++++++++++++--
> 1 file changed, 20 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
>index 6961646..acd9a33 100644
>--- a/drivers/net/ethernet/intel/igb/igb_main.c
>+++ b/drivers/net/ethernet/intel/igb/igb_main.c
>@@ -4146,8 +4146,19 @@ static int igb_set_real_num_queues(struct igb_adapter *adapter)
> return netif_set_real_num_queues(netdev, adapter->num_tx_queues, rxq);
> }
>
>+static void igb_link_queue_napis(struct igb_adapter *adapter)
>+{
>+ int i;
>+
>+ for (i = 0; i < adapter->num_q_vectors; i++)
>+ igb_set_queue_napi(adapter, i, &adapter->q_vector[i]->napi);
>+}
>+
> /* Some settings need RTNL, which isn't held when resuming from runtime
>- * suspend: apply them from here instead, if the device is still up.
>+ * suspend: apply them from here instead, if the device is still up. A
>+ * suspend cancels this work before freeing the q_vectors, so it only runs
>+ * after the resume that scheduled it allocated them; checking __IGB_DOWN
>+ * under RTNL covers a close in the meantime.
> */
> static void igb_rtnl_resume_task(struct work_struct *work)
> {
>@@ -4160,6 +4171,7 @@ static void igb_rtnl_resume_task(struct work_struct *work)
> if (igb_set_real_num_queues(adapter))
> netdev_err(adapter->netdev,
> "error setting real queue count\n");
>+ igb_link_queue_napis(adapter);
> }
> rtnl_unlock();
> }
>@@ -4237,7 +4249,8 @@ static int __igb_open(struct net_device *netdev, bool resuming,
> for (i = 0; i < adapter->num_q_vectors; i++) {
> napi = &adapter->q_vector[i]->napi;
> napi_enable(napi);
>- igb_set_queue_napi(adapter, i, napi);
>+ if (rtnl_held)
>+ igb_set_queue_napi(adapter, i, napi);
> }
>
> /* Clear any pending interrupts. */
>@@ -9548,6 +9561,11 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
> u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol;
> bool wake;
>
>+ /* Don't let a work item queued by an earlier resume run once the
>+ * q_vectors are freed or reallocated
>+ */
>+ cancel_work_sync(&adapter->rtnl_resume_task);
>+
> rtnl_lock();
> netif_device_detach(netdev);
>
>--
>2.56.1
>
Reviewed-by: Janis Edvarts Lacis <janislacis06@gmail.com>
Re: [PATCH net v5 5/6] igb: resume the device before changing XDP or XSK settings
Author: Janis Edvarts Lacis
Date: Sat, 28 Nov 2026 13:38
Date: Sat, 28 Nov 2026 13:38
70 lines
14220 bytes
14220 bytes
On 25 Nov 00:57, Antonio Quartulli wrote:
>igb_xdp() can run while the device is runtime suspended or resuming,
>and __igb_resume() rebuilds the queue counts and the rings without
>RTNL. igb_xdp_setup() and igb_xsk_pool_setup() can then see a queue
>count whose rings don't exist yet (NULL dereference), or a NAPI that
>isn't enabled yet (napi_disable() never returns). Changing the XDP
>program of a runtime suspended device also opened it twice.
>
>Resume the device for the duration of igb_xdp(), as ethtool does. Like
>the other resumes done with RTNL held, this can still deadlock with a
>runtime suspend already in progress, which takes RTNL itself; closing
>an AF_XDP socket or changing the XDP program is now one of them.
>
>Tested with the 82576 emulated by QEMU by closing a zero-copy AF_XDP
>socket and attaching an XDP program while the device is runtime
>suspended; the latter no longer warns in __netif_napi_del_locked()
>because of the double open. The races themselves weren't reproduced.
>
>Fixes: 9cbc948b5a20 ("igb: add XDP support")
>Fixes: 80f6ccf9f116 ("igb: Introduce XSK data structures and helpers")
>Cc: stable@vger.kernel.org
>Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
>---
>v5: new patch (Sashiko)
>
> drivers/net/ethernet/intel/igb/igb_main.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
>diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
>index acd9a33..80ae03d 100644
>--- a/drivers/net/ethernet/intel/igb/igb_main.c
>+++ b/drivers/net/ethernet/intel/igb/igb_main.c
>@@ -2942,16 +2942,28 @@ static int igb_xdp_setup(struct net_device *dev, struct netdev_bpf *bpf)
> static int igb_xdp(struct net_device *dev, struct netdev_bpf *xdp)
> {
> struct igb_adapter *adapter = netdev_priv(dev);
>+ int err;
>+
>+ /* The rings only exist while the device is resumed, and resuming
>+ * rebuilds them without RTNL
>+ */
>+ pm_runtime_get_sync(&adapter->pdev->dev);
>
> switch (xdp->command) {
> case XDP_SETUP_PROG:
>- return igb_xdp_setup(dev, xdp);
>+ err = igb_xdp_setup(dev, xdp);
>+ break;
> case XDP_SETUP_XSK_POOL:
>- return igb_xsk_pool_setup(adapter, xdp->xsk.pool,
>- xdp->xsk.queue_id);
>+ err = igb_xsk_pool_setup(adapter, xdp->xsk.pool,
>+ xdp->xsk.queue_id);
>+ break;
> default:
>- return -EINVAL;
>+ err = -EINVAL;
> }
>+
>+ pm_runtime_put(&adapter->pdev->dev);
>+
>+ return err;
> }
>
> int igb_xdp_xmit_back(struct igb_adapter *adapter, struct xdp_buff *xdp)
>--
>2.56.1
>
Reviewed-by: Janis Edvarts Lacis <janislacis06@gmail.com>
Re: [PATCH net v5 1/6] igb: don't touch rings that don't exist when disabling an XSK pool
Author: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 00:37
Date: Sun, 29 Nov 2026 00:37
329 lines
20014 bytes
20014 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 (3) · Medium: 1 (1) · 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).
- [High] At this commit, the new `qid < adapter->num_rx_queues` check in
igb_xsk_pool_disable() and the num_tx_queues check in…
- [Medium] The new comment in igb_xsk_pool_disable()
(drivers/net/ethernet/intel/igb/igb_xsk.c:161-163) and the commit…
Pre-existing issues:
- [High] The new gate in igb_xsk_pool_disable() is `netif_running() &&
igb_xdp_is_enabled() && qid < adapter->num_rx_queues`…
- [High] igb_txrx_ring_disable() zeroes TXDCTL for tx_ring[qid], then
calls igb_clean_tx_ring() and later igb_configure_tx_ring() on it.
- [High] In igb_xsk_pool_disable(), igb_realloc_rx_buffer_info(rx_ring,
false) can fail with -ENOMEM (vmalloc).
- [Medium] This patch adds igb_xsk_tx_ring() ("With VFs, the device has a
single Tx queue but can have more Rx queues") and changes the pool-…
--
igb: don't touch rings that don't exist when disabling an XSK pool
This patch makes igb_txrx_ring_disable() and igb_txrx_ring_enable() skip
the Tx ring when qid is at or beyond num_tx_queues. It also makes
igb_xsk_pool_disable() skip ring teardown when qid is at or beyond
num_rx_queues, covering 82576 with VFs and the MSI fallback on resume.
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..3b4212a9521e0 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 isn't a bug introduced by this patch, but this helper now treats a
queue that has an Rx ring using the pool and no Tx ring as a supported
state. Does igb_xsk_wakeup() need the same handling?
It still rejects such a queue before it gets to the XDP_WAKEUP_RX branch:
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 a socket bound to queue 1 on 82576, with VFs enabled afterwards.
num_tx_queues becomes 1 while real_num_rx_queues stays 2, and
igb_configure_rx_ring() keeps Rx ring 1 in zero-copy mode. Every
need_wakeup Rx kick for that queue would then fail. Rx would only make
progress on hardware or watchdog interrupts.
igb_xsk_pool_enable() also uses a different validity rule: it checks
num_rx_queues plus both real_num_*_queues.
> 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;
>
[ ... ]
> @@ -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 isn't a bug introduced by this patch, but does the "Rx/Tx share the
same napi context" assumption hold when IGB_FLAG_QUEUE_PAIRS is clear?
igb_set_flag_queue_pairs() leaves the flag clear on 82575/i211. On
82576/i350/i210 it also stays clear whenever rss_queues is at most
max_rss_queues / 2, e.g. 82576 or i350 on a host with 4 or fewer CPUs.
In that case igb_set_interrupt_capability() reserves one vector per Tx
queue, and igb_alloc_q_vectors() allocates the Rx-only vectors first. So
tx_ring[qid] sits on a different NAPI than rx_ring[qid], and that Tx NAPI
is still enabled here.
Three things can schedule that Tx NAPI:
- an interrupt for descriptors completed before TXDCTL was cleared
- the watchdog EICS kick
- igb_xsk_wakeup(XDP_WAKEUP_TX)
It would then run igb_clean_tx_irq() while igb_clean_tx_ring() walks the
same tx_buffer_info entries.
igb_clean_tx_irq() doesn't check IGB_RING_FLAG_TX_DISABLED. Can both
paths free or unmap the same skb or xdp_frame, and both report xsk
completions?
The re-enable side has the same issue. igb_configure_tx_ring(), called
from igb_txrx_ring_enable(), can memset tx_buffer_info and reset the
indices while that NAPI is still walking them.
[ ... ]
> @@ -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.
> + */
[Severity: Medium]
Is this comment still accurate once a resume has completed?
__igb_resume() calls __igb_open(netdev, true), which passes the reduced
counts to the stack:
__igb_open() {
...
/* Notify the stack of the actual queue counts. */
err = netif_set_real_num_tx_queues(adapter->netdev,
adapter->num_tx_queues);
...
err = netif_set_real_num_rx_queues(adapter->netdev,
adapter->num_rx_queues);
...
}
xsk_get_pool_from_qid() checks queue_id against real_num_rx_queues. After
the resume, xsk_get_pool_from_qid(dev, 1) returns NULL, so
igb_xsk_pool_disable() returns at the earlier check:
pool = xsk_get_pool_from_qid(adapter->netdev, qid);
if (!pool)
return -EINVAL;
It never reaches the new num_rx_queues test. xsk_pool_dma_unmap() is
skipped, so the pool's DMA mapping leaks, and xp_disable_drv_zc() hits
its "Failed to disable zero-copy!" WARN. The leak and the WARN predate
this patch.
The new check seems to help only during the resume window itself, or
when __igb_open() fails before netif_set_real_num_*() runs. The same
applies to this part of the commit message:
"and igb can fall back from MSI-X to MSI with a single queue on resume"
Two later patches in this series seem to fix this:
- "igb: fix RTNL assertion when resuming from runtime suspend" stops
lowering the real counts in __igb_open() on runtime resume.
- "igb: keep the stack's Rx queues that still have an XSK pool" adds
igb_set_real_num_queues().
Should the comment and commit message here describe only the cases this
patch handles?
> + 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);
>
[Severity: High]
This isn't a bug introduced by this patch, since the old gate behaved
the same way. Does this check catch states where the rings exist and
num_rx_queues is non-zero, but the rings aren't actually up?
One such state is a failed resume. __igb_resume() first calls
igb_init_interrupt_scheme(adapter, true), which reallocates the rings
and q_vectors and restores num_rx_queues. If __igb_open(netdev, true)
then fails, the error labels free the ring resources, and napi_enable()
is never reached:
err_set_queues:
igb_free_irq(adapter);
err_req_irq:
igb_release_hw_control(adapter);
igb_power_down_link(adapter);
igb_free_all_rx_resources(adapter);
err_setup_rx:
igb_free_all_tx_resources(adapter);
netif_running() stays true. The real queue counts were not lowered
either, so the pool is still found.
Another is PCI error recovery. igb_io_error_detected() calls igb_down(),
which napi_disable()s every q_vector, while netif_running() and the
queue counts stay the same.
Closing a zero-copy socket in either state takes this path:
xp_release_deferred()
rtnl_lock()
ndo_bpf
igb_xsk_pool_disable()
igb_txrx_ring_disable()
napi_disable()
This NAPI is already disabled, or was never enabled. Would
napi_disable_locked() then spin forever with RTNL held?
If napi_disable() did return, igb_txrx_ring_enable() would call:
- igb_configure_tx_ring(), which memsets the NULL tx_buffer_info
- igb_configure_rx_ring(), which writes IGB_RX_DESC(ring, 0) with
ring->desc == NULL
This is still the case at the end of the series. The
pm_runtime_get_sync() added to igb_xdp() later on doesn't help here.
After a failed runtime resume it returns an error that is ignored, and
it doesn't cover the PCI error path.
Would checking test_bit(__IGB_DOWN, &adapter->state) here, as
igb_xsk_wakeup() already does, close this?
[Severity: High]
Can this check race with a runtime resume?
The new num_rx_queues test here and the num_tx_queues test in
igb_xsk_tx_ring() rely on RTNL. __igb_resume(dev, true) rebuilds the same
state without it:
- igb_init_interrupt_scheme() runs before the "if (!rpm) rtnl_lock()"
- __igb_open() also runs without RTNL when rpm is true
igb_set_interrupt_capability() publishes the count:
adapter->num_rx_queues = adapter->rss_queues;
igb_alloc_q_vectors() only fills adapter->rx_ring[] after that, and the
NAPIs are enabled later still, in __igb_open().
Suppose a zero-copy socket is closed while a runtime resume is running
on pm_wq. Can this check pass while rx_ring[qid] is still NULL, so that
igb_txrx_ring_disable() dereferences rx_ring->reg_idx? Or can it pass
while the ring is allocated but its NAPI isn't enabled yet, so that
napi_disable() never returns with RTNL held?
If so, the "socket is closed while the device is runtime suspended" case
from the commit message would still be reachable during the resume
itself.
The later patch "igb: resume the device before changing XDP or XSK
settings" in this series adds pm_runtime_get_sync()/pm_runtime_put()
around igb_xdp(). rpm_resume() waits for a resume that is already in
progress, so the window is closed at the end of the series.
[Severity: High]
This isn't a bug introduced by this patch, but the error path right
after this hunk seems to leave the queue half torn down:
igb_xsk_pool_disable() {
...
xsk_pool_dma_unmap(pool, IGB_RX_DMA_ATTR);
if (if_running) {
err = igb_realloc_rx_buffer_info(rx_ring, false);
if (err)
return err;
igb_txrx_ring_enable(adapter, qid);
}
...
}
Suppose the vmalloc in igb_realloc_rx_buffer_info() fails. By then
igb_txrx_ring_disable() has already:
- zeroed TXDCTL/RXDCTL
- set IGB_RING_FLAG_TX_DISABLED
- disabled the Rx NAPI
- cleaned both rings
None of that is undone.
rx_ring->xsk_pool and tx_ring->xsk_pool also stay set.
xp_disable_drv_zc() only warns on the error, and xp_release_deferred()
goes on to xp_destroy(pool).
Would the next igb_down() then spin in napi_disable() on the
already-disabled NAPI with RTNL held?
When queues aren't paired, can the Tx NAPI, which is still running,
reach the freed pool through igb_clean_tx_irq()?
xsk_pool = READ_ONCE(tx_ring->xsk_pool);
if (xsk_pool) {
if (xsk_frames)
xsk_tx_completed(xsk_pool, xsk_frames);
if (xsk_uses_need_wakeup(xsk_pool))
igb_xsk_pool_enable() has the same pattern. If
igb_realloc_rx_buffer_info() fails there, the rings and NAPI disabled by
igb_txrx_ring_disable() are never re-enabled.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124235723.1135808-1-antonio%40mandelbit.com
Re: [PATCH net v5 5/6] igb: resume the device before changing XDP or XSK settings
Author: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 00:37
Date: Sun, 29 Nov 2026 00:37
162 lines
14198 bytes
14198 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · 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).
- [High] In drivers/net/ethernet/intel/igb/igb_main.c, igb_xdp() calls
pm_runtime_get_sync() at line 2950 and throws away the return value.
- [Medium] igb_xdp() in drivers/net/ethernet/intel/igb/igb_main.c now
calls pm_runtime_get_sync() (line 2950) while its callers hold RTNL.
--
igb: resume the device before changing XDP or XSK settings
This commit wraps igb_xdp() in pm_runtime_get_sync()/pm_runtime_put(), so
XDP program and XSK pool changes run against a resumed device. The goal is
to stop igb_xdp_setup() and igb_xsk_pool_setup() from seeing rings that
don't exist yet, or NAPIs that aren't enabled yet, while __igb_resume()
rebuilds them without RTNL.
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index 25941a6e25b9f..83c88169840ab 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -2942,16 +2942,28 @@ static int igb_xdp_setup(struct net_device *dev, struct netdev_bpf *bpf)
> static int igb_xdp(struct net_device *dev, struct netdev_bpf *xdp)
> {
> struct igb_adapter *adapter = netdev_priv(dev);
> + int err;
> +
> + /* The rings only exist while the device is resumed, and resuming
> + * rebuilds them without RTNL
> + */
> + pm_runtime_get_sync(&adapter->pdev->dev);
[Severity: High]
What happens here if the runtime resume fails? The return value of
pm_runtime_get_sync() is thrown away. Nothing checks netif_device_present()
before igb_xdp_setup() or igb_xsk_pool_setup() runs.
Say __igb_open() fails during the resume, for example with -ENOMEM from
igb_setup_all_rx_resources() or a failure in igb_request_irq(). By then
__igb_resume() has already run igb_init_interrupt_scheme(), so the
q_vectors exist and num_rx_queues > 0. But every error label in
__igb_open() comes before this:
drivers/net/ethernet/intel/igb/igb_main.c:__igb_open() {
...
clear_bit(__IGB_DOWN, &adapter->state);
for (i = 0; i < adapter->num_q_vectors; i++) {
napi = &adapter->q_vector[i]->napi;
napi_enable(napi);
...
}
So the NAPIs still have SCHED/NPSVC set from netif_napi_add(), and the
descriptor memory has been freed. __igb_resume() also returns without
calling netif_device_attach().
Closing a zero-copy AF_XDP socket would then go through:
xp_release_deferred()
rtnl_lock()
xp_clear_dev()
igb_xdp()
pm_runtime_get_sync() <- resume fails, ignored
igb_xsk_pool_setup(pool == NULL)
igb_xsk_pool_disable()
igb_txrx_ring_disable()
napi_disable()
The check in igb_xsk_pool_disable() still passes:
if_running = netif_running(adapter->netdev) &&
igb_xdp_is_enabled(adapter) &&
qid < adapter->num_rx_queues;
Wouldn't napi_disable() spin forever with RTNL held, since that NAPI was
never enabled? Before that, igb_txrx_ring_disable() writes TXDCTL/RXDCTL
on a MAC that was reset and handed back to firmware. If napi_disable() did
return, igb_txrx_ring_enable() would refill rings whose descriptor memory
was freed.
For XDP_SETUP_PROG add/remove with the interface up, igb_close() does
nothing on the non-present device. igb_open() then runs a full open on the
device that failed to resume.
The commit message says the device is resumed "as ethtool does". However,
both __dev_ethtool() and ethnl_ops_begin() check the device after
resuming:
net/ethtool/netlink.c:ethnl_ops_begin() {
...
if (dev->dev.parent)
pm_runtime_get_sync(dev->dev.parent);
if (!netif_device_present(dev) ||
dev->reg_state >= NETREG_UNREGISTERING) {
ret = -ENODEV;
...
}
Should igb_xdp() check the same way? Returning an error on the pool
teardown path may not be enough on its own. xp_disable_drv_zc() WARNs in
that case, and the pool's DMA unmap would be skipped. The disable path may
still need to do its software cleanup when the hardware isn't resumed.
In this tree a failed resume doesn't set power.runtime_error, so each later
pm_runtime_get_sync() retries the resume callback. The direct trigger is a
failed resume inside igb_xdp()'s own pm_runtime_get_sync(). The last patch
in the series ("igb: only allow runtime PM if the device can wake up")
doesn't change igb_xdp().
[Severity: Medium]
Can this deadlock with a runtime suspend that is already in progress?
Every caller that reaches ndo_bpf here holds RTNL:
dev_xdp_attach()
xsk_bind() -> xp_assign_dev()
xp_release_deferred() -> xp_clear_dev()
The igb runtime suspend callback takes RTNL after the PM core has set the
status to RPM_SUSPENDING:
igb_runtime_suspend()
__igb_shutdown()
cancel_work_sync(&adapter->rtnl_resume_task);
rtnl_lock();
While the status is RPM_SUSPENDING, rpm_resume() for a synchronous caller
on a non-irq_safe device waits uninterruptibly on power.wait_queue. The
pm_wq worker waits for RTNL, and the igb_xdp() caller holds RTNL while it
waits for the suspend to finish. Lockdep won't report this.
The commit message mentions this ("closing an AF_XDP socket or changing
the XDP program is now one of them"). The same cycle already exists for
ethtool ops and for igb_open()/igb_close().
Before this patch, igb made no runtime PM calls on two paths:
AF_XDP zero-copy bind and teardown, and XDP program changes when the
interface is down or the program is only swapped. Both paths can now reach
this hang. The last patch in the series only limits when a suspend gets
scheduled. It doesn't remove the rtnl_lock() from the suspend callback.
Is there a way to avoid the synchronous resume under RTNL on these paths?
>
> switch (xdp->command) {
> case XDP_SETUP_PROG:
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124235723.1135808-1-antonio%40mandelbit.com
Re: [PATCH net v5 0/6] igb: fix runtime PM resume issues
Author: Antonio Quartulli
Date: Mon, 30 Nov 2026 13:31
Date: Mon, 30 Nov 2026 13:31
22 lines
10222 bytes
10222 bytes
Hi, On 28/11/2026 14:32, Janis Edvarts Lacis wrote: > Reviewed-by: Janis Edvarts Lacis <janislacis06@gmail.com> Thanks a lot for the review, Janis. However, it seems that sashiko-kung-foo has identified some non-negligible corner cases which may be better fixing (especially on patch 5). I'll check them all out and spin v6. Regards, -- Antonio Quartulli CEO and Co-Founder Mandelbit Srl https://www.mandelbit.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads