Re: [PATCH net v3 4/4] igb: only allow runtime PM if the device can wake up
From: netdev-bot+sashiko
Date: Mon Nov 23 2026 - 09:27:28 EST
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
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 fix checks wake capability only once, in igb_probe().
- [Low] Possible runtime PM usage-count imbalance in
drivers/net/ethernet/intel/igb/igb_main.c.
--
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() reports that the device can
signal a wake-up. igb_remove() takes the reference back under the same
condition. The aim is to stop the NIC from runtime suspending into a
state where it cannot notice the link coming back.
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);
[Severity: Medium]
Is a check done only at probe time enough to keep the device out of a
D-state it can't wake from?
The PCI core recomputes both the target state and the wake enable on
every runtime suspend, after igb_runtime_suspend() has run:
pci_pm_runtime_suspend()
pci_finish_runtime_suspend()
drivers/pci/pci.c:pci_finish_runtime_suspend() {
...
target_state = pci_target_state(dev, device_can_wakeup(&dev->dev));
if (target_state == PCI_POWER_ERROR)
return -EIO;
__pci_enable_wake(dev, target_state, pci_dev_run_wake(dev));
error = pci_set_power_state(dev, target_state);
...
}
If igb probes while d3cold_allowed is 0 or no_d3cold is set,
acpi_pci_choose_state() caps the target at D3hot:
if (pdev->no_d3cold || !pdev->d3cold_allowed)
d_max = ACPI_STATE_D3_HOT;
If the NIC has PME from D3hot, pci_dev_run_wake() is true there, so the
usage reference gets dropped.
Later, root can set d3cold_allowed back to 1 through sysfs, or
pci_d3cold_enable() can clear no_d3cold. The target can then become
D3cold. On a NIC whose PME_Support has no D3cold bit, pci_dev_run_wake()
is now false, and the core would put the device into D3cold with wake
disabled.
Even then, igb_runtime_idle() still schedules a suspend whenever there is
no link:
if (!igb_has_link(adapter))
pm_schedule_suspend(dev, MSEC_PER_SEC * 5);
Could this bring back the behaviour the commit message describes, where
the port stays down until it is resumed from user space? Would it make
sense to also refuse runtime suspend in igb_runtime_idle() or
igb_runtime_suspend() (for example by returning -EBUSY) when
pci_dev_run_wake() is false at that point?
I have only checked the code path here. I have not confirmed that real
82576/i350 parts on D3cold-capable platforms lack PME from D3cold.
> 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: Low]
Can this pci_dev_run_wake() call give a different answer than the one in
igb_probe()?
igb_probe() doesn't save its result. pci_dev_run_wake() recomputes it on
every call from pci_pme_capable(dev, pci_target_state(dev, true)).
Several inputs to the target state can change at runtime:
- d3cold_allowed, which root can write through d3cold_allowed_store()
- no_d3cold
- PM_QOS_FLAG_NO_POWER_OFF in acpi_pm_device_sleep_state()
- acpi_target_system_state()
On a NIC with PME from D3hot but not from D3cold, changing
d3cold_allowed between probe and unbind is enough to flip the answer.
pci_device_remove() relies on ->remove() undoing exactly what probe did:
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 probe saw false and remove sees true, one usage reference leaks. The
device can then never runtime suspend again, even after rebinding with
power/control set to auto.
If probe saw true and remove sees false, the final pm_runtime_put_sync()
drops one reference too many. With power/control set to auto, the usage
count underflows and the kernel warns. With power/control set to on, the
forbid reference is used up and the user's setting is lost.
Before this patch, the put_noidle/get_noresume pair was unconditional and
couldn't mismatch. e1000e and r8169 re-evaluate pci_dev_run_wake() in the
same way.
Would it be safer to record the decision made in igb_probe(), for example
as a flag in struct igb_adapter, and test that flag in igb_remove()?
> #ifdef CONFIG_IGB_HWMON
> igb_sysfs_exit(adapter);
> #endif
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119140412.163202-1-antonio%40mandelbit.com