* [PATCH net v7 0/7] igb: fix runtime PM resume issues
@ 2026-12-02 0:23 Antonio Quartulli
2026-12-02 0:23 ` [PATCH net v7 1/7] igb: don't wait for RTNL when runtime suspending Antonio Quartulli
` (6 more replies)
0 siblings, 7 replies; 13+ messages in thread
From: Antonio Quartulli @ 2026-12-02 0:23 UTC (permalink / raw)
To: intel-wired-lan
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, linux-pm, linux-kernel, bpf
igb can be runtime suspended when the link goes down (with
power/control set to auto). The suspend can deadlock with an RTNL holder
resuming the device, e.g. ethtool (patch 1). Resuming calls functions
that need RTNL without holding it (patches 3 and 5), XDP and XSK changes
race with a resume or follow a failed one (patch 6), and devices that
can't signal a wake-up are suspended anyway, so their port stays down
when the link comes back (patch 7).
Patch 2 fixes the XSK pool disable path when the device has fewer rings
than the stack has queues (a single Tx queue with VFs on 82576, or none
while runtime suspended); patch 4 keeps such queues while they still
have a zero-copy pool, so that it can still be disabled.
Tested with the 82576 emulated by QEMU, with test-only hooks to delay a
runtime suspend, to make the open fail on resume, and to force MSI with
a single queue on resume. Before/after this version: ethtool during a
runtime suspend hangs with RTNL held / completes, and the suspend is
retried; closing a zero-copy AF_XDP socket after a failed resume hangs
in napi_disable() with RTNL held / completes, then removing the XDP
program works. The runtime suspend tests ran without patch 7, as QEMU's
82576 can't signal PME. Not tested: real hardware and PME wake-up, a
real system sleep, PCI error recovery. Not run under KASAN.
Pre-existing issues left for a follow-up: in the XSK queue disable and
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, Rx
wakeups fail on a queue without a Tx ring, and the XSK state isn't
handled during PCI error recovery; a failed igb_open() at the end of
igb_xdp_setup() leaves the NAPIs disabled; system resume rebuilds the
rings without RTNL; and an XDP program is checked against the buffer
size of rings that haven't been configured yet. igc has the same resume
issues (see the notes) and also takes RTNL when runtime suspending; its
fixes will be sent separately.
Changes in v7:
- patch 6: only update the software state on a detached device, and only
check the Rx buffer size when adding or replacing an XDP program, as
removing one failed after a resume with the interface down (Sashiko)
- patch 7: comments (Sashiko)
Changes in v6:
- new patch 1: don't wait for RTNL when runtime suspending (Sashiko)
- patch 2: the message and comment name the runtime suspended case
(Sashiko)
- patch 3: the work item resumes the device first (Sashiko)
- patch 4: only zero-copy pools keep a queue (Sashiko)
- patch 5: don't cancel the work item in __igb_shutdown() anymore
- patch 6: handle a failed resume (Sashiko)
- added Janis's Reviewed-by to the unchanged patches 2 and 7
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
v6: https://lore.kernel.org/netdev/20261130213740.3323814-1-antonio@mandelbit.com/
v5: https://lore.kernel.org/netdev/20261124235723.1135808-1-antonio@mandelbit.com/
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 (7):
igb: don't wait for RTNL when runtime suspending
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 | 2 +
drivers/net/ethernet/intel/igb/igb_main.c | 185 ++++++++++++++++++----
drivers/net/ethernet/intel/igb/igb_xsk.c | 42 +++--
3 files changed, 187 insertions(+), 42 deletions(-)
--
2.56.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net v7 1/7] igb: don't wait for RTNL when runtime suspending
2026-12-02 0:23 [PATCH net v7 0/7] igb: fix runtime PM resume issues Antonio Quartulli
@ 2026-12-02 0:23 ` Antonio Quartulli
2026-12-03 1:04 ` netdev-bot+sashiko
2026-12-02 0:23 ` [PATCH net v7 2/7] igb: don't touch rings that don't exist when disabling an XSK pool Antonio Quartulli
` (5 subsequent siblings)
6 siblings, 1 reply; 13+ messages in thread
From: Antonio Quartulli @ 2026-12-02 0:23 UTC (permalink / raw)
To: intel-wired-lan
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, linux-pm, linux-kernel, bpf, stable
The PM core marks the device as suspending before calling
igb_runtime_suspend(), which takes RTNL. An RTNL holder that resumes the
device meanwhile, e.g. ethtool, igb_open() or igb_close(), waits for the
suspend to end, and the suspend waits for RTNL: both hang, with RTNL
taken.
The suspend still needs RTNL, as it closes the interface and frees the
queues. When runtime suspending, only try to take it, and return -EBUSY
if it's taken, which keeps the device active. Retry from a work item:
resuming and releasing the device schedules a new suspend if the link
is still down.
Fixes: 9474933caf21 ("igb: close/suspend race in netif_device_detach")
Cc: stable@vger.kernel.org
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
v7: no changes
v6: new patch (Sashiko)
drivers/net/ethernet/intel/igb/igb.h | 1 +
drivers/net/ethernet/intel/igb/igb_main.c | 28 ++++++++++++++++++++++-
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h
index 8c9b020..4250b4d 100644
--- a/drivers/net/ethernet/intel/igb/igb.h
+++ b/drivers/net/ethernet/intel/igb/igb.h
@@ -586,6 +586,7 @@ struct igb_adapter {
struct work_struct reset_task;
struct work_struct watchdog_task;
+ struct work_struct rpm_retry_task;
bool fc_autoneg;
u8 tx_timeout_factor;
struct timer_list blink_timer;
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index d4a897a..fffcb31 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -119,6 +119,7 @@ static void igb_set_rx_mode(struct net_device *);
static void igb_update_phy_info(struct timer_list *);
static void igb_watchdog(struct timer_list *);
static void igb_watchdog_task(struct work_struct *);
+static void igb_rpm_retry_task(struct work_struct *);
static netdev_tx_t igb_xmit_frame(struct sk_buff *skb, struct net_device *);
static void igb_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *stats);
@@ -3426,6 +3427,7 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
INIT_WORK(&adapter->reset_task, igb_reset_task);
INIT_WORK(&adapter->watchdog_task, igb_watchdog_task);
+ INIT_WORK(&adapter->rpm_retry_task, igb_rpm_retry_task);
/* Initialize link properties that are user-changeable */
adapter->fc_autoneg = true;
@@ -3889,6 +3891,7 @@ static void igb_remove(struct pci_dev *pdev)
cancel_work_sync(&adapter->reset_task);
cancel_work_sync(&adapter->watchdog_task);
+ cancel_work_sync(&adapter->rpm_retry_task);
#ifdef CONFIG_IGB_DCA
if (adapter->flags & IGB_FLAG_DCA_ENABLED) {
@@ -9501,7 +9504,18 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol;
bool wake;
- rtnl_lock();
+ /* The PM core marks the device as suspending before a runtime
+ * suspend, and an RTNL holder resuming it meanwhile (e.g. ethtool)
+ * waits for the suspend to end: waiting for RTNL here would deadlock.
+ * Only try to take it: -EBUSY keeps the device active, and
+ * igb_rpm_retry_task() schedules a new suspend.
+ */
+ if (!runtime) {
+ rtnl_lock();
+ } else if (!rtnl_trylock()) {
+ schedule_work(&adapter->rpm_retry_task);
+ return -EBUSY;
+ }
netif_device_detach(netdev);
if (netif_running(netdev))
@@ -9666,6 +9680,18 @@ static int igb_runtime_idle(struct device *dev)
return -EBUSY;
}
+/* Resuming and releasing the device runs igb_runtime_idle(), which schedules
+ * a new suspend if the link is still down
+ */
+static void igb_rpm_retry_task(struct work_struct *work)
+{
+ struct igb_adapter *adapter = container_of(work, struct igb_adapter,
+ rpm_retry_task);
+
+ pm_runtime_get_sync(&adapter->pdev->dev);
+ pm_runtime_put(&adapter->pdev->dev);
+}
+
static int igb_runtime_suspend(struct device *dev)
{
return __igb_shutdown(to_pci_dev(dev), NULL, 1);
--
2.56.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net v7 2/7] igb: don't touch rings that don't exist when disabling an XSK pool
2026-12-02 0:23 [PATCH net v7 0/7] igb: fix runtime PM resume issues Antonio Quartulli
2026-12-02 0:23 ` [PATCH net v7 1/7] igb: don't wait for RTNL when runtime suspending Antonio Quartulli
@ 2026-12-02 0:23 ` Antonio Quartulli
2026-12-03 1:04 ` netdev-bot+sashiko
2026-12-02 0:23 ` [PATCH net v7 3/7] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
` (4 subsequent siblings)
6 siblings, 1 reply; 13+ messages in thread
From: Antonio Quartulli @ 2026-12-02 0:23 UTC (permalink / raw)
To: intel-wired-lan
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, linux-pm, linux-kernel, bpf, stable
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 <janislacis06@gmail.com>
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
v7: no changes
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net v7 3/7] igb: fix RTNL assertion when resuming from runtime suspend
2026-12-02 0:23 [PATCH net v7 0/7] igb: fix runtime PM resume issues Antonio Quartulli
2026-12-02 0:23 ` [PATCH net v7 1/7] igb: don't wait for RTNL when runtime suspending Antonio Quartulli
2026-12-02 0:23 ` [PATCH net v7 2/7] igb: don't touch rings that don't exist when disabling an XSK pool Antonio Quartulli
@ 2026-12-02 0:23 ` Antonio Quartulli
2026-12-03 1:04 ` netdev-bot+sashiko
2026-12-02 0:23 ` [PATCH net v7 4/7] igb: keep the stack's Rx queues that still have an XSK pool Antonio Quartulli
` (3 subsequent siblings)
6 siblings, 1 reply; 13+ messages in thread
From: Antonio Quartulli @ 2026-12-02 0:23 UTC (permalink / raw)
To: intel-wired-lan
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, linux-pm, linux-kernel, bpf, stable
Since 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. The work item resumes the device first, so that it
doesn't run in the middle of a later suspend or 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.
Fixes: ac8c58f5b535 ("igb: fix deadlock caused by taking RTNL in RPM resume path")
Cc: stable@vger.kernel.org
Closes: https://bugzilla.ipfire.org/show_bug.cgi?id=13562
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
v7: no changes
v6: the work item resumes the device first, so that it can't run during
a suspend or resume (Sashiko); dropped Janis's Reviewed-by, as the patch
changed
v5: no changes
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 | 76 +++++++++++++++++------
2 files changed, 57 insertions(+), 20 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h
index 4250b4d..0639b00 100644
--- a/drivers/net/ethernet/intel/igb/igb.h
+++ b/drivers/net/ethernet/intel/igb/igb.h
@@ -587,6 +587,7 @@ struct igb_adapter {
struct work_struct reset_task;
struct work_struct watchdog_task;
struct work_struct rpm_retry_task;
+ struct work_struct rtnl_resume_task;
bool fc_autoneg;
u8 tx_timeout_factor;
struct timer_list blink_timer;
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index fffcb31..bf24768 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -110,6 +110,7 @@ static void igb_init_queue_configuration(struct igb_adapter *adapter);
static int igb_sw_init(struct igb_adapter *);
int igb_open(struct net_device *);
int igb_close(struct net_device *);
+static void igb_rtnl_resume_task(struct work_struct *);
static void igb_configure(struct igb_adapter *);
static void igb_configure_tx(struct igb_adapter *);
static void igb_configure_rx(struct igb_adapter *);
@@ -3428,6 +3429,7 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
INIT_WORK(&adapter->reset_task, igb_reset_task);
INIT_WORK(&adapter->watchdog_task, igb_watchdog_task);
INIT_WORK(&adapter->rpm_retry_task, igb_rpm_retry_task);
+ INIT_WORK(&adapter->rtnl_resume_task, igb_rtnl_resume_task);
/* Initialize link properties that are user-changeable */
adapter->fc_autoneg = true;
@@ -3892,6 +3894,7 @@ static void igb_remove(struct pci_dev *pdev)
cancel_work_sync(&adapter->reset_task);
cancel_work_sync(&adapter->watchdog_task);
cancel_work_sync(&adapter->rpm_retry_task);
+ cancel_work_sync(&adapter->rtnl_resume_task);
#ifdef CONFIG_IGB_DCA
if (adapter->flags & IGB_FLAG_DCA_ENABLED) {
@@ -4126,10 +4129,34 @@ static int igb_sw_init(struct igb_adapter *adapter)
return 0;
}
+/* Some settings need RTNL, which isn't held when resuming from runtime
+ * suspend: apply them from here instead, if the device is still up.
+ * Resuming the device first waits for a resume or suspend in progress.
+ */
+static void igb_rtnl_resume_task(struct work_struct *work)
+{
+ struct igb_adapter *adapter = container_of(work, struct igb_adapter,
+ rtnl_resume_task);
+
+ rtnl_lock();
+ pm_runtime_get_sync(&adapter->pdev->dev);
+ if (!test_bit(__IGB_DOWN, &adapter->state) &&
+ netif_running(adapter->netdev)) {
+ if (netif_set_real_num_queues(adapter->netdev,
+ adapter->num_tx_queues,
+ adapter->num_rx_queues))
+ netdev_err(adapter->netdev,
+ "error setting real queue count\n");
+ }
+ pm_runtime_put(&adapter->pdev->dev);
+ rtnl_unlock();
+}
+
/**
* __igb_open - Called when a network interface is made active
* @netdev: network interface device structure
* @resuming: indicates whether we are in a resume call
+ * @rtnl_held: indicates whether RTNL is held
*
* Returns 0 on success, negative value on failure
*
@@ -4139,7 +4166,8 @@ static int igb_sw_init(struct igb_adapter *adapter)
* handler is registered with the OS, the watchdog timer is started,
* and the stack is notified that the interface is ready.
**/
-static int __igb_open(struct net_device *netdev, bool resuming)
+static int __igb_open(struct net_device *netdev, bool resuming,
+ bool rtnl_held)
{
struct igb_adapter *adapter = netdev_priv(netdev);
struct pci_dev *pdev = adapter->pdev;
@@ -4182,16 +4210,15 @@ static int __igb_open(struct net_device *netdev, bool resuming)
if (err)
goto err_req_irq;
- /* Notify the stack of the actual queue counts. */
- err = netif_set_real_num_tx_queues(adapter->netdev,
- adapter->num_tx_queues);
- if (err)
- goto err_set_queues;
-
- err = netif_set_real_num_rx_queues(adapter->netdev,
- adapter->num_rx_queues);
- if (err)
- goto err_set_queues;
+ /* Notify the stack of the actual queue counts. This needs RTNL: on
+ * runtime resume igb_rtnl_resume_task() does it.
+ */
+ if (rtnl_held) {
+ err = netif_set_real_num_queues(netdev, adapter->num_tx_queues,
+ adapter->num_rx_queues);
+ if (err)
+ goto err_set_queues;
+ }
/* From here on the code is the same as igb_up() */
clear_bit(__IGB_DOWN, &adapter->state);
@@ -4245,7 +4272,7 @@ err_setup_tx:
int igb_open(struct net_device *netdev)
{
- return __igb_open(netdev, false);
+ return __igb_open(netdev, false, true);
}
/**
@@ -6620,12 +6647,7 @@ cleanup_tx_tstamp:
static inline struct igb_ring *igb_tx_queue_mapping(struct igb_adapter *adapter,
struct sk_buff *skb)
{
- unsigned int r_idx = skb->queue_mapping;
-
- if (r_idx >= adapter->num_tx_queues)
- r_idx = r_idx % adapter->num_tx_queues;
-
- return adapter->tx_ring[r_idx];
+ return adapter->tx_ring[skb->queue_mapping];
}
static netdev_tx_t igb_xmit_frame(struct sk_buff *skb,
@@ -6639,6 +6661,17 @@ static netdev_tx_t igb_xmit_frame(struct sk_buff *skb,
if (skb_put_padto(skb, 17))
return NETDEV_TX_OK;
+ /* After a fallback to fewer queues on runtime resume, the stack can
+ * use more queues than the device has until igb_rtnl_resume_task()
+ * updates it: drop those packets instead of sharing a ring between
+ * queues, which aren't serialized with each other.
+ */
+ if (unlikely(skb->queue_mapping >= adapter->num_tx_queues)) {
+ dev_kfree_skb_any(skb);
+ dev_core_stats_tx_dropped_inc(netdev);
+ return NETDEV_TX_OK;
+ }
+
return igb_xmit_frame_ring(skb, igb_tx_queue_mapping(adapter, skb));
}
@@ -9653,8 +9686,11 @@ static int __igb_resume(struct device *dev, bool rpm)
if (!rpm)
rtnl_lock();
- if (!err && netif_running(netdev))
- err = __igb_open(netdev, true);
+ if (!err && netif_running(netdev)) {
+ err = __igb_open(netdev, true, !rpm);
+ if (!err && rpm)
+ schedule_work(&adapter->rtnl_resume_task);
+ }
if (!err)
netif_device_attach(netdev);
--
2.56.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net v7 4/7] igb: keep the stack's Rx queues that still have an XSK pool
2026-12-02 0:23 [PATCH net v7 0/7] igb: fix runtime PM resume issues Antonio Quartulli
` (2 preceding siblings ...)
2026-12-02 0:23 ` [PATCH net v7 3/7] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
@ 2026-12-02 0:23 ` Antonio Quartulli
2026-12-03 1:04 ` netdev-bot+sashiko
2026-12-02 0:23 ` [PATCH net v7 5/7] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
` (2 subsequent siblings)
6 siblings, 1 reply; 13+ messages in thread
From: Antonio Quartulli @ 2026-12-02 0:23 UTC (permalink / raw)
To: intel-wired-lan
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, linux-pm, linux-kernel, bpf, stable
When igb lowers its queue counts by itself, after a fallback from MSI-X
to MSI on resume or when enabling VFs, xsk_get_pool_from_qid() doesn't
find the pool of a socket bound to a removed queue anymore. Disabling
it then fails ("Failed to disable zero-copy!") and the pool's DMA
mappings are never unmapped.
ethtool refuses to remove a queue that still has an XSK pool, but igb
can't refuse a VF enable or a resume fallback. Keep the real Rx queue
count up to the highest queue that still has a zero-copy XSK pool
instead, so that the pool can still be disabled, and lower it at the
next open. Copy mode pools don't need the driver to be disabled. The
Tx count follows the device: an XSK pool is always bound to both an Rx
and a Tx queue, and the lookup finds it through the Rx one.
Tested with the 82576 emulated by QEMU and a zero-copy AF_XDP socket,
bound to queue 2 when enabling a VF, and to queue 1 across a runtime
resume forced to use MSI with a single queue (with a test hook): closing
it warned and leaked before, not anymore.
Fixes: 80f6ccf9f116 ("igb: Introduce XSK data structures and helpers")
Cc: stable@vger.kernel.org # 6.14+
Reported-by: Janis Edvarts Lacis <janislacis06@gmail.com>
Closes: https://lore.kernel.org/netdev/xupy6jbpnziq2qji54zjbvm7neggrwkxg3sfrhlolmrd6ysifl@zptk6ynkbu5f/
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
v7: no changes
v6: only zero-copy pools keep a queue: copy mode pools don't need the
driver to be disabled (Sashiko); dropped Janis's Reviewed-by
v5: new patch (Janis)
drivers/net/ethernet/intel/igb/igb_main.c | 30 +++++++++++++++++++----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index bf24768..8b8e8c3 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -4129,6 +4129,29 @@ static int igb_sw_init(struct igb_adapter *adapter)
return 0;
}
+/* ethtool refuses to remove a queue that still has an XSK pool. igb can't
+ * refuse when it lowers its queue counts by itself, so keep the stack's Rx
+ * queue instead, or a zero-copy pool couldn't be disabled anymore: lower the
+ * count once it's gone, at the next open.
+ */
+static int igb_set_real_num_queues(struct igb_adapter *adapter)
+{
+ struct net_device *netdev = adapter->netdev;
+ unsigned int rxq = adapter->num_rx_queues;
+ struct xsk_buff_pool *pool;
+ unsigned int i;
+
+ for (i = netdev->real_num_rx_queues; i > rxq; i--) {
+ pool = xsk_get_pool_from_qid(netdev, i - 1);
+ if (pool && pool->umem->zc) {
+ rxq = i;
+ break;
+ }
+ }
+
+ return netif_set_real_num_queues(netdev, adapter->num_tx_queues, rxq);
+}
+
/* Some settings need RTNL, which isn't held when resuming from runtime
* suspend: apply them from here instead, if the device is still up.
* Resuming the device first waits for a resume or suspend in progress.
@@ -4142,9 +4165,7 @@ static void igb_rtnl_resume_task(struct work_struct *work)
pm_runtime_get_sync(&adapter->pdev->dev);
if (!test_bit(__IGB_DOWN, &adapter->state) &&
netif_running(adapter->netdev)) {
- if (netif_set_real_num_queues(adapter->netdev,
- adapter->num_tx_queues,
- adapter->num_rx_queues))
+ if (igb_set_real_num_queues(adapter))
netdev_err(adapter->netdev,
"error setting real queue count\n");
}
@@ -4214,8 +4235,7 @@ static int __igb_open(struct net_device *netdev, bool resuming,
* runtime resume igb_rtnl_resume_task() does it.
*/
if (rtnl_held) {
- err = netif_set_real_num_queues(netdev, adapter->num_tx_queues,
- adapter->num_rx_queues);
+ err = igb_set_real_num_queues(adapter);
if (err)
goto err_set_queues;
}
--
2.56.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net v7 5/7] igb: link queues to NAPIs under RTNL after runtime resume
2026-12-02 0:23 [PATCH net v7 0/7] igb: fix runtime PM resume issues Antonio Quartulli
` (3 preceding siblings ...)
2026-12-02 0:23 ` [PATCH net v7 4/7] igb: keep the stack's Rx queues that still have an XSK pool Antonio Quartulli
@ 2026-12-02 0:23 ` Antonio Quartulli
2026-12-02 0:23 ` [PATCH net v7 6/7] igb: resume the device before changing XDP or XSK settings Antonio Quartulli
2026-12-02 0:23 ` [PATCH net v7 7/7] igb: only allow runtime PM if the device can wake up Antonio Quartulli
6 siblings, 0 replies; 13+ messages in thread
From: Antonio Quartulli @ 2026-12-02 0:23 UTC (permalink / raw)
To: intel-wired-lan
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, linux-pm, linux-kernel, bpf, stable
__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.
The work item resumes the device and checks __IGB_DOWN under RTNL
first, so the q_vectors exist when it links them.
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>
---
v7: no changes
v6: don't cancel the work item in __igb_shutdown() anymore: it resumes
the device first (patch 3), and a runtime suspend no longer waits for
RTNL (patch 1), so cancelling it there could deadlock (Sashiko); dropped
Janis's Reviewed-by
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 | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 8b8e8c3..55352df 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -4152,9 +4152,18 @@ 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.
- * Resuming the device first waits for a resume or suspend in progress.
+ * Resuming the device first waits for a resume or suspend in progress, so
+ * that the q_vectors aren't being freed or allocated meanwhile.
*/
static void igb_rtnl_resume_task(struct work_struct *work)
{
@@ -4168,6 +4177,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);
}
pm_runtime_put(&adapter->pdev->dev);
rtnl_unlock();
@@ -4246,7 +4256,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. */
--
2.56.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net v7 6/7] igb: resume the device before changing XDP or XSK settings
2026-12-02 0:23 [PATCH net v7 0/7] igb: fix runtime PM resume issues Antonio Quartulli
` (4 preceding siblings ...)
2026-12-02 0:23 ` [PATCH net v7 5/7] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
@ 2026-12-02 0:23 ` Antonio Quartulli
2026-12-03 1:04 ` netdev-bot+sashiko
2026-12-02 0:23 ` [PATCH net v7 7/7] igb: only allow runtime PM if the device can wake up Antonio Quartulli
6 siblings, 1 reply; 13+ messages in thread
From: Antonio Quartulli @ 2026-12-02 0:23 UTC (permalink / raw)
To: intel-wired-lan
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, linux-pm, linux-kernel, bpf, stable
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. If
resuming fails, the rings don't exist, or have no resources and their
NAPIs were never enabled: don't touch them when disabling an XSK pool,
and refuse to enable one. igb_close() doesn't close the device then, as
it's detached (as during PCI error recovery, where changing the program
also opened it twice): only update the software state when changing the
XDP program. Only check the Rx buffer size when adding or replacing a
program, as rings allocated by a resume don't know it until they are
configured, which made removing a program fail.
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. Also, with a test hook making the open fail
on resume, by closing a socket and changing the XDP program after a
failed resume, and by removing a program that needs 3K buffers while the
interface is down and runtime suspended. 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>
---
v7: igb_xdp_setup(): only update the software state on a detached device
(failed resume, PCI error recovery), and only check the Rx buffer size
when adding or replacing a program (Sashiko)
v6: handle a failed resume: skip rings without resources, refuse to
enable a pool or add an XDP program, and only update the software state
when removing or replacing one (Sashiko); dropped Janis's Reviewed-by
v5: new patch (Sashiko)
drivers/net/ethernet/intel/igb/igb_main.c | 34 +++++++++++++++++++----
drivers/net/ethernet/intel/igb/igb_xsk.c | 8 ++++--
2 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 55352df..d7a4b41 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -2896,8 +2896,17 @@ static int igb_xdp_setup(struct net_device *dev, struct netdev_bpf *bpf)
bool running = netif_running(dev);
bool need_reset;
- /* verify igb ring attributes are sufficient for XDP */
- for (i = 0; i < adapter->num_rx_queues; i++) {
+ /* igb_close() doesn't close a detached device (after a failed resume,
+ * or during PCI error recovery): only update the software state
+ */
+ if (!netif_device_present(dev))
+ running = false;
+
+ /* verify igb ring attributes are sufficient for XDP, only when adding
+ * or replacing a program: rings allocated by a resume don't know their
+ * buffer size until they are configured
+ */
+ for (i = 0; prog && i < adapter->num_rx_queues; i++) {
struct igb_ring *ring = adapter->rx_ring[i];
if (frame_size > igb_rx_bufsz(ring)) {
@@ -2943,16 +2952,29 @@ 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. If resuming fails, igb_xdp_setup() and
+ * igb_xsk_pool_setup() find the device down.
+ */
+ 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)
diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c b/drivers/net/ethernet/intel/igb/igb_xsk.c
index b6234e3..e70f818 100644
--- a/drivers/net/ethernet/intel/igb/igb_xsk.c
+++ b/drivers/net/ethernet/intel/igb/igb_xsk.c
@@ -120,6 +120,10 @@ static int igb_xsk_pool_enable(struct igb_adapter *adapter,
qid >= netdev->real_num_tx_queues)
return -EINVAL;
+ /* After a failed resume the rings have no resources */
+ if (netif_running(netdev) && !adapter->rx_ring[qid]->desc)
+ return -ENODEV;
+
err = xsk_pool_dma_map(pool, &adapter->pdev->dev, IGB_RX_DMA_ATTR);
if (err)
return err;
@@ -160,11 +164,11 @@ static int igb_xsk_pool_disable(struct igb_adapter *adapter, u16 qid)
rx_ring = adapter->rx_ring[qid];
/* 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.
+ * doesn't have, or that have no resources after a failed resume.
*/
if_running = netif_running(adapter->netdev) &&
igb_xdp_is_enabled(adapter) &&
- qid < adapter->num_rx_queues;
+ qid < adapter->num_rx_queues && rx_ring->desc;
if (if_running)
igb_txrx_ring_disable(adapter, qid);
--
2.56.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net v7 7/7] igb: only allow runtime PM if the device can wake up
2026-12-02 0:23 [PATCH net v7 0/7] igb: fix runtime PM resume issues Antonio Quartulli
` (5 preceding siblings ...)
2026-12-02 0:23 ` [PATCH net v7 6/7] igb: resume the device before changing XDP or XSK settings Antonio Quartulli
@ 2026-12-02 0:23 ` Antonio Quartulli
6 siblings, 0 replies; 13+ messages in thread
From: Antonio Quartulli @ 2026-12-02 0:23 UTC (permalink / raw)
To: intel-wired-lan
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, linux-pm, linux-kernel, bpf, stable
igb 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.
Only schedule a runtime suspend if pci_dev_run_wake() is true. Devices
that can't wake up no longer runtime suspend, even with power/control
set to auto. Checking it when scheduling the suspend, rather than at
probe and remove as e1000e and r8169 do, keeps the runtime PM usage
count balanced if the result changes while the driver is bound.
Tested with the 82576 emulated by QEMU.
Fixes: 749ab2cd1270 ("igb: add basic runtime PM support")
Cc: stable@vger.kernel.org
Closes: https://bugzilla.ipfire.org/show_bug.cgi?id=13562
Reviewed-by: Janis Edvarts Lacis <janislacis06@gmail.com>
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
v7: mention the wake-up condition in two comments (Sashiko)
v6: no changes
v5: check pci_dev_run_wake() when scheduling the suspend rather than
at probe and remove, which keeps the usage count balanced (Sashiko)
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 | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index d7a4b41..6c29152 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -5642,6 +5642,15 @@ static void igb_watchdog(struct timer_list *t)
schedule_work(&adapter->watchdog_task);
}
+/* A device that can't wake up wouldn't notice the link coming back while
+ * runtime suspended
+ */
+static void igb_schedule_runtime_suspend(struct igb_adapter *adapter)
+{
+ if (pci_dev_run_wake(adapter->pdev))
+ pm_schedule_suspend(&adapter->pdev->dev, MSEC_PER_SEC * 5);
+}
+
static void igb_watchdog_task(struct work_struct *work)
{
struct igb_adapter *adapter = container_of(work,
@@ -5794,8 +5803,7 @@ no_wait:
return;
}
}
- pm_schedule_suspend(netdev->dev.parent,
- MSEC_PER_SEC * 5);
+ igb_schedule_runtime_suspend(adapter);
/* also check for alternate media here */
} else if (!netif_carrier_ok(netdev) &&
@@ -9594,7 +9602,7 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
* suspend, and an RTNL holder resuming it meanwhile (e.g. ethtool)
* waits for the suspend to end: waiting for RTNL here would deadlock.
* Only try to take it: -EBUSY keeps the device active, and
- * igb_rpm_retry_task() schedules a new suspend.
+ * igb_rpm_retry_task() schedules a new suspend if it can still wake up.
*/
if (!runtime) {
rtnl_lock();
@@ -9764,13 +9772,13 @@ static int igb_runtime_idle(struct device *dev)
struct igb_adapter *adapter = netdev_priv(netdev);
if (!igb_has_link(adapter))
- pm_schedule_suspend(dev, MSEC_PER_SEC * 5);
+ igb_schedule_runtime_suspend(adapter);
return -EBUSY;
}
/* Resuming and releasing the device runs igb_runtime_idle(), which schedules
- * a new suspend if the link is still down
+ * a new suspend if the link is still down and the device can wake up
*/
static void igb_rpm_retry_task(struct work_struct *work)
{
--
2.56.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net v7 1/7] igb: don't wait for RTNL when runtime suspending
2026-12-02 0:23 ` [PATCH net v7 1/7] igb: don't wait for RTNL when runtime suspending Antonio Quartulli
@ 2026-12-03 1:04 ` netdev-bot+sashiko
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03 1:04 UTC (permalink / raw)
To: antonio
Cc: intel-wired-lan, anthony.l.nguyen, przemyslaw.kitszel,
andrew+netdev, davem, edumazet, kuba, pabeni, janislacis06, ast,
daniel, hawk, john.fastabend, sdf, sriram.yagnaraman, kurt,
maciej.fijalkowski, hkallweit1, joe, rafael, sven.auhagen,
netdev, linux-pm, linux-kernel, bpf, stable
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The new member `struct work_struct rpm_retry_task` goes into the
middle of `struct igb_adapter`…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the igc driver
(I225/I226) still has the same RTNL vs. RPM_SUSPENDING deadlock that…
--
igb: don't wait for RTNL when runtime suspending
This patch changes __igb_shutdown() to use rtnl_trylock() on the runtime
suspend path. If RTNL is contended, it returns -EBUSY to avoid a deadlock
with RTNL holders that resume the device. A new work item,
igb_rpm_retry_task(), resumes and releases the device so that
igb_runtime_idle() can schedule another suspend.
> diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h
> index 8c9b02058cecb..4250b4d363ea3 100644
> --- a/drivers/net/ethernet/intel/igb/igb.h
> +++ b/drivers/net/ethernet/intel/igb/igb.h
> @@ -586,6 +586,7 @@ struct igb_adapter {
>
> struct work_struct reset_task;
> struct work_struct watchdog_task;
> + struct work_struct rpm_retry_task;
[Severity: Low]
This isn't a bug, but struct igb_adapter has this comment further down:
/* to not mess up cache alignment, always add to the bottom */
Placing a work_struct here moves fc_autoneg, blink_timer, pdev,
stats64_lock, stats64, hw, stats, q_vector[] and the other later members
to new offsets.
rpm_retry_task is only used on a failed runtime suspend and in
igb_remove(). Could it go below that comment instead? If the comment no
longer applies, it could be updated or removed.
The later patch in this series, "igb: fix RTNL assertion when resuming
from runtime suspend", adds rtnl_resume_task in the same place, so the
same question applies there.
> bool fc_autoneg;
> u8 tx_timeout_factor;
> struct timer_list blink_timer;
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index 131df3e09ba14..2fb9615d3bab3 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
[ ... ]
> @@ -9500,7 +9503,18 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
> u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol;
> bool wake;
>
> - rtnl_lock();
> + /* The PM core marks the device as suspending before a runtime
> + * suspend, and an RTNL holder resuming it meanwhile (e.g. ethtool)
> + * waits for the suspend to end: waiting for RTNL here would deadlock.
> + * Only try to take it: -EBUSY keeps the device active, and
> + * igb_rpm_retry_task() schedules a new suspend.
> + */
> + if (!runtime) {
> + rtnl_lock();
> + } else if (!rtnl_trylock()) {
> + schedule_work(&adapter->rpm_retry_task);
> + return -EBUSY;
> + }
[Severity: High]
This is a pre-existing issue in a sibling driver, not something
introduced by this patch. Does igc have the same RTNL vs RPM_SUSPENDING
deadlock that this patch fixes in igb?
igc_runtime_suspend() goes through __igc_shutdown() with runtime=1, and
that path takes RTNL unconditionally:
drivers/net/ethernet/intel/igc/igc_main.c:igc_runtime_suspend() {
return __igc_shutdown(to_pci_dev(dev), NULL, 1);
}
drivers/net/ethernet/intel/igc/igc_main.c:__igc_shutdown() {
...
rtnl_lock();
netif_device_detach(netdev);
...
}
At the same time, RTNL holders resume the device, and rpm_resume() waits
for the suspend in progress to finish:
drivers/net/ethernet/intel/igc/igc_main.c:__igc_open() {
...
if (!resuming)
pm_runtime_get_sync(&pdev->dev);
...
}
drivers/net/ethernet/intel/igc/igc_main.c:__igc_close() {
...
if (!suspending)
pm_runtime_get_sync(&pdev->dev);
...
}
The ethtool ioctl and netlink paths in net/ethtool/ also call
pm_runtime_get_sync(dev->dev.parent) while holding RTNL.
igc_runtime_idle() uses the same pm_schedule_suspend(dev, 5000) scheme
as igb. The trigger looks the same: link down, power/control set to
auto, and an ethtool query or ip link up/down at the moment the delayed
suspend runs. RTNL would then stay held, and later networking
configuration would hang.
This igc code has not changed since 2019, and no patch in this series
touches igc. Would a matching igc fix make sense, either in this series
or as a follow-up, so stable can pick up both?
> netif_device_detach(netdev);
>
> if (netif_running(netdev))
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202002317.3140591-1-antonio%40mandelbit.com
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net v7 2/7] igb: don't touch rings that don't exist when disabling an XSK pool
2026-12-02 0:23 ` [PATCH net v7 2/7] igb: don't touch rings that don't exist when disabling an XSK pool Antonio Quartulli
@ 2026-12-03 1:04 ` netdev-bot+sashiko
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03 1:04 UTC (permalink / raw)
To: antonio
Cc: intel-wired-lan, anthony.l.nguyen, przemyslaw.kitszel,
andrew+netdev, davem, edumazet, kuba, pabeni, janislacis06, ast,
daniel, hawk, john.fastabend, sdf, sriram.yagnaraman, kurt,
maciej.fijalkowski, hkallweit1, joe, rafael, sven.auhagen,
netdev, linux-pm, linux-kernel, bpf, stable
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 (1) · Medium: 1 (4) · 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] At this commit, the new `qid < adapter->num_rx_queues` guard
in igb_xsk_pool_disable() and the num_tx_queues check in…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch
rewrites these exact blocks and keeps the faulty assumption.
- [Medium] At this commit, igb_xsk_pool_disable() decides whether to tear
down and rebuild the queue with only `netif_running() &&…
- [Medium] This problem wasn't introduced by this patch, but
igb_xsk_wakeup() rejects any qid >= adapter->num_tx_queues and…
- [Medium] This problem wasn't introduced by this patch, but in
igb_xsk_pool_disable(), if igb_realloc_rx_buffer_info(rx_ring, false)…
- [Medium] This problem wasn't introduced by this patch, but
igb_txrx_ring_disable() clears RXDCTL/TXDCTL with posted MMIO writes.
--
igb: don't touch rings that don't exist when disabling an XSK pool
This patch adds igb_xsk_tx_ring(), which returns NULL for a qid beyond
num_tx_queues. igb_txrx_ring_disable() and igb_txrx_ring_enable() now
skip the Tx part when there is no Tx ring. igb_xsk_pool_disable() also
skips the ring teardown entirely when qid >= num_rx_queues, which covers
82576 with VFs and the runtime suspended case.
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..b6234e349ef20 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 is a pre-existing issue, but with this helper an Rx-only queue can
now keep a zero-copy pool. How does igb_xsk_wakeup() handle such a queue?
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 the scenario from the commit message: a pool is bound to queue 1,
then VFs are enabled, so num_tx_queues == 1. igb_configure_rx_ring()
re-attaches the pool to rx_ring[1].
But every ndo_xsk_wakeup for queue 1 returns -EINVAL before the
XDP_WAKEUP_RX branch. Does that mean the Rx need_wakeup kick never
reaches rx_ring[1]->q_vector?
The two paths also check the qid against different counters.
igb_xsk_pool_enable() uses netdev->real_num_tx_queues and
adapter->num_rx_queues, while igb_xsk_wakeup() uses
adapter->num_tx_queues. Should these agree?
> +
> 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();
[Severity: Medium]
This isn't a bug introduced by this patch, but these queue disables are
posted MMIO writes that are never flushed or polled. Are synchronize_net()
and napi_disable() enough to make sure the queue has stopped DMA? The rings
are cleaned right after, and igb_xsk_pool_disable() then calls
xsk_pool_dma_unmap().
igb_down() in the same driver does this after disabling Rx and Tx:
/* flush both disables and wait for them to finish */
wrfl();
usleep_range(10000, 11000);
igb_rx_fifo_flush_82575() also polls RXDCTL.
If the queue hasn't actually stopped, could a late descriptor write-back
or packet DMA land in a UMEM buffer already returned to the pool? Could it
hit an IOVA that was just unmapped?
> @@ -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 is a pre-existing issue, but since these blocks are being rewritten:
does the "Rx/Tx share the same napi context" assumption hold when
IGB_FLAG_QUEUE_PAIRS is clear?
igb_set_flag_queue_pairs() never sets the flag on 82575/i211. On
82576/82580/i350/i354/i210 it clears the flag when
rss_queues <= max_rss_queues / 2.
With the flag clear, igb_set_interrupt_capability() reserves separate Tx
vectors. igb_alloc_q_vectors() then puts rx_ring[qid] and tx_ring[qid] on
different q_vectors.
The driver's own igb_xsk_wakeup() treats the sharing as conditional:
/* If IGB_FLAG_QUEUE_PAIRS is active, the q_vector
* and NAPI is shared between RX and TX.
Only rx_ring->q_vector->napi is disabled here. Can the Tx vector keep
running this:
igb_poll()
igb_clean_tx_irq(q_vector, budget)
while this path runs igb_clean_tx_ring(tx_ring) on the same ring?
IGB_RING_FLAG_TX_DISABLED only stops igb_xmit_zc() and
igb_xmit_frame_ring(), not the completion loop.
Both loops start from tx_ring->next_to_clean. Could skbs or xdp frames be
freed twice, or the same DMA mapping be unmapped twice? Could
netdev_tx_reset_queue() race netdev_tx_completed_queue() and hit this
BUG_ON in dql_completed():
BUG_ON(count > num_queued - dql->num_completed);
There is a related problem in igb_txrx_ring_enable().
igb_configure_tx_ring() resets TDH/TDT and memsets tx_buffer_info while
the Tx NAPI is still live.
Could this also napi_disable()/napi_enable() tx_ring->q_vector->napi when
it differs from the Rx one? This is unchanged at the end of the series.
[ ... ]
> @@ -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;
[Severity: Medium]
This is a pre-existing issue rather than something introduced here. The
new gate catches a missing ring, but not a ring that exists and has no
resources.
What happens if __igb_open() failed earlier? That can happen in
__igb_resume(), or after igb_close() in igb_xdp_setup(),
igb_sriov_reinit() or igb_reinit_queues().
The __igb_open() unwind frees ring->desc and the tx/rx buffer_info arrays.
It leaves these in place:
- num_rx_queues > 0
- the ring structs, still allocated
- __LINK_STATE_START, still set
- the NAPI, never enabled
Closing a zero-copy socket in that state still calls
igb_txrx_ring_disable(). netif_napi_add() left SCHED|NPSVC set, so
wouldn't napi_disable() spin forever with RTNL held?
If it got past that, igb_txrx_ring_enable() would dereference NULL in two
places:
- igb_configure_tx_ring(), in the memset of tx_buffer_info
- igb_configure_rx_ring(), at IGB_RX_DESC(ring, 0)
igb_xsk_pool_enable() has the same gap.
The later patch in this series, "igb: resume the device before changing
XDP or XSK settings", seems to fix both paths:
- it adds "&& rx_ring->desc" to this gate
- igb_xsk_pool_enable() returns -ENODEV when
!adapter->rx_ring[qid]->desc
- a runtime PM reference is held across igb_xdp()
[Severity: Medium]
Can this check, and the num_tx_queues check in igb_xsk_tx_ring(), change
under a concurrent runtime resume?
This path holds only RTNL. __igb_resume() with rpm=true does not take
RTNL. It rebuilds num_rx_queues, num_tx_queues and
adapter->rx_ring[]/tx_ring[] through igb_init_interrupt_scheme().
igb_set_interrupt_capability() publishes the count first:
adapter->num_rx_queues = adapter->rss_queues;
The ring pointers are only filled in later by igb_alloc_q_vector(), and
NAPI is enabled later still, in __igb_open(). rx_ring is also loaded
before num_rx_queues is checked.
Suppose a zero-copy socket is closed during that window. Could this check
pass and the code still dereference a NULL rx_ring? Could it call
napi_disable() on a NAPI that isn't enabled yet and spin with RTNL held?
The later patch in this series, "igb: resume the device before changing
XDP or XSK settings", appears to close this. It calls
pm_runtime_get_sync() in igb_xdp() before igb_xsk_pool_setup().
> if (if_running)
> igb_txrx_ring_disable(adapter, qid);
>
[Severity: Medium]
This isn't a bug introduced by this patch, but look further down in
igb_xsk_pool_disable():
if (if_running) {
err = igb_realloc_rx_buffer_info(rx_ring, false);
if (err)
return err;
igb_txrx_ring_enable(adapter, qid);
}
When igb_realloc_rx_buffer_info() fails, igb_txrx_ring_disable() and
xsk_pool_dma_unmap() have already run, but igb_txrx_ring_enable() is
skipped. Doesn't that leave the queue in this state?
- RXDCTL/TXDCTL at 0
- IGB_RING_FLAG_TX_DISABLED set
- the q_vector NAPI disabled
- rx_ring->xsk_pool and tx_ring->xsk_pool pointing at a pool that the
XSK core then frees
The next igb_down() would then disable the same NAPI again:
igb_down()
napi_disable(&adapter->q_vector[i]->napi)
That call never returns, and RTNL stays held. igb_xsk_pool_enable() has the
same pattern: on a realloc failure it only unmaps the pool and returns.
This is unchanged at the end of the series.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202002317.3140591-1-antonio%40mandelbit.com
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net v7 3/7] igb: fix RTNL assertion when resuming from runtime suspend
2026-12-02 0:23 ` [PATCH net v7 3/7] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
@ 2026-12-03 1:04 ` netdev-bot+sashiko
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03 1:04 UTC (permalink / raw)
To: antonio
Cc: intel-wired-lan, anthony.l.nguyen, przemyslaw.kitszel,
andrew+netdev, davem, edumazet, kuba, pabeni, janislacis06, ast,
daniel, hawk, john.fastabend, sdf, sriram.yagnaraman, kurt,
maciej.fijalkowski, hkallweit1, joe, rafael, sven.auhagen,
netdev, linux-pm, linux-kernel, bpf, stable
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 (2) · 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 patch does not fully fix the RTNL assertion it targets on
runtime resume, but a later patch in the series closes the gap.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but
`igb_save_cbs_params()` and `igb_save_txtime_params()` have an off-by-…
- [High] This problem wasn't introduced by this patch, but the MSI-X to
MSI fallback in `igb_request_irq()` frees Rx/Tx descriptor rings and…
--
igb: fix RTNL assertion when resuming from runtime suspend
On runtime resume, __igb_open() no longer calls netif_set_real_num_queues()
when RTNL isn't held. A new work item takes RTNL and sets the queue
counts instead. Until that runs, igb_xmit_frame() drops packets whose
queue_mapping is beyond the device's current TX queue count, rather than
folding them onto a shared ring.
Closes: https://bugzilla.ipfire.org/show_bug.cgi?id=13562
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index 2fb9615d3bab3..5774a4d3c9810 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
[ ... ]
> @@ -4181,16 +4209,15 @@ static int __igb_open(struct net_device *netdev, bool resuming)
> if (err)
> goto err_req_irq;
>
[Severity: High]
This isn't a bug introduced by this patch, but the commit message relies
on the MSI-X to MSI fallback in igb_request_irq(). Is that fallback safe
for the hardware queues that igb_configure() has already enabled?
__igb_open() calls igb_configure() before igb_request_irq(). For each of
the N queues:
- igb_configure_rx_ring() enables RXDCTL and programs the ring base.
- igb_alloc_rx_buffers() advances RDT.
- igb_setup_rctl() sets E1000_RCTL_EN.
- igb_setup_mrqc() spreads RSS over all N queues.
If igb_request_msix() fails:
drivers/net/ethernet/intel/igb/igb_main.c:igb_request_irq() {
...
/* fall back to MSI */
igb_free_all_tx_resources(adapter);
igb_free_all_rx_resources(adapter);
igb_clear_interrupt_scheme(adapter);
err = igb_init_interrupt_scheme(adapter, false);
...
igb_configure(adapter);
...
}
The descriptor rings and Rx pages are freed without any RXDCTL/TXDCTL
write. The second igb_configure() only reconfigures the new, smaller set
of queues. igb_setup_rctl() only disables queue 0:
/* disable queue 0 to prevent tail write w/o re-config */
wr32(E1000_RXDCTL(0), 0);
Can queues 1..N-1 stay enabled, with base addresses and posted
descriptors that point at freed memory?
Packets could still be steered there in two ways:
- RSS, until the second igb_setup_mrqc() rewrites RETA.
- ntuple/etype filters with an action queue >= 1, permanently.
igb_nfc_filter_restore() re-adds them without checking them against the
new num_rx_queues. The only check is in igb_add_ethtool_nfc_entry().
Would the NIC then DMA packet data and descriptor write-backs into freed
pages?
> - /* Notify the stack of the actual queue counts. */
> - err = netif_set_real_num_tx_queues(adapter->netdev,
> - adapter->num_tx_queues);
> - if (err)
> - goto err_set_queues;
> -
> - err = netif_set_real_num_rx_queues(adapter->netdev,
> - adapter->num_rx_queues);
> - if (err)
> - goto err_set_queues;
> + /* Notify the stack of the actual queue counts. This needs RTNL: on
> + * runtime resume igb_rtnl_resume_task() does it.
> + */
> + if (rtnl_held) {
> + err = netif_set_real_num_queues(netdev, adapter->num_tx_queues,
> + adapter->num_rx_queues);
> + if (err)
> + goto err_set_queues;
> + }
>
> /* From here on the code is the same as igb_up() */
> clear_bit(__IGB_DOWN, &adapter->state);
[Severity: Medium]
Does this fully cover the RTNL assertion on runtime resume? A few lines
further down in __igb_open(), the NAPI loop isn't guarded by rtnl_held:
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);
}
igb_set_queue_napi() calls netif_queue_set_napi(), which runs
netdev_assert_locked_ops_compat_or_invisible(). igb is a registered
netdev without the ops lock, so this becomes ASSERT_RTNL(). The runtime
resume path is:
igb_runtime_resume()
__igb_resume(dev, true)
__igb_open(netdev, true, false)
igb_set_queue_napi()
netif_queue_set_napi()
Wouldn't this still print "RTNL: assertion failed" and write
rxq->napi/txq->napi without RTNL? igb_rtnl_resume_task() only restores
the queue counts, not the links between queues and NAPIs.
The later patch in this series, "igb: link queues to NAPIs under RTNL
after runtime resume", appears to fix this. It guards
igb_set_queue_napi() with rtnl_held and calls igb_link_queue_napis() from
igb_rtnl_resume_task(). So the gap only exists between these two commits.
Since this patch carries the Fixes: and stable tags, should the two be
combined?
[ ... ]
> @@ -6638,6 +6660,17 @@ static netdev_tx_t igb_xmit_frame(struct sk_buff *skb,
> if (skb_put_padto(skb, 17))
> return NETDEV_TX_OK;
>
> + /* After a fallback to fewer queues on runtime resume, the stack can
> + * use more queues than the device has until igb_rtnl_resume_task()
> + * updates it: drop those packets instead of sharing a ring between
> + * queues, which aren't serialized with each other.
> + */
> + if (unlikely(skb->queue_mapping >= adapter->num_tx_queues)) {
> + dev_kfree_skb_any(skb);
> + dev_core_stats_tx_dropped_inc(netdev);
> + return NETDEV_TX_OK;
> + }
[Severity: High]
This isn't a bug introduced by this patch, but this check uses >=, while
igb_save_cbs_params() and igb_save_txtime_params() use >:
drivers/net/ethernet/intel/igb/igb_main.c:igb_save_cbs_params() {
...
if (queue < 0 || queue > adapter->num_tx_queues)
return -EINVAL;
ring = adapter->tx_ring[queue];
ring->cbs_enable = enable;
...
}
igb_save_txtime_params() has the same check before:
ring->launchtime_enable = enable;
On i210, igb_offload_cbs() and igb_offload_txtime() accept queue 0 or 1,
whatever num_tx_queues is:
if (qopt->queue < 0 || qopt->queue > 1)
return -EINVAL;
num_tx_queues can be 1 in these cases:
- a single online CPU
- after ethtool -L combined 1
- after the MSI-X to MSI fallback discussed in this commit
In that case, can queue 1 pass both checks and dereference a NULL
tx_ring[1]? That entry is either never assigned or set to NULL by
igb_reset_q_vector().
The netdev has 8 allocated TX queues, and mq_queue_get() only rejects
ntx >= dev->num_tx_queues. So these commands reach igb_setup_tc() with
queue 1:
tc qdisc add dev X root handle 1: mq
tc qdisc replace dev X parent 1:2 cbs ... offload 1
An etf qdisc with offload takes the same path.
Should both helpers check queue >= adapter->num_tx_queues instead?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202002317.3140591-1-antonio%40mandelbit.com
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net v7 4/7] igb: keep the stack's Rx queues that still have an XSK pool
2026-12-02 0:23 ` [PATCH net v7 4/7] igb: keep the stack's Rx queues that still have an XSK pool Antonio Quartulli
@ 2026-12-03 1:04 ` netdev-bot+sashiko
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03 1:04 UTC (permalink / raw)
To: antonio
Cc: intel-wired-lan, anthony.l.nguyen, przemyslaw.kitszel,
andrew+netdev, davem, edumazet, kuba, pabeni, janislacis06, ast,
daniel, hawk, john.fastabend, sdf, sriram.yagnaraman, kurt,
maciej.fijalkowski, hkallweit1, joe, rafael, sven.auhagen,
netdev, linux-pm, linux-kernel, bpf, stable
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] After this patch, the comment in __igb_open()
(drivers/net/ethernet/intel/igb/igb_main.c) no longer matches the code…
--
igb: keep the stack's Rx queues that still have an XSK pool
This patch adds igb_set_real_num_queues(). The helper keeps
real_num_rx_queues up to the highest queue that still has a zero-copy XSK
pool bound, so the pool can still be disabled after igb lowers its own
queue counts (MSI-X to MSI fallback on resume, or VF enable). The count is
lowered again at the next open.
Closes: https://lore.kernel.org/netdev/xupy6jbpnziq2qji54zjbvm7neggrwkxg3sfrhlolmrd6ysifl@zptk6ynkbu5f/
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index 5774a4d3c9810..9752350ffc68b 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
[ ... ]
> @@ -4213,8 +4234,7 @@ static int __igb_open(struct net_device *netdev, bool resuming,
> * runtime resume igb_rtnl_resume_task() does it.
> */
> if (rtnl_held) {
> - err = netif_set_real_num_queues(netdev, adapter->num_tx_queues,
> - adapter->num_rx_queues);
> + err = igb_set_real_num_queues(adapter);
[Severity: Low]
This isn't a bug, but should the comment above this call be updated too?
The full comment in __igb_open() reads:
/* Notify the stack of the actual queue counts. This needs RTNL: on
* runtime resume igb_rtnl_resume_task() does it.
*/
With this change, igb_set_real_num_queues() can on purpose report more Rx
queues than adapter->num_rx_queues. That happens while a zero-copy pool is
still bound to a queue the device no longer has:
for (i = netdev->real_num_rx_queues; i > rxq; i--) {
pool = xsk_get_pool_from_qid(netdev, i - 1);
if (pool && pool->umem->zc) {
rxq = i;
break;
}
}
So the Rx count passed to the stack is not always the device's actual
count.
Someone reading the __igb_open() comment could assume that
netdev->real_num_rx_queues == adapter->num_rx_queues after open. The
previous patch in this series had to drop that same assumption in
igb_xsk_pool_disable().
Could the comment mention that the Rx count may stay higher while a
zero-copy XSK pool is still bound to a removed queue?
> if (err)
> goto err_set_queues;
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202002317.3140591-1-antonio%40mandelbit.com
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net v7 6/7] igb: resume the device before changing XDP or XSK settings
2026-12-02 0:23 ` [PATCH net v7 6/7] igb: resume the device before changing XDP or XSK settings Antonio Quartulli
@ 2026-12-03 1:04 ` netdev-bot+sashiko
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03 1:04 UTC (permalink / raw)
To: antonio
Cc: intel-wired-lan, anthony.l.nguyen, przemyslaw.kitszel,
andrew+netdev, davem, edumazet, kuba, pabeni, janislacis06, ast,
daniel, hawk, john.fastabend, sdf, sriram.yagnaraman, kurt,
maciej.fijalkowski, hkallweit1, joe, rafael, sven.auhagen,
netdev, linux-pm, linux-kernel, bpf, stable
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.
Critical: 0 · High: 3 · Medium: 1 · Low: 1
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 guards in igb_xsk_pool_enable() and
igb_xsk_pool_disable() (drivers/net/ethernet/intel/igb/igb_xsk.c) use…
- [High] igb_xdp_setup() makes its close/open decision from one read of
netif_device_present() under RTNL.
- [High] The new "only update the software state" path for a detached
device in igb_xdp_setup() can lead to an out-of-bounds write in…
- [Medium] igb_xdp() now calls pm_runtime_get_sync() first.
- [Low] The new comment in igb_xdp() says that if resuming fails,
igb_xdp_setup() and igb_xsk_pool_setup() "find the device down".
--
igb: resume the device before changing XDP or XSK settings
This patch holds a runtime PM reference for the whole of igb_xdp(). That
stops __igb_resume() from rebuilding the rings while XDP or XSK setup is
running. It also skips or refuses XSK ring changes when the rings have no
descriptors after a failed resume, makes igb_xdp_setup() update only the
software state on a detached device, and checks the Rx buffer size only
when a program is added or replaced.
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index 11c136d7bea75..a6fa33cb4521a 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -2896,8 +2896,17 @@ static int igb_xdp_setup(struct net_device *dev, struct netdev_bpf *bpf)
> bool running = netif_running(dev);
> bool need_reset;
>
> - /* verify igb ring attributes are sufficient for XDP */
> - for (i = 0; i < adapter->num_rx_queues; i++) {
> + /* igb_close() doesn't close a detached device (after a failed resume,
> + * or during PCI error recovery): only update the software state
> + */
> + if (!netif_device_present(dev))
> + running = false;
[Severity: High]
Can this netif_device_present() check race with PCI error recovery? The
PCI error handlers change the present bit outside RTNL:
igb_io_error_detected() {
netif_device_detach(netdev);
...
rtnl_lock();
if (netif_running(netdev))
igb_down(adapter);
rtnl_unlock();
...
}
igb_io_resume() {
rtnl_lock();
...
if (igb_up(adapter)) {
...
rtnl_unlock();
netif_device_attach(netdev);
...
}
igb_close() also reads the bit again on its own:
int igb_close(struct net_device *netdev)
{
if (netif_device_present(netdev) || netdev->dismantle)
return __igb_close(netdev, false);
return 0;
}
Suppose igb_xdp_setup() sees the device as present with need_reset true,
and igb_io_error_detected() then detaches it. igb_close() returns 0
without closing, and igb_xdp_setup() still calls igb_open() on an
interface that is already open. Isn't that the double open the commit
message says is fixed?
The reverse case can happen too. An ndo_bpf caller waiting on RTNL while
igb_io_resume() runs igb_up() can get the lock before
netif_device_attach() runs. It then sees !present, sets running to false
and only xchg()s ring->xdp_prog.
If a program is removed this way while a zero-copy pool is bound, the
ring stays in ZC mode and ring->xdp_prog becomes NULL:
igb_clean_rx_irq_zc() {
...
/* xdp_prog cannot be NULL in the ZC path */
xdp_prog = READ_ONCE(rx_ring->xdp_prog);
...
}
Would igb_run_xdp_zc() then call bpf_prog_run_xdp() with a NULL prog
from NAPI?
[Severity: High]
Can this software-only path leave the Rx rings with the wrong
rx_buffer_info layout?
With an XDP program attached and a zero-copy pool bound,
igb_xsk_pool_enable()->igb_realloc_rx_buffer_info(rx_ring, true) sizes
the array for ZC:
int size = pool_present ?
sizeof(*ring->rx_buffer_info_zc) * ring->count :
sizeof(*ring->rx_buffer_info) * ring->count;
Then a PCI error hits. igb_io_error_detected() detaches the device and
calls igb_down(), which keeps the ring resources. If the XDP program is
removed before igb_io_resume(), this path only clears adapter->xdp_prog
and ring->xdp_prog. Nothing calls igb_realloc_rx_buffer_info(ring, false).
Later, igb_io_resume()->igb_up()->igb_configure()->igb_configure_rx()->
igb_configure_rx_ring() finds no pool, because igb_xsk_pool() returns
NULL once XDP is disabled:
else
memset(ring->rx_buffer_info, 0,
sizeof(*ring->rx_buffer_info) * ring->count);
Don't this memset() and the igb_alloc_rx_buffers() call that follows
write struct igb_rx_buffer entries past the end of the 8-byte-per-entry
ZC allocation?
Before this patch, this case went through igb_open()->
igb_setup_rx_resources(), which allocated a full-size igb_rx_buffer
array.
> +
> + /* verify igb ring attributes are sufficient for XDP, only when adding
> + * or replacing a program: rings allocated by a resume don't know their
> + * buffer size until they are configured
> + */
> + for (i = 0; prog && i < adapter->num_rx_queues; i++) {
> struct igb_ring *ring = adapter->rx_ring[i];
>
> if (frame_size > igb_rx_bufsz(ring)) {
[Severity: Medium]
igb_xdp() now calls pm_runtime_get_sync() first. With that, can this
check refuse a valid attach on a down interface?
On a down, runtime suspended interface, __igb_resume()->
igb_init_interrupt_scheme() allocates fresh rings. netif_running() is
false, so igb_set_rx_buffer_len() never runs for them. Neither
IGB_RING_FLAG_RX_3K_BUFFER nor IGB_RING_FLAG_RX_BUILD_SKB_ENABLED gets
set, and igb_rx_bufsz() returns IGB_RXBUFFER_2048.
At open, igb_set_rx_buffer_len() would have chosen 3K buffers:
if (adapter->max_frame_size > IGB_MAX_FRAME_BUILD_SKB ||
IGB_2K_TOO_SMALL_WITH_PADDING ||
rd32(E1000_RCTL) & E1000_RCTL_SBP)
set_ring_uses_large_buffer(rx_ring);
So with PAGE_SIZE < 8192 and an MTU between 2023 and 3046, adding a
program now fails with "The RX buffer size is too small for the frame
size". Before this patch, runtime suspend had freed the rings and
num_rx_queues was 0 at this point, so the attach succeeded.
The new comment says rings allocated by a resume don't know their buffer
size, yet the check is skipped only for removal. Should it also be
skipped for rings that haven't been configured yet?
> @@ -2943,16 +2952,29 @@ 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. If resuming fails, igb_xdp_setup() and
> + * igb_xsk_pool_setup() find the device down.
> + */
> + pm_runtime_get_sync(&adapter->pdev->dev);
[Severity: Low]
Is "find the device down" accurate here? When __igb_open() fails inside
__igb_resume(), nothing clears __LINK_STATE_START, so netif_running() is
still true. The device is only not attached, and its rings have no
resources.
The new checks depend on exactly that state: netif_running() &&
!rx_ring[qid]->desc in igb_xsk_pool_enable(), and netif_device_present()
in igb_xdp_setup().
Could the comment say that the device is detached but still running?
[ ... ]
> diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c b/drivers/net/ethernet/intel/igb/igb_xsk.c
> index b6234e349ef20..e70f8184debe6 100644
> --- a/drivers/net/ethernet/intel/igb/igb_xsk.c
> +++ b/drivers/net/ethernet/intel/igb/igb_xsk.c
> @@ -120,6 +120,10 @@ static int igb_xsk_pool_enable(struct igb_adapter *adapter,
> qid >= netdev->real_num_tx_queues)
> return -EINVAL;
>
> + /* After a failed resume the rings have no resources */
> + if (netif_running(netdev) && !adapter->rx_ring[qid]->desc)
> + return -ENODEV;
> +
> err = xsk_pool_dma_map(pool, &adapter->pdev->dev, IGB_RX_DMA_ATTR);
> if (err)
> return err;
> @@ -160,11 +164,11 @@ static int igb_xsk_pool_disable(struct igb_adapter *adapter, u16 qid)
> rx_ring = adapter->rx_ring[qid];
> /* 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.
> + * doesn't have, or that have no resources after a failed resume.
> */
> if_running = netif_running(adapter->netdev) &&
> igb_xdp_is_enabled(adapter) &&
> - qid < adapter->num_rx_queues;
> + qid < adapter->num_rx_queues && rx_ring->desc;
> if (if_running)
> igb_txrx_ring_disable(adapter, qid);
[Severity: High]
Does the rx_ring->desc check cover PCI error recovery?
igb_io_error_detected() detaches the device and calls igb_down(), which
disables every NAPI:
for (i = 0; i < adapter->num_q_vectors; i++) {
if (adapter->q_vector[i]) {
napi_disable(&adapter->q_vector[i]->napi);
igb_down() doesn't free the descriptor rings, though, and netif_running()
stays true.
Now suppose a zero-copy AF_XDP socket is closed, or a new one is bound,
while an XDP program is attached. if_running is true here in
igb_xsk_pool_disable(), and the new !desc test in igb_xsk_pool_enable()
passes as well. Both paths then reach igb_txrx_ring_disable():
/* Rx/Tx share the same napi context. */
napi_disable(&rx_ring->q_vector->napi);
Won't this second napi_disable() spin forever in napi_disable_locked()
with RTNL held? igb_io_resume() also takes rtnl_lock(), so recovery would
hang as well.
igb_xdp_setup() handles the detached case with netif_device_present().
Would netif_device_present() or test_bit(__IGB_DOWN, &adapter->state) be
a better gate here than rx_ring->desc?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202002317.3140591-1-antonio%40mandelbit.com
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-12-03 1:04 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-02 0:23 [PATCH net v7 0/7] igb: fix runtime PM resume issues Antonio Quartulli
2026-12-02 0:23 ` [PATCH net v7 1/7] igb: don't wait for RTNL when runtime suspending Antonio Quartulli
2026-12-03 1:04 ` netdev-bot+sashiko
2026-12-02 0:23 ` [PATCH net v7 2/7] igb: don't touch rings that don't exist when disabling an XSK pool Antonio Quartulli
2026-12-03 1:04 ` netdev-bot+sashiko
2026-12-02 0:23 ` [PATCH net v7 3/7] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
2026-12-03 1:04 ` netdev-bot+sashiko
2026-12-02 0:23 ` [PATCH net v7 4/7] igb: keep the stack's Rx queues that still have an XSK pool Antonio Quartulli
2026-12-03 1:04 ` netdev-bot+sashiko
2026-12-02 0:23 ` [PATCH net v7 5/7] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
2026-12-02 0:23 ` [PATCH net v7 6/7] igb: resume the device before changing XDP or XSK settings Antonio Quartulli
2026-12-03 1:04 ` netdev-bot+sashiko
2026-12-02 0:23 ` [PATCH net v7 7/7] igb: only allow runtime PM if the device can wake up Antonio Quartulli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®