Linux Power Management development
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@mandelbit.com>
To: intel-wired-lan@lists.osuosl.org
Cc: Antonio Quartulli <antonio@mandelbit.com>,
	Tony Nguyen <anthony.l.nguyen@intel.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Janis Edvarts Lacis <janislacis06@gmail.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	Sriram Yagnaraman <sriram.yagnaraman@ericsson.com>,
	Kurt Kanzenbach <kurt@linutronix.de>,
	Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
	Heiner Kallweit <hkallweit1@gmail.com>, Joe Damato <joe@dama.to>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Sven Auhagen <sven.auhagen@voleatech.de>,
	netdev@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
	stable@vger.kernel.org
Subject: [PATCH net v6 5/7] igb: link queues to NAPIs under RTNL after runtime resume
Date: Mon, 30 Nov 2026 22:37:35 +0100	[thread overview]
Message-ID: <20261130213740.3323814-6-antonio@mandelbit.com> (raw)
In-Reply-To: <20261130213740.3323814-1-antonio@mandelbit.com>

__igb_open() links queues to NAPIs with netif_queue_set_napi(), which
requires RTNL, but RTNL isn't held when resuming from runtime suspend:
this triggers "RTNL: assertion failed".

Link them in __igb_open() only when RTNL is held, and from the work
item that sets the real queue counts on runtime resume. The links can't
be kept across a suspend, because __igb_shutdown() frees the q_vectors.
The work item resumes the device and checks __IGB_DOWN under RTNL
first, so the q_vectors exist when it links them.

Tested with the 82576 emulated by QEMU.

Fixes: b75a1dea500f ("igb: Link queues to NAPI instances")
Cc: stable@vger.kernel.org # 6.16+
Closes: https://bugzilla.ipfire.org/show_bug.cgi?id=13562
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
v6: don't cancel the work item in __igb_shutdown() anymore: it resumes
the device first (patch 3), and a runtime suspend no longer waits for
RTNL (patch 1), so cancelling it there could deadlock (Sashiko); dropped
Janis's Reviewed-by
v5: cancel the work item before a suspend (Sashiko)
v4: no changes
v3: link the NAPIs from the work item added by the previous patch, and
in __igb_open() whenever RTNL is held (also on system sleep resume);
dropped Joe's Reviewed-by, as the patch changed
v2: no code changes; mention the tested hardware

Note: igc has the same issue: __igc_open() also links queues to NAPIs
(igc_set_queue_napi()) on the RTNL-less runtime resume path. A fix will
follow separately once it has been tested on igc hardware.

 drivers/net/ethernet/intel/igb/igb_main.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 8b8e8c3..55352df 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -4152,9 +4152,18 @@ static int igb_set_real_num_queues(struct igb_adapter *adapter)
 	return netif_set_real_num_queues(netdev, adapter->num_tx_queues, rxq);
 }
 
+static void igb_link_queue_napis(struct igb_adapter *adapter)
+{
+	int i;
+
+	for (i = 0; i < adapter->num_q_vectors; i++)
+		igb_set_queue_napi(adapter, i, &adapter->q_vector[i]->napi);
+}
+
 /* Some settings need RTNL, which isn't held when resuming from runtime
  * suspend: apply them from here instead, if the device is still up.
- * Resuming the device first waits for a resume or suspend in progress.
+ * Resuming the device first waits for a resume or suspend in progress, so
+ * that the q_vectors aren't being freed or allocated meanwhile.
  */
 static void igb_rtnl_resume_task(struct work_struct *work)
 {
@@ -4168,6 +4177,7 @@ static void igb_rtnl_resume_task(struct work_struct *work)
 		if (igb_set_real_num_queues(adapter))
 			netdev_err(adapter->netdev,
 				   "error setting real queue count\n");
+		igb_link_queue_napis(adapter);
 	}
 	pm_runtime_put(&adapter->pdev->dev);
 	rtnl_unlock();
@@ -4246,7 +4256,8 @@ static int __igb_open(struct net_device *netdev, bool resuming,
 	for (i = 0; i < adapter->num_q_vectors; i++) {
 		napi = &adapter->q_vector[i]->napi;
 		napi_enable(napi);
-		igb_set_queue_napi(adapter, i, napi);
+		if (rtnl_held)
+			igb_set_queue_napi(adapter, i, napi);
 	}
 
 	/* Clear any pending interrupts. */
-- 
2.56.1


  parent reply	other threads:[~2026-11-30 21:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 21:37 [PATCH net v6 0/7] igb: fix runtime PM resume issues Antonio Quartulli
2026-11-30 21:37 ` [PATCH net v6 1/7] igb: don't wait for RTNL when runtime suspending Antonio Quartulli
2026-11-30 21:37 ` [PATCH net v6 2/7] igb: don't touch rings that don't exist when disabling an XSK pool Antonio Quartulli
2026-11-30 21:37 ` [PATCH net v6 3/7] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
2026-11-30 21:37 ` [PATCH net v6 4/7] igb: keep the stack's Rx queues that still have an XSK pool Antonio Quartulli
2026-11-30 21:37 ` Antonio Quartulli [this message]
2026-11-30 21:37 ` [PATCH net v6 6/7] igb: resume the device before changing XDP or XSK settings Antonio Quartulli
2026-11-30 21:37 ` [PATCH net v6 7/7] igb: only allow runtime PM if the device can wake up Antonio Quartulli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130213740.3323814-6-antonio@mandelbit.com \
    --to=antonio@mandelbit.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hawk@kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=janislacis06@gmail.com \
    --cc=joe@dama.to \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kurt@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=rafael@kernel.org \
    --cc=sdf@fomichev.me \
    --cc=sriram.yagnaraman@ericsson.com \
    --cc=stable@vger.kernel.org \
    --cc=sven.auhagen@voleatech.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox