igb: fix runtime PM resume issues
Subsystems (5)
v4 cover igb: fix runtime PM resume issues
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 3), and devices that can't signal a wake-up are suspended anyway, so their port stays down when the link comes back (patch 4). 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.
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. 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, and SR-IOV with runtime PM. Patch 1 was tested with a zero-copy AF_XDP socket on queue 1: closing it after enabling a VF oopses in igb_txrx_ring_disable() with stock igb and v3, not with v4, and the Rx ring then no longer references the pool. Not run under KASAN.
igc has the same issues (see the notes); Joe Damato offered to test on igc, so its fix will be sent separately.
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: 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
v3: https://lore.kernel.org/netdev/[email protected]/
v2: https://lore.kernel.org/netdev/[email protected]/
v1: https://lore.kernel.org/netdev/[email protected]/
Antonio Quartulli (4):
igb: don't touch rings that don't exist when disabling an XSK pool
igb: fix RTNL assertion when resuming from runtime suspend
igb: link queues to NAPIs under RTNL after runtime resume
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 | 96 +++++++++++++++++------ drivers/net/ethernet/intel/igb/igb_xsk.c | 37 ++++++--- 3 files changed, 100 insertions(+), 34 deletions(-)
Signature · 1 line
2.56.1
PATCH v4 1/4 igb: don't touch rings that don't exist when disabling an XSK pool
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.
---
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(-)
drivers/net/ethernet/intel/igb/igb_xsk.c +26 -11
@@ -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);
Signature · 1 line
2.56.1
Re: [PATCH net v4 1/4] igb: don't touch rings that don't exist when disabling an XSK pool
Quoted 8 lines · Antonio Quartulli
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 toigb_txrx_ring_disable().
Quoted 4 lines
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.
What happens if a pool is bound to, say, queue 1 and the socket stays open across a runtime resume that falls back from MSI-X to MSI (queue 1 becomes invalid)?
If the socket is closed after igb_rtnl_resume_task() has reduced both real queue counts to one, xsk_get_pool_from_qid() will return NULL for queue 1. As I read it, igb_xsk_pool_disable() then returns -EINVAL before doing the cleanup and resources get leaked.
I may be mistaken here, if so, please let me know :)
Best regards,
Janis
Re: [PATCH net v4 1/4] igb: don't touch rings that don't exist when disabling an XSK pool
Quoted 14 lines · Janis Edvarts Lacis
Quoted 8 lines · Antonio Quartulli
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 toigb_txrx_ring_disable().Quoted 4 lines
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.
Quoted 8 lines
What happens if a pool is bound to, say, queue 1 and the socket stays open across a runtime resume that falls back from MSI-X to MSI (queue 1 becomes invalid)?
If the socket is closed after
igb_rtnl_resume_task()has reduced both real queue counts to one,xsk_get_pool_from_qid()will return NULL for queue 1. As I read it,igb_xsk_pool_disable()then returns-EINVALbefore doing the cleanup and resources get leaked.I may be mistaken here, if so, please let me know :)
Hi Janis,
actually you're not mistaken, thanks for spotting it.
Once the real Rx queue count is lowered below a queue with a bound XSK pool, xsk_get_pool_from_qid() no longer finds the pool, the disable fails ("Failed to disable zero-copy!") and the pool's DMA mappings are never unmapped.
igb already does this today (it lowers the counts on runtime resume, just without RTNL), and so does any shrink done by the driver itself (e.g. SR-IOV reinit), so it's worth fixing here.
In v5 igb I will follow what ethtool does for channel changes: when the driver lowers its queue counts, it keeps the real Rx count up to the highest queue that still has an XSK pool, so the pool can still be disabled and unmapped (the rings are skipped as they don't exist). The Tx count follows the device, and the Rx count is lowered at the next open.
This said, I will first wait for Sashiko to report any other potential issue and then I'll work on v5.
Best regards,
Signature · 5 lines
Antonio Quartulli CEO and Co-Founder Mandelbit Srl https://www.mandelbit.com
[email protected]
AI reviewRe: [PATCH net v4 1/4] igb: don't touch rings that don't exist when disabling an XSK pool
In reply to Antonio QuartulliThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 1 (2) · Medium: 0 · 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] The new qid < adapter->num_rx_queues guard in igb_xsk_pool_disable() (and qid < adapter->num_tx_queues in…
Pre-existing issues:
- [High] igb_txrx_ring_disable() and igb_txrx_ring_enable() in drivers/net/ethernet/intel/igb/igb_xsk.c only stop and restart…
- [High] On error, igb_xsk_pool_disable() returns early with the queue half torn down.
--
igb: don't touch rings that don't exist when disabling an XSK pool
This commit makes igb_txrx_ring_disable() and igb_txrx_ring_enable() skip the Tx ring when qid is not below num_tx_queues. It also makes igb_xsk_pool_disable() skip the ring teardown when qid is not below num_rx_queues. The goal is to stop passing a NULL ring when the stack knows about more queues than the device has, for example on 82576 with VFs or after an MSI fallback on resume.
Quoted 14 lines
drivers/net/ethernet/intel/igb/igb_xsk.c +6
-0@@ -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 ; +} +
[ ... ]
drivers/net/ethernet/intel/igb/igb_xsk.c static void igb_txrx_ring_disable(struct igb_adapter *adapter, u16 qid) · line 60
Quoted 9 lines
drivers/net/ethernet/intel/igb/igb_xsk.c +4
-1@@ -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 always hold here?
igb_set_flag_queue_pairs() only sets IGB_FLAG_QUEUE_PAIRS in some cases:
if (adapter->rss_queues > (max_rss_queues / 2)) adapter->flags |= IGB_FLAG_QUEUE_PAIRS; else adapter->flags &= ~IGB_FLAG_QUEUE_PAIRS;
Without the flag, igb_alloc_q_vectors() gives each Rx ring its own vector. The Tx rings then sit on separate Tx-only vectors, each with its own NAPI. Examples are an i350 or 82576 without VFs on a machine with 4 or fewer CPUs, or an i210 with 2 queues. The comment in igb_xsk_wakeup() in this same file says the NAPI is only shared "If IGB_FLAG_QUEUE_PAIRS is active".
In that setup, napi_disable(&rx_ring->q_vector->napi) leaves the Tx ring's NAPI running. It can still be scheduled by late write-back interrupts or by the watchdog's EICS kick. igb_poll() on that vector then does:
if (q_vector->tx.ring) clean_complete = igb_clean_tx_irq(q_vector, budget);
Also, igb_clean_tx_irq() does not check IGB_RING_FLAG_TX_DISABLED.
Can igb_clean_tx_irq() and igb_clean_tx_ring() then walk the same entries from tx_ring->next_to_clean at the same time? Neither one clears tx_buffer->skb or xdpf. So napi_consume_skb() or xdp_return_frame() on one side, and dev_kfree_skb_any() or xdp_return_frame() on the other, could free the same skb or xdp_frame twice.
igb_clean_tx_irq() could also write back a stale next_to_clean after igb_clean_tx_ring() has reset it to 0. igb_configure_tx_ring() in igb_txrx_ring_enable() does not reset that index. It does memset tx_buffer_info and rewrite TDH/TDT while the Tx NAPI may still be polling.
The patch keeps this flow for every qid that has a Tx ring.
[ ... ]
drivers/net/ethernet/intel/igb/igb_xsk.c static int igb_xsk_pool_disable(struct igb_adapter *adapter, u16 qid) · line 166
Quoted 11 lines
drivers/net/ethernet/intel/igb/igb_xsk.c +6
-1@@ -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;
[Severity: High]
Is this check enough for the resume case named in the comment?
The check reads num_rx_queues under RTNL, but __igb_resume() rebuilds that state without RTNL. It calls igb_init_interrupt_scheme() before rtnl_lock(), and for runtime PM it never takes RTNL. Inside that call, igb_set_interrupt_capability() publishes:
adapter->num_rx_queues = adapter->rss_queues;
This happens before igb_alloc_q_vectors() fills in adapter->rx_ring[i] and adapter->tx_ring[i]. Suspend had already set those to NULL through igb_free_q_vectors(). netif_running() stays true across suspend, and adapter->xdp_prog is kept.
Suppose an XSK pool teardown runs under RTNL while a runtime resume is in progress on pm_wq. The teardown could come from closing a zero-copy socket, or from xp_release_deferred(). Could it see qid < num_rx_queues while adapter->rx_ring[qid] is still NULL? If so, igb_txrx_ring_disable() would dereference NULL:
wr32(E1000_RXDCTL(rx_ring->reg_idx), 0);
The num_tx_queues and tx_ring[] read in igb_xsk_tx_ring() has the same race.
There is also a slightly later window where the ring exists but its NAPI has not been enabled yet. Would napi_disable() then spin while holding RTNL and the netdev lock? Meanwhile, __igb_open() in the resume path would be waiting for the netdev lock in napi_enable() (runtime PM) or for RTNL (system resume).
The later patches in this series ("igb: fix RTNL assertion when resuming from runtime suspend" and "igb: link queues to NAPIs under RTNL after runtime resume") still leave igb_init_interrupt_scheme() outside RTNL. So this race seems to remain at the end of the series.
drivers/net/ethernet/intel/igb/igb_xsk.c static int igb_xsk_pool_disable(struct igb_adapter *adapter, u16 qid) · line 169
Quoted 3 lines
drivers/net/ethernet/intel/igb/igb_xsk.c +0
-0if (if_running)igb_txrx_ring_disable (adapter, qid);
[Severity: High]
This is a pre-existing issue, but the error path just after this hunk in igb_xsk_pool_disable() returns with the queue half torn down:
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);
}If the vmalloc() in igb_realloc_rx_buffer_info() fails, igb_txrx_ring_enable() is never called. That leaves:
- the Rx q_vector NAPI disabled
- IGB_RING_FLAG_TX_DISABLED set
- rx_ring->xsk_pool and tx_ring->xsk_pool pointing at the pool that is about to be freed
- rx_buffer_info_zc still attached to the ring
Can the next igb_down() then hang? It can come from close, reset, an XDP program change or suspend. igb_down() calls napi_disable() on every q_vector, and napi_disable_locked() never exits on a NAPI that is already disabled:
while (val & (NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC)) {
usleep_range(20, 200);
val = READ_ONCE(n->state);
}This loop runs with RTNL and the netdev lock held.
Without queue pairs, the Tx NAPI keeps running. Could it read the stale tx_ring->xsk_pool through igb_clean_tx_irq() after the pool is freed?
igb_xsk_pool_enable() has the same pattern. When igb_realloc_rx_buffer_info(rx_ring, true) fails, it unmaps the DMA and returns with the rings stopped and the NAPI disabled.
With this patch, the Rx-only teardown also goes through this error path.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120210134.133238-1-antonio%40mandelbit.com
Re: [PATCH net v4 1/4] igb: don't touch rings that don't exist when disabling an XSK pool
Quoted 5 lines · On 24/11/2026 22:38, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 1 (2) · Medium: 0 · Low: 0
Quoted 9 lines
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] The new
qid < adapter->num_rx_queuesguard inigb_xsk_pool_disable()(andqid < adapter->num_tx_queuesin…
The race with a runtime resume is real, though it predates this patch:
v5 adds a patch that resumes the device for the duration of igb_xdp(), which also covers the same race in igb_xdp_setup().
Quoted 6 lines
Pre-existing issues:
- [High]igb_txrx_ring_disable()andigb_txrx_ring_enable()indrivers/net/ethernet/intel/igb/igb_xsk.conly stop and restart…
- [High] On error,igb_xsk_pool_disable()returns early with the queue half torn down.
The two pre-existing issues are real too (the Tx NAPI isn't stopped when Rx and Tx don't share a vector, and a failed buffer reallocation leaves the queue half torn down). They're independent from this series, so I'll fix them separately. The zero-copy tests ran without queue pairs and didn't hit the first one
Regards,
Signature · 5 lines
Antonio Quartulli CEO and Co-Founder Mandelbit Srl https://www.mandelbit.com
PATCH v4 2/4 igb: fix RTNL assertion when resuming from runtime suspend
In reply to Antonio QuartulliSince commit ac8c58f5b535 ("igb: fix deadlock caused by taking RTNL in RPM resume path") __igb_resume() doesn't take RTNL for runtime resume, but __igb_open() still calls netif_set_real_num_{tx,rx}_queues(), which require it. An asynchronous runtime resume (e.g. after the link comes back) then triggers "RTNL: assertion failed".
Only set the real queue counts in __igb_open() when RTNL is held (open and system sleep resume), and set them from a work item taking RTNL on runtime resume. Until it runs, after a fallback to fewer queues on resume (MSI-X to MSI), the stack can use queues the device doesn't
have: drop those packets in igb_xmit_frame() instead of mapping several stack queues, each with its own xmit lock, onto the same ring. The stack can't be kept off those queues instead, as __igb_open() and netif_device_attach() start all of them and changing the count needs RTNL.
Tested with the 82576 emulated by QEMU.
---
v4: no changes
v3:
- set the real queue counts when RTNL is held (open and system sleep resume), and from a work item on runtime resume, instead of not at all on resume (Janis, Sashiko)
- until then, drop packets for queues the device doesn't have
- stable: netif_set_real_num_queues() needs 5.15+ and dev_core_stats_tx_dropped_inc() 5.18+; older backports can use the separate tx/rx calls and netdev->stats.tx_dropped
v2:
- keep setting the queue counts in __igb_open() after igb_request_irq(), only skipping them on resume (Sashiko)
- drop the reference to igc
Note: igc has the same issue: it sets the real queue counts only in igc_open(), before requesting the IRQs, and never on resume. A fix will follow separately once it has been tested on igc hardware (Joe offered to test).
drivers/net/ethernet/intel/igb/igb.h | 1 + drivers/net/ethernet/intel/igb/igb_main.c | 73 ++++++++++++++++------- 2 files changed, 54 insertions(+), 20 deletions(-)
drivers/net/ethernet/intel/igb/igb.h +1 -0
@@ -586,6 +586,7 @@ struct igb_adapter {struct work_struct reset_task;struct work_struct watchdog_task; +struct work_struct rtnl_resume_task;bool fc_autoneg;u8 tx_timeout_factor;struct timer_list blink_timer;
drivers/net/ethernet/intel/igb/igb_main.c +53 -20
137 lines not on this page · raw message
Signature · 1 line
2.56.1
PATCH v4 3/4 igb: link queues to NAPIs under RTNL after runtime resume
In reply to Antonio Quartulli__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. These are only freed while __IGB_DOWN is set, which is cleared once they are allocated again, so the work item checks __IGB_DOWN under RTNL.
Tested with the 82576 emulated by QEMU.
---
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 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +14 -2
@@ -4126,8 +4126,18 @@ static int igb_sw_init(struct igb_adapter *adapter)return 0 ; } +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. The +* q_vectors are only freed while __IGB_DOWN is set, which is cleared once +* they are allocated again, so checking it under RTNL is safe. */ static void igb_rtnl_resume_task (struct work_struct *work) {
@@ -4142,6 +4152,7 @@ static void igb_rtnl_resume_task(struct work_struct *work) adapter->num_rx_queues))netdev_err (adapter->netdev,"error setting real queue count\n" ); +igb_link_queue_napis (adapter); }rtnl_unlock (); }
@@ -4220,7 +4231,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. */
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH net v4 3/4] igb: link queues to NAPIs under RTNL after runtime resume
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · 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).
- [Medium] igb_rtnl_resume_task() now calls igb_link_queue_napis(), which reads adapter->num_q_vectors and dereferences adapter->q_vector[i]…
Pre-existing issues:
- [Medium] This problem wasn't introduced by this patch, but igc has the same bug.
--
igb: link queues to NAPIs under RTNL after runtime resume
This patch stops __igb_open() from calling netif_queue_set_napi() when RTNL isn't held, which is the case on runtime resume. The queues are linked to their NAPIs from igb_rtnl_resume_task() instead, and that work item uses an __IGB_DOWN check under RTNL to decide the q_vectors are valid.
Quoted 25 lines
drivers/net/ethernet/intel/igb/igb_main.c +11
-1@@ -4125,8 +4125,18 @@ static int igb_sw_init(struct igb_adapter *adapter)return 0 ; } +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. The +* q_vectors are only freed while __IGB_DOWN is set, which is cleared once +* they are allocated again, so checking it under RTNL is safe. */ static void igb_rtnl_resume_task (struct work_struct *work) {
drivers/net/ethernet/intel/igb/igb_main.c static void igb_rtnl_resume_task(struct work_struct *work) · line 4157
Quoted 7 lines
drivers/net/ethernet/intel/igb/igb_main.c +1
-0@@ -4141,6 +4151,7 @@ static void igb_rtnl_resume_task(struct work_struct *work) adapter->num_rx_queues))netdev_err (adapter->netdev,"error setting real queue count\n" ); +igb_link_queue_napis (adapter); }rtnl_unlock (); }
[Severity: Medium]
Is checking __IGB_DOWN under RTNL enough to make the q_vector accesses in igb_link_queue_napis() safe? The free paths all hold RTNL, but on runtime resume the publish side does not:
igb_runtime_resume()
__igb_resume(dev, rpm=true)
igb_init_interrupt_scheme() /* stores num_q_vectors, q_vector[i] */
__igb_open(netdev, true, false)
clear_bit(__IGB_DOWN, &adapter->state);
schedule_work(&adapter->rtnl_resume_task);
None of this runs under RTNL, and clear_bit() has no release ordering.
Also, nothing cancels or flushes rtnl_resume_task on runtime suspend. __igb_shutdown() frees the q_vectors under RTNL, but the only cancel_work_sync(&adapter->rtnl_resume_task) is in igb_remove().
That means a work instance queued by one runtime resume could still be pending, or waiting on rtnl_lock(), when the next runtime suspend runs after the autosuspend delay. It could then still be waiting when the next RTNL-less runtime resume runs.
Once the work gets RTNL, its loads of num_q_vectors and q_vector[i] are ordered after the relaxed test_bit() only by a control dependency. A control dependency doesn't order load->load on arm64 or POWER.
Could the work then see __IGB_DOWN clear and the new num_q_vectors, but a stale NULL or freed q_vector[i]? If so, it would oops in igb_set_queue_napi() when it reads q_vector->rx.ring.
This seems unlikely in practice, since the q_vector stores happen well before clear_bit(). Still, would either of these make the claim in the comment hold?
- A cancel_work_sync(&adapter->rtnl_resume_task) in the runtime suspend path before rtnl_lock().
- An smp_mb__before_atomic() before clear_bit(), paired with test_bit_acquire() in igb_rtnl_resume_task().
[ ... ]
drivers/net/ethernet/intel/igb/igb_main.c static int __igb_open(struct net_device *netdev, bool resuming, · line 4235
Quoted 8 lines
drivers/net/ethernet/intel/igb/igb_main.c +2
-1@@ -4219,7 +4230,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); }
[Severity: Medium]
This isn't a bug introduced by this patch, but igc appears to have the same problem. igc_runtime_resume() calls __igc_resume(dev, true), which only takes RTNL when !rpm:
drivers/net/ethernet/intel/igc/igc_main.c:__igc_resume() {
...
if (netif_running(netdev)) {
if (!rpm)
rtnl_lock();
err = __igc_open(netdev, true);
...
}__igc_open() still links the queues unconditionally:
for (i = 0; i < adapter->num_q_vectors; i++) {
napi = &adapter->q_vector[i]->napi;
napi_enable(napi);
igc_set_queue_napi(adapter, i, napi);
}Wouldn't igc_set_queue_napi()->netif_queue_set_napi() trigger the same "RTNL: assertion failed" splat on every runtime resume while the interface is up?
The note about igc is below the --- line, so it won't be in the commit log. Is a separate igc fix still planned?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120210134.133238-1-antonio%40mandelbit.com
Re: [PATCH net v4 3/4] igb: link queues to NAPIs under RTNL after runtime resume
Quoted 5 lines · On 24/11/2026 22:38, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 (1) · Low: 0
Quoted 9 lines
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).
- [Medium]
igb_rtnl_resume_task()now callsigb_link_queue_napis(), which readsadapter->num_q_vectorsand dereferences adapter->q_vector[i]…
Right, nothing cancelled the work item on suspend. v5 cancels it at the start of __igb_shutdown(), before taking RTNL, so it only runs after the resume that scheduled it allocated the q_vectors.
Quoted 3 lines
Pre-existing issues:
- [Medium] This problem wasn't introduced by this patch, but igc has the same bug.
yes, an igc fix is planned and will be sent separately once it has been tested on igc hardware.
Regards,
Signature · 5 lines
Antonio Quartulli CEO and Co-Founder Mandelbit Srl https://www.mandelbit.com
PATCH v4 4/4 igb: only allow runtime PM if the device can wake up
In reply to Antonio Quartulliigb lets the device be runtime suspended even if it can't signal a wake-up from D3. Such a device doesn't notice the link coming back, so the port stays down until it is resumed from user space.
Allow runtime PM only if pci_dev_run_wake() is true, as e1000e and r8169 do. Devices that can't wake up no longer runtime suspend, even with power/control set to auto.
Tested with the 82576 emulated by QEMU.
---
v4: no changes
v3: no changes
v2: no code changes; mention the tested hardware
Note: igc has the same issue: igc_probe() also allows runtime PM regardless of pci_dev_run_wake().
drivers/net/ethernet/intel/igb/igb_main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +7 -2
@@ -3654,7 +3654,11 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)dev_pm_set_driver_flags (&pdev->dev,DPM_FLAG_NO_DIRECT_COMPLETE ); -pm_runtime_put_noidle (&pdev->dev); +/* A device that can't wake up wouldn't notice the link coming back +* while runtime suspended +*/ +if (pci_dev_run_wake (pdev)) +pm_runtime_put_noidle (&pdev->dev);return 0 ; err_register:
@@ -3876,7 +3880,8 @@ static void igb_remove(struct pci_dev *pdev)struct igb_adapter *adapter =netdev_priv (netdev);struct e1000_hw *hw = &adapter->hw; -pm_runtime_get_noresume (&pdev->dev); +if (pci_dev_run_wake (pdev)) +pm_runtime_get_noresume (&pdev->dev);#ifdef CONFIG_IGB_HWMON igb_sysfs_exit (adapter);#endif
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH net v4 4/4] igb: only allow runtime PM if the device can wake up
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · 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).
- [Medium] The runtime PM usage count can end up unbalanced, because the same decision is made twice.
--
igb: only allow runtime PM if the device can wake up
With this patch, igb_probe() drops the runtime PM reference taken by local_pci_probe() only when pci_dev_run_wake() is true. Devices that can't signal a wake-up from D3 are therefore never runtime suspended. igb_remove() takes the reference back under the same condition.
Quoted 18 lines
drivers/net/ethernet/intel/igb/igb_main.c +5
-1@@ -3654,7 +3654,11 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)dev_pm_set_driver_flags (&pdev->dev,DPM_FLAG_NO_DIRECT_COMPLETE ); -pm_runtime_put_noidle (&pdev->dev); +/* A device that can't wake up wouldn't notice the link coming back +* while runtime suspended +*/ +if (pci_dev_run_wake (pdev)) +pm_runtime_put_noidle (&pdev->dev);return 0 ; err_register:
drivers/net/ethernet/intel/igb/igb_main.c static void igb_remove(struct pci_dev *pdev) · line 3884
Quoted 6 lines
drivers/net/ethernet/intel/igb/igb_main.c +2
-1@@ -3876,7 +3880,8 @@ static void igb_remove(struct pci_dev *pdev)struct igb_adapter *adapter =netdev_priv (netdev);struct e1000_hw *hw = &adapter->hw; -pm_runtime_get_noresume (&pdev->dev); +if (pci_dev_run_wake (pdev)) +pm_runtime_get_noresume (&pdev->dev);
[Severity: Medium]
Can the runtime PM usage count get out of balance here?
pci_dev_run_wake() runs once in igb_probe() and again in igb_remove(), and the first result isn't stored. pci_device_remove() then always ends with a put:
drivers/pci/pci-driver.c:pci_device_remove() {
...
/* Undo the runtime PM settings in local_pci_probe() */
pm_runtime_put_sync(dev);
...
}The count only balances if both pci_dev_run_wake() calls return the same value.
It looks like the result can change while the driver is bound. pci_dev_run_wake() checks pci_pme_capable(dev, pci_target_state(dev, true)). On ACPI-managed devices, acpi_pci_choose_state() caps the target state using a flag that root can change through sysfs:
drivers/pci/pci-acpi.c:acpi_pci_choose_state() {
...
if (pdev->no_d3cold || !pdev->d3cold_allowed)
d_max = ACPI_STATE_D3_HOT;
else
d_max = ACPI_STATE_D3_COLD;
...
}d3cold_allowed_store() writes pdev->d3cold_allowed, and nothing serializes that write against probe or remove. On a device that can raise PME from D3hot but not from D3cold, toggling the attribute flips the result of pci_dev_run_wake().
A second case is a device not managed by the platform, for example an igb NIC behind a Thunderbolt or USB4 dock. If it is surprise-removed while runtime suspended, the result also seems to change. pm_runtime_get_sync() in pci_device_remove() resumes the device, and pci_power_up() does:
drivers/pci/pci.c:pci_power_up() {
...
if (pci_dev_is_disconnected(dev)) {
dev->current_state = PCI_D3cold;
return -EIO;
}
...
}After that, pci_target_state() returns D3cold:
drivers/pci/pci.c:pci_target_state() {
...
if (dev->current_state == PCI_D3cold)
return PCI_D3cold;
...
}So igb_remove() tests the PME-from-D3cold bit, while igb_probe() tested the D3hot bit.
If the call returns false at probe and true at remove, igb_remove() does an extra pm_runtime_get_noresume(). One usage count then leaks on each bind/unbind cycle. The device can't runtime suspend again, even after the driver is rebound.
If it returns true at probe and false at remove, the final pm_runtime_put_sync() in pci_device_remove() underflows and logs "Runtime PM usage count underflow!". With power/control set to on, the extra put uses up the pm_runtime_forbid() reference instead, and a later pm_runtime_allow() underflows.
Would it be safer to call pci_dev_run_wake() once in igb_probe(), store the result (for example as a bool in struct igb_adapter), and test that stored value in igb_remove()?
e1000e and r8169 call pci_dev_run_wake() again at remove in the same way, so this pattern already exists in the tree. In igb, though, this would be a new imbalance, added by a fix that is tagged for stable.
Quoted 3 lines
drivers/net/ethernet/intel/igb/igb_main.c +0
-0#ifdef CONFIG_IGB_HWMON igb_sysfs_exit (adapter);#endif
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120210134.133238-1-antonio%40mandelbit.com
Re: [PATCH net v4 4/4] igb: only allow runtime PM if the device can wake up
Quoted 5 lines · On 24/11/2026 22:38, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
Quoted 8 lines
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).
- [Medium] The runtime PM usage count can end up unbalanced, because the same decision is made twice.
Right: pci_dev_run_wake() can change while the driver is bound. v5 checks it where the runtime suspend is scheduled (the watchdog and igb_runtime_idle()) instead of at probe and remove, which stay unconditional, so the usage count stays balanced.
Regards,
Signature · 5 lines
Antonio Quartulli CEO and Co-Founder Mandelbit Srl https://www.mandelbit.com