Netdev List
 help / color / mirror / Atom feed
* [PATCH net v4 0/4] igb: fix runtime PM resume issues
@ 2026-11-20 21:01 Antonio Quartulli
  2026-11-20 21:01 ` [PATCH net v4 1/4] igb: don't touch rings that don't exist when disabling an XSK pool Antonio Quartulli
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Antonio Quartulli @ 2026-11-20 21:01 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, netdev, linux-kernel, bpf

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/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 (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(-)

-- 
2.56.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH net v4 1/4] igb: don't touch rings that don't exist when disabling an XSK pool
  2026-11-20 21:01 [PATCH net v4 0/4] igb: fix runtime PM resume issues Antonio Quartulli
@ 2026-11-20 21:01 ` Antonio Quartulli
  2026-11-20 23:17   ` Janis Edvarts Lacis
  2026-11-24 21:38   ` netdev-bot+sashiko
  2026-11-20 21:01 ` [PATCH net v4 2/4] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 10+ messages in thread
From: Antonio Quartulli @ 2026-11-20 21:01 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, netdev,
	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 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.

Fixes: 80f6ccf9f116 ("igb: Introduce XSK data structures and helpers")
Cc: stable@vger.kernel.org # 6.14+
Link: https://lore.kernel.org/netdev/20261116153041.3002666-2-antonio@mandelbit.com/
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
v4: also handle queues with an Rx but no Tx ring, as with VFs (Sashiko):
tear down the Rx ring and skip only the Tx part; tested with a
zero-copy AF_XDP socket; subject was "don't disable rings that don't exist
..."
v3: new patch.

 drivers/net/ethernet/intel/igb/igb_xsk.c | 37 +++++++++++++++++-------
 1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c b/drivers/net/ethernet/intel/igb/igb_xsk.c
index ce4a7b5..3b4212a 100644
--- a/drivers/net/ethernet/intel/igb/igb_xsk.c
+++ b/drivers/net/ethernet/intel/igb/igb_xsk.c
@@ -31,15 +31,22 @@ static int igb_realloc_rx_buffer_info(struct igb_ring *ring, bool pool_present)
 	return 0;
 }
 
+/* With VFs, the device has a single Tx queue but can have more Rx queues */
+static struct igb_ring *igb_xsk_tx_ring(struct igb_adapter *adapter, u16 qid)
+{
+	return qid < adapter->num_tx_queues ? adapter->tx_ring[qid] : NULL;
+}
+
 static void igb_txrx_ring_disable(struct igb_adapter *adapter, u16 qid)
 {
-	struct igb_ring *tx_ring = adapter->tx_ring[qid];
+	struct igb_ring *tx_ring = igb_xsk_tx_ring(adapter, qid);
 	struct igb_ring *rx_ring = adapter->rx_ring[qid];
 	struct e1000_hw *hw = &adapter->hw;
 
-	set_bit(IGB_RING_FLAG_TX_DISABLED, &tx_ring->flags);
-
-	wr32(E1000_TXDCTL(tx_ring->reg_idx), 0);
+	if (tx_ring) {
+		set_bit(IGB_RING_FLAG_TX_DISABLED, &tx_ring->flags);
+		wr32(E1000_TXDCTL(tx_ring->reg_idx), 0);
+	}
 	wr32(E1000_RXDCTL(rx_ring->reg_idx), 0);
 
 	synchronize_net();
@@ -47,24 +54,27 @@ static void igb_txrx_ring_disable(struct igb_adapter *adapter, u16 qid)
 	/* Rx/Tx share the same napi context. */
 	napi_disable(&rx_ring->q_vector->napi);
 
-	igb_clean_tx_ring(tx_ring);
+	if (tx_ring) {
+		igb_clean_tx_ring(tx_ring);
+		memset(&tx_ring->tx_stats, 0, sizeof(tx_ring->tx_stats));
+	}
 	igb_clean_rx_ring(rx_ring);
-
 	memset(&rx_ring->rx_stats, 0, sizeof(rx_ring->rx_stats));
-	memset(&tx_ring->tx_stats, 0, sizeof(tx_ring->tx_stats));
 }
 
 static void igb_txrx_ring_enable(struct igb_adapter *adapter, u16 qid)
 {
-	struct igb_ring *tx_ring = adapter->tx_ring[qid];
+	struct igb_ring *tx_ring = igb_xsk_tx_ring(adapter, qid);
 	struct igb_ring *rx_ring = adapter->rx_ring[qid];
 
-	igb_configure_tx_ring(adapter, tx_ring);
+	if (tx_ring)
+		igb_configure_tx_ring(adapter, tx_ring);
 	igb_configure_rx_ring(adapter, rx_ring);
 
 	synchronize_net();
 
-	clear_bit(IGB_RING_FLAG_TX_DISABLED, &tx_ring->flags);
+	if (tx_ring)
+		clear_bit(IGB_RING_FLAG_TX_DISABLED, &tx_ring->flags);
 
 	/* call igb_desc_unused which always leaves
 	 * at least 1 descriptor unused to make sure
@@ -148,7 +158,12 @@ static int igb_xsk_pool_disable(struct igb_adapter *adapter, u16 qid)
 		return -EINVAL;
 
 	rx_ring = adapter->rx_ring[qid];
-	if_running = netif_running(adapter->netdev) && igb_xdp_is_enabled(adapter);
+	/* The stack can know more queues than the device has, e.g. after a
+	 * fallback to fewer queues on resume: skip the rings it doesn't have.
+	 */
+	if_running = netif_running(adapter->netdev) &&
+		     igb_xdp_is_enabled(adapter) &&
+		     qid < adapter->num_rx_queues;
 	if (if_running)
 		igb_txrx_ring_disable(adapter, qid);
 
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH net v4 2/4] igb: fix RTNL assertion when resuming from runtime suspend
  2026-11-20 21:01 [PATCH net v4 0/4] igb: fix runtime PM resume issues Antonio Quartulli
  2026-11-20 21:01 ` [PATCH net v4 1/4] igb: don't touch rings that don't exist when disabling an XSK pool Antonio Quartulli
@ 2026-11-20 21:01 ` Antonio Quartulli
  2026-11-20 21:01 ` [PATCH net v4 3/4] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
  2026-11-20 21:01 ` [PATCH net v4 4/4] igb: only allow runtime PM if the device can wake up Antonio Quartulli
  3 siblings, 0 replies; 10+ messages in thread
From: Antonio Quartulli @ 2026-11-20 21:01 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, Heiner Kallweit, netdev, linux-kernel,
	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. 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>
---
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(-)

diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h
index 8c9b020..79d7fcc 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 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 d4a897a..2f51edc 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 *);
@@ -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->rtnl_resume_task, igb_rtnl_resume_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->rtnl_resume_task);
 
 #ifdef CONFIG_IGB_DCA
 	if (adapter->flags & IGB_FLAG_DCA_ENABLED) {
@@ -4123,10 +4126,31 @@ 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.
+ */
+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();
+	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");
+	}
+	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
  *
@@ -4136,7 +4160,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;
@@ -4179,16 +4204,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);
@@ -4242,7 +4266,7 @@ err_setup_tx:
 
 int igb_open(struct net_device *netdev)
 {
-	return __igb_open(netdev, false);
+	return __igb_open(netdev, false, true);
 }
 
 /**
@@ -6617,12 +6641,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,
@@ -6636,6 +6655,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));
 }
 
@@ -9639,8 +9669,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 related	[flat|nested] 10+ messages in thread

* [PATCH net v4 3/4] igb: link queues to NAPIs under RTNL after runtime resume
  2026-11-20 21:01 [PATCH net v4 0/4] igb: fix runtime PM resume issues Antonio Quartulli
  2026-11-20 21:01 ` [PATCH net v4 1/4] igb: don't touch rings that don't exist when disabling an XSK pool Antonio Quartulli
  2026-11-20 21:01 ` [PATCH net v4 2/4] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
@ 2026-11-20 21:01 ` Antonio Quartulli
  2026-11-24 21:38   ` netdev-bot+sashiko
  2026-11-20 21:01 ` [PATCH net v4 4/4] igb: only allow runtime PM if the device can wake up Antonio Quartulli
  3 siblings, 1 reply; 10+ messages in thread
From: Antonio Quartulli @ 2026-11-20 21:01 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, Kurt Kanzenbach, Joe Damato, netdev,
	linux-kernel, 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.
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.

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>
---
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(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 2f51edc..6196d7a 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -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. */
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH net v4 4/4] igb: only allow runtime PM if the device can wake up
  2026-11-20 21:01 [PATCH net v4 0/4] igb: fix runtime PM resume issues Antonio Quartulli
                   ` (2 preceding siblings ...)
  2026-11-20 21:01 ` [PATCH net v4 3/4] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
@ 2026-11-20 21:01 ` Antonio Quartulli
  2026-11-24 21:38   ` netdev-bot+sashiko
  3 siblings, 1 reply; 10+ messages in thread
From: Antonio Quartulli @ 2026-11-20 21:01 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, netdev, linux-kernel, 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.

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.

Fixes: 749ab2cd1270 ("igb: add basic runtime PM support")
Cc: stable@vger.kernel.org
Closes: https://bugzilla.ipfire.org/show_bug.cgi?id=13562
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
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(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 6196d7a..72eeaf3 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -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
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH net v4 1/4] igb: don't touch rings that don't exist when disabling an XSK pool
  2026-11-20 21:01 ` [PATCH net v4 1/4] igb: don't touch rings that don't exist when disabling an XSK pool Antonio Quartulli
@ 2026-11-20 23:17   ` Janis Edvarts Lacis
  2026-11-23 20:28     ` Antonio Quartulli
  2026-11-24 21:38   ` netdev-bot+sashiko
  1 sibling, 1 reply; 10+ messages in thread
From: Janis Edvarts Lacis @ 2026-11-20 23:17 UTC (permalink / raw)
  To: Antonio Quartulli
  Cc: intel-wired-lan, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
	John Fastabend, Stanislav Fomichev, Sriram Yagnaraman,
	Kurt Kanzenbach, Maciej Fijalkowski, netdev, linux-kernel, bpf,
	stable

On 20 Nov 22:01, Antonio Quartulli wrote:
>xsk_get_pool_from_qid() checks the queue id against the stack's real
>queue counts, which can be higher than the number of rings the device
>has: on 82576, enabling VFs leaves a single Tx queue while keeping two
>Rx queues, and igb can fall back from MSI-X to MSI with a single queue
>on resume. Disabling the pool of such a queue, e.g. one bound to queue 1
>before enabling VFs, then passes a NULL Tx ring to
>igb_txrx_ring_disable().
>
>Only disable and re-enable the rings the device has: skip the queue if
>it has no Rx ring, and only the Tx part if it has no Tx ring, so that
>an Rx ring using the pool still stops using it.
>

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net v4 1/4] igb: don't touch rings that don't exist when disabling an XSK pool
  2026-11-20 23:17   ` Janis Edvarts Lacis
@ 2026-11-23 20:28     ` Antonio Quartulli
  0 siblings, 0 replies; 10+ messages in thread
From: Antonio Quartulli @ 2026-11-23 20:28 UTC (permalink / raw)
  To: Janis Edvarts Lacis
  Cc: intel-wired-lan, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
	John Fastabend, Stanislav Fomichev, Sriram Yagnaraman,
	Kurt Kanzenbach, Maciej Fijalkowski, netdev, linux-kernel, bpf,
	stable



On 21/11/2026 00:17, Janis Edvarts Lacis wrote:
> On 20 Nov 22:01, Antonio Quartulli wrote:
>> xsk_get_pool_from_qid() checks the queue id against the stack's real
>> queue counts, which can be higher than the number of rings the device
>> has: on 82576, enabling VFs leaves a single Tx queue while keeping two
>> Rx queues, and igb can fall back from MSI-X to MSI with a single queue
>> on resume. Disabling the pool of such a queue, e.g. one bound to queue 1
>> before enabling VFs, then passes a NULL Tx ring to
>> igb_txrx_ring_disable().
>>
>> Only disable and re-enable the rings the device has: skip the queue if
>> it has no Rx ring, and only the Tx part if it has no Tx ring, so that
>> an Rx ring using the pool still stops using it.
>>
> 
> 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 :)

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,

-- 
Antonio Quartulli

CEO and Co-Founder
Mandelbit Srl
https://www.mandelbit.com


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net v4 1/4] igb: don't touch rings that don't exist when disabling an XSK pool
  2026-11-20 21:01 ` [PATCH net v4 1/4] igb: don't touch rings that don't exist when disabling an XSK pool Antonio Quartulli
  2026-11-20 23:17   ` Janis Edvarts Lacis
@ 2026-11-24 21:38   ` netdev-bot+sashiko
  1 sibling, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 21:38 UTC (permalink / raw)
  To: antonio
  Cc: intel-wired-lan, anthony.l.nguyen, przemyslaw.kitszel,
	andrew+netdev, davem, edumazet, kuba, pabeni, janislacis06,
	netdev, linux-kernel, stable

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.

Link: https://lore.kernel.org/netdev/20261116153041.3002666-2-antonio@mandelbit.com/

> diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c b/drivers/net/ethernet/intel/igb/igb_xsk.c
> index ce4a7b58cad2f..3b4212a9521e0 100644
> --- a/drivers/net/ethernet/intel/igb/igb_xsk.c
> +++ b/drivers/net/ethernet/intel/igb/igb_xsk.c
> @@ -31,15 +31,22 @@ static int igb_realloc_rx_buffer_info(struct igb_ring *ring, bool pool_present)
>  	return 0;
>  }
>  
> +/* With VFs, the device has a single Tx queue but can have more Rx queues */
> +static struct igb_ring *igb_xsk_tx_ring(struct igb_adapter *adapter, u16 qid)
> +{
> +	return qid < adapter->num_tx_queues ? adapter->tx_ring[qid] : NULL;
> +}
> +

[ ... ]

> @@ -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.

[ ... ]

> @@ -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.

>  	if (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.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120210134.133238-1-antonio%40mandelbit.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net v4 3/4] igb: link queues to NAPIs under RTNL after runtime resume
  2026-11-20 21:01 ` [PATCH net v4 3/4] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
@ 2026-11-24 21:38   ` netdev-bot+sashiko
  0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 21:38 UTC (permalink / raw)
  To: antonio
  Cc: intel-wired-lan, anthony.l.nguyen, przemyslaw.kitszel,
	andrew+netdev, davem, edumazet, kuba, pabeni, janislacis06,
	netdev, linux-kernel, stable

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.

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 6b299a1429a8e..4617aba5759d2 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -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)
>  {
> @@ -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().

[ ... ]

> @@ -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?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120210134.133238-1-antonio%40mandelbit.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net v4 4/4] igb: only allow runtime PM if the device can wake up
  2026-11-20 21:01 ` [PATCH net v4 4/4] igb: only allow runtime PM if the device can wake up Antonio Quartulli
@ 2026-11-24 21:38   ` netdev-bot+sashiko
  0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 21:38 UTC (permalink / raw)
  To: antonio
  Cc: intel-wired-lan, anthony.l.nguyen, przemyslaw.kitszel,
	andrew+netdev, davem, edumazet, kuba, pabeni, janislacis06,
	netdev, linux-kernel, stable

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.

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 4617aba5759d2..36bd395e36dab 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -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);

[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.

>  #ifdef CONFIG_IGB_HWMON
>  	igb_sysfs_exit(adapter);
>  #endif

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120210134.133238-1-antonio%40mandelbit.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-11-24 21:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 21:01 [PATCH net v4 0/4] igb: fix runtime PM resume issues Antonio Quartulli
2026-11-20 21:01 ` [PATCH net v4 1/4] igb: don't touch rings that don't exist when disabling an XSK pool Antonio Quartulli
2026-11-20 23:17   ` Janis Edvarts Lacis
2026-11-23 20:28     ` Antonio Quartulli
2026-11-24 21:38   ` netdev-bot+sashiko
2026-11-20 21:01 ` [PATCH net v4 2/4] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
2026-11-20 21:01 ` [PATCH net v4 3/4] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
2026-11-24 21:38   ` netdev-bot+sashiko
2026-11-20 21:01 ` [PATCH net v4 4/4] igb: only allow runtime PM if the device can wake up Antonio Quartulli
2026-11-24 21:38   ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox