🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
4 messages
4 total messages Started by Antonio Quartulli Fri, 20 Nov 2026 21:01
[PATCH net v4 0/4] igb: fix runtime PM resume issues
#19959
Author: Antonio Quartulli
Date: Fri, 20 Nov 2026 21:01
58 lines
12070 bytes
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
[PATCH net v4 4/4] igb: only allow runtime PM if the device can wake up
#19960
Author: Antonio Quartulli
Date: Fri, 20 Nov 2026 21:01
55 lines
11040 bytes
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
Re: [PATCH net v4 4/4] igb: only allow runtime PM if the device can wake up
#22097
Author: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 21:38
140 lines
12819 bytes
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
Re: [PATCH net v4 4/4] igb: only allow runtime PM if the device can wake up
#22186
Author: Antonio Quartulli
Date: Tue, 24 Nov 2026 23:57
32 lines
10263 bytes

On 24/11/2026 22:38, netdev-bot+sashiko@kernel.org wrote:
> 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.

Right: pci_dev_run_wake() can change while the driver is bound. v5
checks it where the runtime suspend is scheduled (the watchdog and
igb_runtime_idle()) instead of at probe and remove, which stay
unconditional, so the usage count stays balanced.

Regards,


-- 
Antonio Quartulli

CEO and Co-Founder
Mandelbit Srl
https://www.mandelbit.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