mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net 1/3] igb: fix RTNL assertion when resuming from runtime suspend
@ 2026-11-13 10:58 Antonio Quartulli
  2026-11-13 10:58 ` [PATCH net 2/3] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Antonio Quartulli @ 2026-11-13 10:58 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,
	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".

The queue counts only change on paths that re-open the device under
RTNL (ethtool -L, SR-IOV reconfiguration): set them in igb_open() only,
as igc does since commit 6f31d6b643a3 ("igc: Refactor runtime power
management flow").

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>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 24 +++++++++++------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 78f0786..bd1185d 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -4178,17 +4178,6 @@ 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;
-
 	/* From here on the code is the same as igb_up() */
 	clear_bit(__IGB_DOWN, &adapter->state);
 
@@ -4223,8 +4212,6 @@ static int __igb_open(struct net_device *netdev, bool resuming)
 
 	return 0;
 
-err_set_queues:
-	igb_free_irq(adapter);
 err_req_irq:
 	igb_release_hw_control(adapter);
 	igb_power_down_link(adapter);
@@ -4241,6 +4228,17 @@ err_setup_tx:
 
 int igb_open(struct net_device *netdev)
 {
+	struct igb_adapter *adapter = netdev_priv(netdev);
+	int err;
+
+	/* Notify the stack of the actual queue counts. */
+	err = netif_set_real_num_queues(netdev, adapter->num_tx_queues,
+					adapter->num_rx_queues);
+	if (err) {
+		netdev_err(netdev, "error setting real queue count\n");
+		return err;
+	}
+
 	return __igb_open(netdev, false);
 }
 
-- 
2.56.0


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

* [PATCH net 2/3] igb: link queues to NAPIs under RTNL after runtime resume
  2026-11-13 10:58 [PATCH net 1/3] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
@ 2026-11-13 10:58 ` Antonio Quartulli
  2026-11-17 11:18   ` netdev-bot+sashiko
  2026-11-13 10:58 ` [PATCH net 3/3] igb: only allow runtime PM if the device can wake up Antonio Quartulli
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Antonio Quartulli @ 2026-11-13 10:58 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,
	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".

Don't link them in __igb_open() when resuming: do it right away on
system resume (RTNL held) and from a work item taking RTNL on runtime
resume. The links can't be kept across a suspend, because
__igb_shutdown() frees the q_vectors. These are only freed under RTNL
with __IGB_DOWN set, so the work item checks __IGB_DOWN under RTNL.

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>
---
Note: igc may have the same issue: __igc_open() also links queues to NAPIs
(igc_set_queue_napi()) on the RTNL-less runtime resume path. We didn't
have igc hardware to test a fix with, so no igc patch is sent for now.

 drivers/net/ethernet/intel/igb/igb.h      |  1 +
 drivers/net/ethernet/intel/igb/igb_main.c | 38 +++++++++++++++++++++--
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h
index 0fff1df..ea2d739 100644
--- a/drivers/net/ethernet/intel/igb/igb.h
+++ b/drivers/net/ethernet/intel/igb/igb.h
@@ -585,6 +585,7 @@ struct igb_adapter {
 
 	struct work_struct reset_task;
 	struct work_struct watchdog_task;
+	struct work_struct queue_napi_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 bd1185d..4d97399 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -2115,6 +2115,30 @@ void igb_set_queue_napi(struct igb_adapter *adapter, int vector,
 				     NETDEV_QUEUE_TYPE_TX, napi);
 }
 
+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);
+}
+
+/* Linking queues to NAPIs requires RTNL, which isn't held when resuming
+ * from runtime suspend: do it from here instead. The q_vectors are only
+ * freed under RTNL with __IGB_DOWN set, so checking it under RTNL is safe.
+ */
+static void igb_queue_napi_task(struct work_struct *work)
+{
+	struct igb_adapter *adapter = container_of(work, struct igb_adapter,
+						   queue_napi_task);
+
+	rtnl_lock();
+	if (!test_bit(__IGB_DOWN, &adapter->state) &&
+	    netif_running(adapter->netdev))
+		igb_link_queue_napis(adapter);
+	rtnl_unlock();
+}
+
 /**
  *  igb_up - Open the interface and prepare it to handle traffic
  *  @adapter: board private structure
@@ -3426,6 +3450,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->queue_napi_task, igb_queue_napi_task);
 
 	/* Initialize link properties that are user-changeable */
 	adapter->fc_autoneg = true;
@@ -3890,6 +3915,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->queue_napi_task);
 
 #ifdef CONFIG_IGB_DCA
 	if (adapter->flags & IGB_FLAG_DCA_ENABLED) {
@@ -4184,7 +4210,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 (!resuming)
+			igb_set_queue_napi(adapter, i, napi);
 	}
 
 	/* Clear any pending interrupts. */
@@ -9631,8 +9658,15 @@ static int __igb_resume(struct device *dev, bool rpm)
 
 	if (!rpm)
 		rtnl_lock();
-	if (!err && netif_running(netdev))
+	if (!err && netif_running(netdev)) {
 		err = __igb_open(netdev, true);
+		if (!err) {
+			if (rpm)
+				schedule_work(&adapter->queue_napi_task);
+			else
+				igb_link_queue_napis(adapter);
+		}
+	}
 
 	if (!err)
 		netif_device_attach(netdev);
-- 
2.56.0


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

* [PATCH net 3/3] igb: only allow runtime PM if the device can wake up
  2026-11-13 10:58 [PATCH net 1/3] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
  2026-11-13 10:58 ` [PATCH net 2/3] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
@ 2026-11-13 10:58 ` Antonio Quartulli
  2026-11-17 11:18   ` netdev-bot+sashiko
  2026-11-13 11:03 ` [PATCH net 1/3] igb: fix RTNL assertion when resuming from runtime suspend netdev-bot+sinfo
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Antonio Quartulli @ 2026-11-13 10:58 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, Yan,
	Zheng, 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.

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>
---
Note: igc may have the same issue: igc_probe() also allows runtime PM
regardless of pci_dev_run_wake(). We didn't have igc hardware to test a
fix with, so no igc patch is sent for now.

 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 4d97399..59f59da 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -3677,7 +3677,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:
@@ -3900,7 +3904,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.0


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

* Re: [PATCH net 1/3] igb: fix RTNL assertion when resuming from runtime suspend
  2026-11-13 10:58 [PATCH net 1/3] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
  2026-11-13 10:58 ` [PATCH net 2/3] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
  2026-11-13 10:58 ` [PATCH net 3/3] igb: only allow runtime PM if the device can wake up Antonio Quartulli
@ 2026-11-13 11:03 ` netdev-bot+sinfo
  2026-11-15 19:37 ` Antonio Quartulli
  2026-11-17 11:18 ` netdev-bot+sashiko
  4 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sinfo @ 2026-11-13 11:03 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,
	Heiner Kallweit, netdev, linux-kernel, stable

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - What hardware the change was tested on. For driver fixes please
   mention the device (and if relevant firmware version) used for
   testing, or say that the change was not tested on real hardware.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.

The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

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

* Re: [PATCH net 1/3] igb: fix RTNL assertion when resuming from runtime suspend
  2026-11-13 10:58 [PATCH net 1/3] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
                   ` (2 preceding siblings ...)
  2026-11-13 11:03 ` [PATCH net 1/3] igb: fix RTNL assertion when resuming from runtime suspend netdev-bot+sinfo
@ 2026-11-15 19:37 ` Antonio Quartulli
  2026-11-17 11:18 ` netdev-bot+sashiko
  4 siblings, 0 replies; 8+ messages in thread
From: Antonio Quartulli @ 2026-11-15 19:37 UTC (permalink / raw)
  To: intel-wired-lan, netdev
  Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Heiner Kallweit,
	linux-kernel, stable

On 13/11/2026 11:58, 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".
> 
> The queue counts only change on paths that re-open the device under
> RTNL (ethtool -L, SR-IOV reconfiguration): set them in igb_open() only,
> as igc does since commit 6f31d6b643a3 ("igc: Refactor runtime power
> management flow").
> 
> 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>
Sashiko reported an interesting finding that is worth fixing.
Will spin v2.

pw-bot: cr

-- 
Antonio Quartulli

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


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

* Re: [PATCH net 1/3] igb: fix RTNL assertion when resuming from runtime suspend
  2026-11-13 10:58 [PATCH net 1/3] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
                   ` (3 preceding siblings ...)
  2026-11-15 19:37 ` Antonio Quartulli
@ 2026-11-17 11:18 ` netdev-bot+sashiko
  4 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-11-17 11:18 UTC (permalink / raw)
  To: antonio
  Cc: intel-wired-lan, anthony.l.nguyen, przemyslaw.kitszel,
	andrew+netdev, davem, edumazet, kuba, pabeni, zheng.z.yan,
	netdev, linux-kernel, stable

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 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).

- [High] Commit "igb: fix RTNL assertion when resuming from runtime
  suspend" moves netif_set_real_num_queues() out of __igb_open() and…
- [High] The commit message says "The queue counts only change on paths
  that re-open the device under RTNL (ethtool -L, SR-IOV…
- [Medium] Concern (baseline decision: false, resolved later in the
  series).

--

igb: fix RTNL assertion when resuming from runtime suspend

This patch moves the netif_set_real_num_{tx,rx}_queues() calls out of
__igb_open() and into igb_open(). The runtime resume path runs without
RTNL, so it no longer triggers an RTNL assertion. igb_open() now publishes
the queue counts with netif_set_real_num_queues() before it calls
__igb_open().

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..028cdd90522cb 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -4178,17 +4178,6 @@ 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;
> -

[Severity: High]
The commit message says:

  The queue counts only change on paths that re-open the device under
  RTNL (ethtool -L, SR-IOV reconfiguration)

Does that hold for suspend and resume? Every suspend goes through
__igb_shutdown(), which calls igb_clear_interrupt_scheme(). That frees
the rings and sets num_tx_queues and num_rx_queues to zero in
igb_free_q_vectors().

On resume, __igb_resume() rebuilds them:

__igb_resume()
    igb_init_interrupt_scheme(adapter, true)
        igb_set_interrupt_capability()
            pci_enable_msix_range() fails
            msi_only:
                adapter->num_rx_queues = 1;
                adapter->num_tx_queues = 1;
                adapter->num_q_vectors = 1;
    __igb_open(netdev, true)

Before this patch, __igb_open(netdev, true) updated
dev->real_num_{tx,rx}_queues after that. Now only igb_open() does, and the
resume path never calls igb_open(). The same is true when the MSI-X to MSI
fallback in igb_request_irq() runs inside __igb_open(netdev, true).

In that case, can the stack keep a larger real_num_tx_queues while only
tx_ring[0] exists? igb_tx_queue_mapping() folds the stale indices onto
ring 0:

	if (r_idx >= adapter->num_tx_queues)
		r_idx = r_idx % adapter->num_tx_queues;

Each stack txq has its own _xmit_lock. Couldn't several CPUs then run
igb_xmit_frame_ring() on tx_ring[0] at the same time, racing on
next_to_use, tx_buffer_info[], the tail write and the BQL state of txq 0?

__igb_maybe_stop_tx() and igb_clean_tx_irq() also only stop and wake
subqueue 0. real_num_rx_queues would likewise stay larger than the single
configured RX ring.

Runtime resume happens on every link-up after a cable unplug, and each
cycle releases and re-acquires MSI-X, so this can happen more than once.

On system resume (rpm == false), __igb_resume() already holds RTNL around
__igb_open(). Did that path need to lose the update to fix the assertion?

[Severity: Medium]
Will runtime resume still hit an RTNL assertion with this patch applied?
Later in __igb_open(), igb_set_queue_napi() is still called
unconditionally:

	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(), and that calls
netdev_assert_locked_ops_compat_or_invisible(). For igb, that check is
ASSERT_RTNL(). __igb_resume() only takes rtnl_lock() when !rpm, so this
chain runs without RTNL:

igb_runtime_resume()
    __igb_resume(dev, true)
        __igb_open(netdev, true)
            igb_set_queue_napi()
                netif_queue_set_napi()
                    ASSERT_RTNL()

It also updates the queue napi pointers without RTNL.

The next patch in the series, "igb: link queues to NAPIs under RTNL after
runtime resume", fixes this. It calls igb_set_queue_napi() only when
!resuming, and links the NAPIs under RTNL from a new igb_queue_napi_task
work item. So the problem is gone by the end of the series. With only this
commit applied, though, the "RTNL: assertion failed" warning from the
commit message still looks reachable on runtime resume.

[ ... ]

> @@ -4241,6 +4228,17 @@ static int __igb_open(struct net_device *netdev, bool resuming)
>  
>  int igb_open(struct net_device *netdev)
>  {
> +	struct igb_adapter *adapter = netdev_priv(netdev);
> +	int err;
> +
> +	/* Notify the stack of the actual queue counts. */
> +	err = netif_set_real_num_queues(netdev, adapter->num_tx_queues,
> +					adapter->num_rx_queues);

[Severity: High]
Can the queue counts still change after this call? __igb_open() calls
igb_request_irq(). If igb_request_msix() fails, it falls back to MSI and
rebuilds the interrupt scheme:

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);
    ...
}

When msix is false, igb_set_interrupt_capability() takes the msi_only path.
That sets num_tx_queues, num_rx_queues and num_q_vectors to 1.

Before this patch, the netif_set_real_num_{tx,rx}_queues() calls ran after
igb_request_irq() and saw the reduced count. Now dev->real_num_tx_queues
keeps the value set here (for example 4 or 8), while only tx_ring[0]
exists.

Would igb_tx_queue_mapping() then fold txq 1..N-1 onto tx_ring[0]? Each of
those stack txqs takes a different _xmit_lock, so igb_xmit_frame_ring()
could run concurrently on the same ring. real_num_rx_queues would also
stay larger than the single configured RX ring.

[ ... ]

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

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

* Re: [PATCH net 2/3] igb: link queues to NAPIs under RTNL after runtime resume
  2026-11-13 10:58 ` [PATCH net 2/3] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
@ 2026-11-17 11:18   ` netdev-bot+sashiko
  0 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-11-17 11:18 UTC (permalink / raw)
  To: antonio
  Cc: intel-wired-lan, anthony.l.nguyen, przemyslaw.kitszel,
	andrew+netdev, davem, edumazet, kuba, pabeni, zheng.z.yan,
	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 new comment above igb_queue_napi_task() says: "The
  q_vectors are only freed under RTNL with __IGB_DOWN set, so checking…

--

igb: link queues to NAPIs under RTNL after runtime resume

When __igb_open() is called on the resume path, it no longer links queues
to NAPIs. On system resume the links are set directly with RTNL held. On
runtime resume a new work item takes RTNL and sets them, checking
__IGB_DOWN first so that it does not touch freed q_vectors.

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 028cdd90522cb..f1ce9aa696ab7 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -2115,6 +2115,30 @@ void igb_set_queue_napi(struct igb_adapter *adapter, int vector,
>  				     NETDEV_QUEUE_TYPE_TX, napi);
>  }
>
> +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);
> +}
> +
> +/* Linking queues to NAPIs requires RTNL, which isn't held when resuming
> + * from runtime suspend: do it from here instead. The q_vectors are only
> + * freed under RTNL with __IGB_DOWN set, so checking it under RTNL is safe.
> + */
> +static void igb_queue_napi_task(struct work_struct *work)
> +{
> +	struct igb_adapter *adapter = container_of(work, struct igb_adapter,
> +						   queue_napi_task);
> +
> +	rtnl_lock();
> +	if (!test_bit(__IGB_DOWN, &adapter->state) &&
> +	    netif_running(adapter->netdev))
> +		igb_link_queue_napis(adapter);
> +	rtnl_unlock();
> +}

[Severity: Medium]
Is this statement accurate: "The q_vectors are only freed under RTNL with
__IGB_DOWN set"? The commit message makes the same claim.

On the runtime resume path, __igb_resume(dev, rpm=true) runs without RTNL.
It calls igb_init_interrupt_scheme(adapter, true), which sets num_q_vectors
and allocates q_vector[]. It then calls __igb_open(netdev, true). If MSI-X
setup fails there, igb_request_irq() frees and reallocates the q_vectors:

igb_request_irq() {
    ...
	if (adapter->flags & IGB_FLAG_HAS_MSIX) {
		err = igb_request_msix(adapter);
		if (!err)
			goto request_done;
		/* fall back to MSI */
		...
		igb_clear_interrupt_scheme(adapter);
		err = igb_init_interrupt_scheme(adapter, false);
    ...
}

igb_clear_interrupt_scheme()->igb_free_q_vectors() sets num_q_vectors to 0
and frees each q_vector[i]. The fallback then reallocates them with
num_q_vectors set to 1. None of this runs under RTNL.

igb_remove() also frees the q_vectors without RTNL. It is only safe because
set_bit(__IGB_DOWN) and cancel_work_sync(&adapter->queue_napi_task) run
before igb_clear_interrupt_scheme().

So RTNL does not seem to serialize igb_queue_napi_task() against the
runtime resume writer. The only handoff between them is the __IGB_DOWN bit.
The writer uses a plain clear_bit() in __igb_open() and the reader uses a
plain test_bit() here. Neither provides release or acquire ordering.

Can the following sequence happen?

  runtime resume #1 queues queue_napi_task

  the work is delayed (on rtnl_lock() or in the workqueue) past the
  5 second pm_schedule_suspend() in igb_runtime_idle()

  runtime suspend #2 takes RTNL, igb_down() sets __IGB_DOWN and
  igb_clear_interrupt_scheme() NULLs q_vector[]

  the work takes RTNL while runtime resume #2, without RTNL, reallocates
  the q_vectors (possibly through the MSI fallback) and clears __IGB_DOWN

On weakly ordered CPUs such as arm64 or POWER, the work could see
__IGB_DOWN as cleared but still load stale num_q_vectors or q_vector[i]
values. For example, it could read num_q_vectors as N from before the
fallback and q_vector[1] as NULL from after it.

igb_set_queue_napi() would then dereference q_vector->rx.ring through a
NULL pointer, or through a pointer that was already passed to kfree_rcu().
The work does not hold rcu_read_lock().

This looks like a flag being used as a lock. One option is to pair
clear_bit_unlock() (or smp_mb__before_atomic() plus clear_bit()) in
__igb_open() with test_bit_acquire() here. Another is to rebuild the
q_vectors on the rpm resume path under the same lock the work takes.

At minimum, could the comment and the commit message state the real
invariant? That is, the q_vectors only change while __IGB_DOWN is set, and
igb_remove() cancels the work before it frees them.

[ ... ]

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

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

* Re: [PATCH net 3/3] igb: only allow runtime PM if the device can wake up
  2026-11-13 10:58 ` [PATCH net 3/3] igb: only allow runtime PM if the device can wake up Antonio Quartulli
@ 2026-11-17 11:18   ` netdev-bot+sashiko
  0 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-11-17 11:18 UTC (permalink / raw)
  To: antonio
  Cc: intel-wired-lan, anthony.l.nguyen, przemyslaw.kitszel,
	andrew+netdev, davem, edumazet, kuba, pabeni, zheng.z.yan,
	netdev, linux-kernel, stable

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · 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] Probe and remove can disagree about the runtime PM usage
  count.
- [Medium] The patch decides whether igb may runtime-suspend from one
  pci_dev_run_wake() check in igb_probe().

--

igb: only allow runtime PM if the device can wake up

This patch changes igb_probe() so it drops the probe-time runtime PM
usage reference only when pci_dev_run_wake() is true. Devices that can't
signal a wake-up from D3 therefore no longer runtime suspend.
igb_remove() takes the reference back under the same condition.

> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index f1ce9aa696ab7..145daee832640 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -3677,7 +3677,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);

[Severity: Medium]
Is one check at probe time enough to close the bug described in the
commit message?

pci_dev_run_wake() depends on pci_target_state(), and that can change
after probe. On ACPI platforms, acpi_pci_choose_state() limits the
target to D3hot only when d3cold_allowed is clear:

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;
    ...
}

Root can change d3cold_allowed through sysfs while igb is bound.

Here is one sequence:

1. igb binds with d3cold_allowed=0. The target is D3hot and PME is
   supported from D3hot, so the probe check passes and the reference is
   dropped.
2. Root writes d3cold_allowed=1, so the target becomes D3cold.
3. The part doesn't support PME from D3cold.

On the next link-down, igb_runtime_idle() or the watchdog schedules a
suspend. igb_runtime_suspend()->__igb_shutdown() arms the WUFC
link-change filter without any PCI-level check. Then
pci_finish_runtime_suspend() runs:

drivers/pci/pci.c:pci_finish_runtime_suspend() {
    ...
	__pci_enable_wake(dev, target_state, pci_dev_run_wake(dev));

	error = pci_set_power_state(dev, target_state);
    ...
}

pci_dev_run_wake() is now false. Wouldn't the device then go into D3cold
with PME disarmed? The port would stay down after the cable is plugged
back in, until user space resumes it.

Could igb_runtime_idle() or igb_runtime_suspend() return -EBUSY when
pci_dev_run_wake() is false? That would cover this case and also remove
the need for the separate probe and remove accounting below.

>  	return 0;
>  
>  err_register:
> @@ -3899,7 +3903,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 igb_probe() and igb_remove() disagree about the runtime PM usage
count here?

igb_remove() calls pci_dev_run_wake() again instead of reusing the
decision made in igb_probe(). The result comes from
pci_pme_capable(dev, pci_target_state(dev, true)), and the target state
can change while the driver is bound.

One way it can change is a write to d3cold_allowed through
d3cold_allowed_store(). That changes what acpi_pci_choose_state()
returns, as described above.

Another way is surprise removal of a runtime-suspended igb that the
platform does not manage. pci_device_remove() calls
pm_runtime_get_sync() before drv->remove(), and during that resume
pci_power_up() does:

drivers/pci/pci.c:pci_power_up() {
    ...
	if (pci_dev_is_disconnected(dev)) {
		dev->current_state = PCI_D3cold;
		return -EIO;
	}
    ...
}

pci_target_state() then returns PCI_D3cold when igb_remove() runs. On a
part with PME from D3hot but not from D3cold, pci_dev_run_wake()
changes from true to false.

After that, pci_device_remove() runs the same sequence regardless:

drivers/pci/pci-driver.c:pci_device_remove() {
    ...
		pm_runtime_get_sync(dev);
		pm_runtime_barrier(dev);
		drv->remove(pci_dev);
		pm_runtime_put_noidle(dev);
	}
    ...
	pm_runtime_put_sync(dev);
    ...
}

If the check was false at probe and true at remove, doesn't the usage
count stay one too high for good? The device could then never runtime
suspend again, even after rebinding.

If the check was true at probe and false at remove, doesn't this drop
one reference too many?

With power/control=auto, rpm_drop_usage_count() would warn "Runtime PM
usage count underflow!". With power/control=on, the extra put would
silently cancel the pm_runtime_forbid() reference.

Would it help to save the probe-time decision in struct igb_adapter and
test that flag in igb_remove()?

e1000e and r8169 also re-check pci_dev_run_wake() in their remove paths.
Following them doesn't by itself show that the pattern stays balanced.

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

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

end of thread, other threads:[~2026-11-17 11:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13 10:58 [PATCH net 1/3] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
2026-11-13 10:58 ` [PATCH net 2/3] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
2026-11-17 11:18   ` netdev-bot+sashiko
2026-11-13 10:58 ` [PATCH net 3/3] igb: only allow runtime PM if the device can wake up Antonio Quartulli
2026-11-17 11:18   ` netdev-bot+sashiko
2026-11-13 11:03 ` [PATCH net 1/3] igb: fix RTNL assertion when resuming from runtime suspend netdev-bot+sinfo
2026-11-15 19:37 ` Antonio Quartulli
2026-11-17 11:18 ` 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

all inboxes | Powered by JetHome®