πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
3 messages
3 total messages Started by Antonio Quartulli Tue, 24 Nov 2026 23:57
[PATCH net v5 2/6] igb: fix RTNL assertion when resuming from runtime suspend
#22187
Author: Antonio Quartulli
Date: Tue, 24 Nov 2026 23:57
213 lines
17143 bytes
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>
---
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 | 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
Re: [PATCH net v5 2/6] igb: fix RTNL assertion when resuming from runtime suspend
#23877
Author: Janis Edvarts Lacis
Date: Sat, 28 Nov 2026 13:37
216 lines
19487 bytes
On 25 Nov 00:57, Antonio Quartulli wrote:
>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>
>---
>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 | 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
>
Reviewed-by: Janis Edvarts Lacis <janislacis06@gmail.com>
Re: [PATCH net v5 2/6] igb: fix RTNL assertion when resuming from runtime suspend
#24026
Author: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 00:37
198 lines
14844 bytes
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] On runtime resume, __igb_resume() calls __igb_open(netdev, true,
  false).

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch's
  runtime-resume design depends on it and it stays reachable at the end…

--

igb: fix RTNL assertion when resuming from runtime suspend

On runtime resume, __igb_open() no longer sets the real queue counts.
They are now set from a new work item, igb_rtnl_resume_task(), which takes
RTNL. Until that work runs, igb_xmit_frame() drops packets for stack
queues the device doesn't have.

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 131df3e09ba14..6b299a1429a8e 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c

[ ... ]

> @@ -4122,10 +4125,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");

[Severity: Low]
If netif_set_real_num_queues() fails here, does the stack stay out of step
with the hardware until the next ifdown/ifup or system resume?

On runtime resume, __igb_resume() calls __igb_open(netdev, true, false).
That skips the queue count update, but it still enables every ring,
programs RSS across adapter->num_rx_queues through
igb_configure()->igb_setup_mrqc(), and starts all stack TX queues.

Here is one way to reach it. An earlier runtime resume falls back from
MSI-X to MSI, so this work lowers real_num_{tx,rx}_queues to 1. A later
runtime resume gets MSI-X with N queues again, so the counts have to go
up. Raising them can fail with -ENOMEM while allocating the sysfs queue
kobjects or XPS maps.

When that happens, the NIC has N rings armed and RSS spreads RX over N
queues, but the stack only sees one TX queue and one RX queue. TX uses
only ring 0, RX skbs carry queue indices >= real_num_rx_queues, and
per-queue reporting is wrong.

Before this patch, a failure in __igb_open() unwound through
err_set_queues, so the stack and the hardware stayed consistent.

The same mismatch also exists, without any failure, between the resume
and the moment this work runs. The commit message only covers the
opposite direction, where the device has fewer queues than the stack. At
the end of the series this failure is still only logged.

Should this retry, or bring the hardware configuration back in line with
the stack?

> +	}
> +	rtnl_unlock();
> +}
> +

[ ... ]

> @@ -4178,16 +4203,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;
> +	}

[ ... ]

> @@ -9638,8 +9668,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);
> +	}

[Severity: High]
This is a pre-existing issue and was not introduced by this patch.
However, the runtime resume design here relies on it, and it can still
be reached at the end of the series. Can the runtime suspend path
deadlock against RTNL holders?

igb_runtime_suspend()->__igb_shutdown(pdev, NULL, 1) always takes RTNL:

drivers/net/ethernet/intel/igb/igb_main.c:__igb_shutdown() {
    ...
	rtnl_lock();
	netif_device_detach(netdev);
    ...
}

rpm_suspend() sets runtime_status to RPM_SUSPENDING before it calls the
callback. While the callback is blocked in rtnl_lock(), any RTNL holder
that does a synchronous runtime resume of the same PCI device waits in
rpm_resume() with no timeout:

drivers/base/power/runtime.c:rpm_resume() {
    ...
		for (;;) {
			prepare_to_wait(&dev->power.wait_queue, &wait,
					TASK_UNINTERRUPTIBLE);
			if (dev->power.runtime_status != RPM_RESUMING &&
			    dev->power.runtime_status != RPM_SUSPENDING)
				break;
    ...
}

Several RTNL holders do this. One is ethnl_ops_begin():

net/ethtool/netlink.c:ethnl_ops_begin() {
    ...
	if (dev->dev.parent)
		pm_runtime_get_sync(dev->dev.parent);

	netdev_assert_locked_ops_compat(dev);
    ...
}

Others are the ethtool ioctl path and
dev_close()->igb_close()->__igb_close(netdev, false), which calls
pm_runtime_get_sync(). igb_xdp() joins them once the later commit "igb:
resume the device before changing XDP or XSK settings" is applied.

The suspend waits for RTNL, and the RTNL holder waits for the suspend to
finish. Every other rtnl_lock() caller then hangs.

Ethtool netlink GET requests don't need CAP_NET_ADMIN. Once runtime PM is
enabled (power/control=auto) and the link is down, an unprivileged user
could hit this race.

This is the suspend-side counterpart of the resume deadlock fixed by
ac8c58f5b535. The commit message of "igb: resume the device before
changing XDP or XSK settings" says this deadlock remains, and no patch in
the series fixes it.

At the end of the series, __igb_shutdown() also calls
cancel_work_sync(&adapter->rtnl_resume_task) before rtnl_lock(). That
work takes RTNL, so does it become part of the same dependency cycle?

>  
>  	if (!err)
>  		netif_device_attach(netdev);

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

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads